Skip to content

Commit

Permalink
Add preBuild to set CFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Nov 29, 2024
1 parent f1309bb commit 821ad3b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ stdenv.mkDerivation (rec {
dontStrip = true;
dontPatchELF = true;
noAuditTmpdir = true;
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin || stdenv.targetPlatform.isWindows) {
} // {
# ghc install on macOS wants to run `xattr -r -c`
# The macOS version fails because it wants python 2.
# The nix version of xattr does not support those args.
Expand All @@ -805,6 +805,11 @@ stdenv.mkDerivation (rec {
if [[ -f rts/win32/ThrIOManager.c ]]; then
substituteInPlace rts/win32/ThrIOManager.c --replace rts\\OSThreads.h rts/OSThreads.h
fi
''
+ lib.optionalString (targetPlatform.isAndroid && targetPlatform.isAarch32) ''
export NIX_CFLAGS_COMPILE_${
lib.replaceStrings ["-" "."] ["_" "_"] stdenv.targetPlatform.config
}+=" -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
'';
# Same hack as 'preBuild'
preInstall = lib.optionalString stdenv.buildPlatform.isDarwin ''
Expand All @@ -827,6 +832,7 @@ stdenv.mkDerivation (rec {
'cross-compiling = NO'
'';
buildPhase = ''
runHook preBuild
${hadrian}/bin/hadrian ${hadrianArgs}
'' + lib.optionalString (installStage1 && !stdenv.targetPlatform.isGhcjs && builtins.compareVersions ghc-version "9.8" < 0) ''
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
Expand All @@ -841,6 +847,8 @@ stdenv.mkDerivation (rec {
mv $exe ${targetPrefix}$exe
done
popd
'' + ''
runHook postBuild
'';

# Hadrian's installation only works for native compilers, and is broken for cross compilers.
Expand Down

0 comments on commit 821ad3b

Please sign in to comment.