Skip to content

Commit 6886c43

Browse files
committed
Fix for GHC 9.6 JS backend
1 parent f474ff4 commit 6886c43

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

compiler/ghc/default.nix

+15-5
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,26 @@ stdenv.mkDerivation (rec {
397397
done
398398
''
399399
# Use emscripten and the `config.sub` saved by `postPatch`
400-
+ lib.optionalString (targetPlatform.isGhcjs) ''
400+
+ lib.optionalString (targetPlatform.isGhcjs) (''
401401
export CC="${targetCC}/bin/emcc"
402402
export CXX="${targetCC}/bin/em++"
403403
export LD="${targetCC}/bin/emcc"
404-
export AR="${targetCC}/bin/emar"
405-
export NM="${targetCC}/share/emscripten/emnm"
406-
export RANLIB="${targetCC}/bin/emranlib"
404+
'' + (
405+
# Including AR and RANLIB here breaks tests.js-template-haskell for GHC 9.6
406+
# `LLVM ERROR: malformed uleb128, extends past end`
407+
if builtins.compareVersions ghc-version "9.8" >= 0
408+
then ''
409+
export AR="${targetCC}/bin/emar"
410+
export NM="${targetCC}/share/emscripten/emnm"
411+
export RANLIB="${targetCC}/bin/emranlib"
412+
''
413+
else ''
414+
export NM="${targetCC}/share/emscripten/emnm"
415+
''
416+
) + ''
407417
export EM_CACHE=$(mktemp -d)
408418
mv config.sub.ghcjs config.sub
409-
''
419+
'')
410420
# GHC is a bit confused on its cross terminology, as these would normally be
411421
# the *host* tools.
412422
+ lib.optionalString (!targetPlatform.isGhcjs) (''

0 commit comments

Comments
 (0)