`ghc-iserv` assertion failed when cross-compiling
Summary
When trying to cross-compile a template haskell source file on x86_64 targeting aarch64 with -fexternal-interpreter
, ghc-iserv
crashes:
ghc-iserv: internal error: ASSERTION FAILED: file rts/linker/elf_reloc_aarch64.c, line 99
(GHC version 9.0.2 for aarch64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Steps to reproduce
Source file:
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax
main :: IO ()
main = putStrLn $( do liftString ("answer: " ++ show 42) )
Compile with:
$ aarch64-unknown-linux-gnu-ghc -pgmi /path/to/ghc/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/bin/ghc-iserv -fexternal-interpreter -v thmain.hs
Output:
Glasgow Haskell Compiler, Version 9.0.2, stage 1 booted by GHC version 8.10.7
*** initializing unit database:
Using binary package database: /nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/package.conf.d/package.cache
package flags []
loading package database /nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.7.0
wired-in package ghc-bignum mapped to ghc-bignum-1.1
wired-in package base mapped to base-4.15.1.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.17.0.0
wired-in package ghc not found.
!!! initializing unit database: finished in 9.60 milliseconds, allocated 8.889 megabytes
*** initializing unit database:
package flags []
loading package database /nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.7.0
wired-in package ghc-bignum mapped to ghc-bignum-1.1
wired-in package base mapped to base-4.15.1.0
wired-in package rts mapped to rts-1.0.2
wired-in package template-haskell mapped to template-haskell-2.17.0.0
wired-in package ghc not found.
!!! initializing unit database: finished in 7.79 milliseconds, allocated 2.035 megabytes
*** Chasing dependencies:
Chasing modules from: *thmain.hs
!!! Chasing dependencies: finished in 0.67 milliseconds, allocated 0.696 megabytes
Stable obj: {Main}
Stable BCO: {}
Ready for upsweep
[NONREC
ModSummary {
ms_hs_date = 2022-06-20 12:20:46.437771223 UTC
ms_mod = Main,
ms_textual_imps = [(Nothing, Prelude),
(Nothing, Language.Haskell.TH.Syntax)]
ms_srcimps = []
}]
*** Deleting temp files:
Deleting:
compile: input file thmain.hs
*** Checking old interface for Main (use -ddump-hi-diffs for more details):
[1 of 1] Compiling Main ( thmain.hs, thmain.o )
*** Parser [Main]:
!!! Parser [Main]: finished in 0.37 milliseconds, allocated 0.244 megabytes
*** Renamer/typechecker [Main]:
*** Simplify [expr]:
!!! Simplify [expr]: finished in 0.07 milliseconds, allocated 0.056 megabytes
*** CorePrep [expr]:
!!! CorePrep [expr]: finished in 0.32 milliseconds, allocated 0.795 megabytes
*** GHC.CoreToByteCode [Ghci1]:
Starting /nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/bin/ghc-iserv
!!! GHC.CoreToByteCode [Ghci1]: finished in 2.63 milliseconds, allocated 0.183 megabytes
*** systool:linker:
*** gcc:
/nix/store/8l6s18lnfvsh1ixzza2x62yyn6pfq9gx-aarch64-unknown-linux-gnu-stage-final-gcc-debug-wrapper-9.3.0/bin/aarch64-unknown-linux-gnu-cc '-fuse-ld=gold' -Wl,-z,noexecstack -B/nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/ghc-prim-0.7.0 --print-file-name libc.so
!!! systool:linker: finished in 0.41 milliseconds, allocated 0.098 megabytes
*** systool:linker:
*** gcc:
/nix/store/8l6s18lnfvsh1ixzza2x62yyn6pfq9gx-aarch64-unknown-linux-gnu-stage-final-gcc-debug-wrapper-9.3.0/bin/aarch64-unknown-linux-gnu-cc '-fuse-ld=gold' -Wl,-z,noexecstack -B/nix/store/5j5pldfyaayh1kgymcgwv11d7plmlk63-aarch64-unknown-linux-gnu-ghc-native-bignum-9.0.2/lib/aarch64-unknown-linux-gnu-ghc-9.0.2/ghc-prim-0.7.0 --print-file-name libm.so
!!! systool:linker: finished in 0.22 milliseconds, allocated 0.074 megabytes
Loading package ghc-prim-0.7.0 ... linking ... ghc-iserv: internal error: ASSERTION FAILED: file rts/linker/elf_reloc_aarch64.c, line 99
(GHC version 9.0.2 for aarch64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
ghc: ghc-iserv terminated (-6)
(Note: ghc-iserv
is an aarch64 binary, but I have enabled binfmt_misc support for aarch64 using qemu-aarch64
so I can run aarch64 binaries transparently on my system)
Backtrace:
#0 0x00000055008dca88 in raise () from /nix/store/y3rh7f9mhi5qnv5vci01ds607gjywcad-glibc-aarch64-unknown-linux-gnu-2.33-108/lib/libc.so.6
#1 0x00000055008ca1f4 in abort () from /nix/store/y3rh7f9mhi5qnv5vci01ds607gjywcad-glibc-aarch64-unknown-linux-gnu-2.33-108/lib/libc.so.6
#2 0x0000000001de3870 in rtsFatalInternalErrorFn ()
#3 0x0000000001de39c8 in barf ()
#4 0x0000000001de3a20 in _assertFail ()
#5 0x0000000001e179c0 in encodeAddendAarch64 ()
#6 0x0000000001e17b50 in relocateObjectCodeAarch64 ()
#7 0x0000000001dfd2cc in ocResolve_ELF ()
#8 0x0000000001de0c80 in ocTryLoad ()
#9 0x0000000001de10ec in resolveObjs ()
#10 0x0000000000fe4d78 in ghcizm9zi0zi2_GHCiziObjLink_resolveObjs1_info$def ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Expected behavior
I would expect the source file to be compiled without errors, I tested this with GHC 8.10.4 and it worked flawlessly.
Environment
- GHC version used: 9.0.2 native-bignum
Optional:
- Operating System: NixOS / Linux x1 5.17.7-zen1 #1 (closed)-NixOS ZEN SMP PREEMPT Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux
- System Architecture: x86_64