ghc-stage2 fails with ld: fatal: library -lrt: not found on topHandler02(profthreaded) test
On SmartOS ghc-stage2 crashes with an error when trying to run the topHandler02(dyn) test: ld: fatal: library -lrt: not found
Tracing this with the following DTrace script to stop ghc-stage2 at the point of launching ld:
~/exit_on_ld.d: {{{ #!/usr/sbin/dtrace -s
#pragma D option destructive
syscall::exec*:entry /copyinstr(arg0) == "/usr/bin/ld"/ {
trace(pid);
stop();
system("pargs %d", pid);
exit(0);
} }}}
This let me observe the command-line arguments to ld:
In ssh session A I started DTrace:
chmod +x ~/exit_on_ld.d
~/exit_on_ld.d
In a ssh session B I started the topHandler02(dyn) test manually with no output redirection:
cd ~/ghc/libraries/base/tests && '/root/ghc/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -o topHandler02 topHandler02.hs -O -prof -static -auto-all -threaded
In ssh session A I observed the ld call (ghc-stage2 is now frozen by stop):
CPU ID FUNCTION:NAME
3 5167 exece:entry 9186691866: /opt/local/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.3/collect2 -R/opt/local
argv[0]: /opt/local/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.3/collect2
argv[1]: -R/opt/local/lib/
argv[2]: -Y
argv[3]: P,/lib/amd64:/usr/lib/amd64:/opt/local/lib/
argv[4]: -Qy
argv[5]: -o
argv[6]: topHandler02.o
argv[7]: -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3
argv[8]: -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib/amd64
argv[9]: -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../amd64
argv[10]: -L/lib/amd64
argv[11]: -L/usr/lib/amd64
argv[12]: -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib
argv[13]: -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../..
argv[14]: -R/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64
argv[15]: -R/opt/local/gcc47/lib/amd64
argv[16]: -lrt
argv[17]: -r
argv[18]: /tmp/ghc91814_0/ghc91814_6.o
argv[19]: /tmp/ghc91814_0/ghc91814_5.o
I was then able to run them in isolation with GHC's temp files present on disk:
# /opt/local/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.3/collect2 -R/opt/local/lib/ -Y P,/lib/amd64:/usr/lib/amd64:/opt/local/lib/ -Qy -o topHandler02.o -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib/amd64 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../amd64 -L/lib/amd64 -L/usr/lib/amd64 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../.. -R/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64 -R/opt/local/gcc47/lib/amd64 -lrt -r /tmp/ghc91814_0/ghc91814_6.o /tmp/ghc91814_0/ghc91814_5.o
ld: fatal: library -lrt: not found
ld: fatal: file processing errors. No output written to topHandler02.o
collect2: error: ld returned 1 exit status
If I omit -lrt from the arguments it succeeds (on Illumos-based systems, including SmartOS, librt is a passthrough to libc):
# /opt/local/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.3/collect2 -R/opt/local/lib/ -Y P,/lib/amd64:/usr/lib/amd64:/opt/local/lib/ -Qy -o topHandler02.o -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib/amd64 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../amd64 -L/lib/amd64 -L/usr/lib/amd64 -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../../../x86_64-sun-solaris2.11/lib -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3/../../.. -R/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64 -R/opt/local/gcc47/lib/amd64 -r /tmp/ghc91814_0/ghc91814_6.o /tmp/ghc91814_0/ghc91814_5.o
# echo $?
0
No errors are emitted and the exit code is 0 (good).
I would like to conditionally omit -lrt from the ld arguments.
Where do I need to look for where ghc-stage2 populates the arguments to ld?
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |