Skip to content

Hadrian: Build fails if StgRun/Return are implemented in asm file

Summary

Hadrian fails to build if StgRun and StgReturn are implemented in assembler file rts/StgCRunAsm.S rather than in C file rts/StgCRun.c:

$ ./hadrian/build.sh
[...]
Run Ar Pack Stage1: _build/stage1/rts/build/c/Adjustor.thr_l_o (and 116 more) => _build/stage1/rts/build/libHSrts-1.0_thr_l.a
/usr/bin/ar: creating _build/stage1/rts/build/libHSrts-1.0_thr_l.a

rts/Schedule.c:452:0: error:
     error: undefined reference to 'StgRun'
    |
452 |         r = StgRun((StgFunPtr) stg_returnToStackTop, &cap->r);
    | ^
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
Error when running Shake build system:
  at action, called at src/Rules.hs:71:19 in main:Rules
  at need, called at src/Rules.hs:93:5 in main:Rules
* Depends on: _build/stage1/bin/hp2ps
* Depends on: _build/stage1/rts/build/libHSrts-1.0_thr_debug-ghc8.9.0.20191001.so
* Raised the exception:
user error (Development.Shake.cmd, system command failed
Command line: _build/stage0/bin/ghc [...]
Exit code: 1
Stderr:
Warning: -rtsopts and -with-rtsopts have no effect with -shared.
    Call hs_init_ghc() from your main() function to set these options.

rts/Schedule.c:452:0: error:
     error: undefined reference to 'StgRun'
    |
452 |         r = StgRun((StgFunPtr) stg_returnToStackTop, &cap->r);
    | ^
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
)

Steps to reproduce

Just move both functions from the C file to the S file of your favourite architecture. Then in file rts/rts.cabal.in add your favourite architecture to the if condition for asm-sources: StgCRunAsm.S and run hadrian.

Are there other places in which the assembler file must be registered for an particular architecture? Did I miss something?

Environment

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information