Hadrian doesn't pass -DNOSMP to C compiler if target doesn't support SMP
Compiling GHC 9.4.7 on mips64el fails with:
| Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
===> Command failed with error code: 1
In file included from rts/include/Stg.h:348,
from rts/include/Rts.h:38,
from rts/hooks/FlagDefaults.c:8:
rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
416 | #error memory barriers unimplemented on this architecture
| ^~~~~
rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
440 | #error memory barriers unimplemented on this architecture
| ^~~~~
rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
464 | #error memory barriers unimplemented on this architecture
| ^~~~~
Error when running Shake build system:
at want, called at src/Main.hs:124:44 in main:Main
* Depends on: binary-dist-dir
at need, called at src/Rules/BinaryDist.hs:130:9 in main:Rules.BinaryDist
* Depends on: _build/stage1/lib/package.conf.d/rts-1.0.2.conf
at need, called at src/Rules/Register.hs:126:5 in main:Rules.Register
* Depends on: _build/stage1/rts/build/libHSrts-1.0.2_thr_debug_p.a
at need, called at src/Rules/Library.hs:160:5 in main:Rules.Library
* Depends on: _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o
at cmd', called at src/Builder.hs:384:23 in main:Builder
at cmdArgs, called at src/Builder.hs:524:8 in main:Builder
at cmdArgs, called at src/Builder.hs:548:18 in main:Builder
at cmdArgs, called at src/Builder.hs:548:18 in main:Builder
at error, called at src/Builder.hs:593:13 in main:Builder
* Raised the exception:
Command failed
We didn't have this issue when building with the old make system, so this is a bug introduced in Hadrian.
I believe the problem is that Hadrian doesn't pass the -DNOSMP
flag to C compiler (but does so for GHC) see https://gitlab.haskell.org/ghc/ghc/-/blob/1b213d336bcb0e66c5773b6015924b57a3a59de5/hadrian/src/Settings/Packages.hs#L302.
I will try passing this flag to cArgs
as well, and submit a PR if this fixes the issue.