Intermediate LLVM files mangled up
Build GHC via LLVM backend fails if option
-keep-llvm-files is present and multiple threads are used, i.e.,
Compile GHC via
./boot && ./configure && make -j using the following
include mk/flavours/quick-llvm.mk GhcStage2HcOpts += -keep-llvm-files GhcLibHcOpts += -keep-llvm-files GhcRtsHcOpts += -keep-llvm-files
results in the following error:
... make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.dyn_o] Error 1 make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.l_o] Error 1 make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.thr_l_dyn_o] Error 1 make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.thr_o] Error 1 make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.thr_dyn_o] Error 1 make: *** [rts/ghc.mk:315: rts/dist/build/AutoApply.l_dyn_o] Error 1 opt: rts/dist/build/AutoApply.ll:20589:28: error: expected value token %ln4ve = mul i64 %ln4vd, g, i64* noalias nocapture %Sp_Arg, i64* noalias nocapture %Hp_Arg, i64 %R1_Arg, i64 %SpLim_Arg) align 8 nounwind ^ `opt' failed in phase `LLVM Optimiser'. (Exit code: 1) ...
An excerpt of file
rts/dist/build/AutoApply.ll looks as follows:
20583 tail call ghccc void (i64*, i64*, i64*, i64, i64) %ln4v7( i64* %Base_Arg, i64* %ln4v8, i64* %ln4v9, i64 %ln4va, i64 %SpLim_Arg ) nounwind 20584 ret void 20585 cBT: 20586 %ln4vb = load i64*, i64** %Sp_Var 20587 %ln4vc = ptrtoint i64* %ln4vb to i64 20588 %ln4vd = sub i64 0, 1 20589 %ln4ve = mul i64 %ln4vd, 8 20590 %ln4vf = add i64 %ln4vc, %ln4ve 20591 %ln4vg = inttoptr i64 %ln4vf to i64* 20592 store i64* %ln4vg, i64** %Sp_Var 20593 %ln4vh = load i64*, i64** %Sp_Var
For example, the function signature is messed up.
It looks like as if all builds of different ways of AutoApply are using the same intermediate LLVM file resulting in a race condition.
GHC release 8.6.5 (git 92b6a023) was used as stage0 compiler and as the actual target compiler.