Summary
Static linking is broken on Solaris
Metadata
- Id: ea0dd08101f39d3e121e76300002b0314d1954bc
- Trac id: 1350
- Type: defect
- Reporter: evhan
- Owner:
- Cc:
- Status: new
- Component: unknown
- Estimated difficulty: medium
- Resolution:
- Priority: minor
- Milestone: someday
- Version: 4.12.0
- Changetime: 2026-07-14 21:56:22 UTC
- Created: 2017-03-08 05:06:23 UTC
- Keywords: static solaric ld linker
Description
While testing Peter's fix for #1347, I found that static linking is totally broken on Solaris.
In particular, our linking tests fail on both Solaris 10 and 11 (gcc, i386 -- I haven't tried with any other compiler or architecture), albeit with slightly different error messages. The underlying issue might be the same, however, since they both fail in the same situations.
Note that this problem isn't caused by the fix for #1347; both c4c60ce5 and 4.12.0 fail in the same way, so this was a preexisting bug.
Try running the following command to see the problem:
$ echo '(print 1)' | csc -static -o /tmp/a.out -
Test output on Solaris 10:
==> solaris-solaris-10-i386: ======================================== linking tests ... ==> solaris-solaris-10-i386: [... snip ...] ==> solaris-solaris-10-i386: /export/home/vagrant/chicken-core/tests/../chicken 'linking-tests.scm' -output-file 'linking-tests.c' -feature chicken-compile-static -verbose -include-path /export/home/vagrant/chicken-core/tests/.. -uses reverser ==> solaris-solaris-10-i386: 'gcc' 'linking-tests.c' -o 'linking-tests.o' -c -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -I/export/home/vagrant/chicken-core/tests/.. -I/export/home/vagrant/chicken-core/tests/../include/chicken/ ==> solaris-solaris-10-i386: rm linking-tests.c ==> solaris-solaris-10-i386: 'gcc' 'linking-tests.o' 'reverser.o' -o 'linking-tests' -L/export/home/vagrant/chicken-core/tests/.. -L/export/home/vagrant/chicken-core/tests/../lib/ -Wl,-R'/export/home/vagrant/chicken-core/lib/' -static -lchicken -lsocket -lnsl -lm -ldl -lrt ==> solaris-solaris-10-i386: ld: fatal: library -lsocket: not found ==> solaris-solaris-10-i386: ld: fatal: library -lnsl: not found ==> solaris-solaris-10-i386: ld: fatal: library -lm: not found ==> solaris-solaris-10-i386: ld: fatal: library -ldl: not found ==> solaris-solaris-10-i386: ld: fatal: library -lrt: not found ==> solaris-solaris-10-i386: ld: fatal: library -lc: not found ==> solaris-solaris-10-i386: ld: fatal: file processing errors. No output written to linking-tests ==> solaris-solaris-10-i386: Error: shell command terminated with non-zero exit status 256: 'gcc' 'linking-tests.o' 'reverser.o' -o 'linking-tests' -L/export/home/vagrant/chicken-core/tests/.. -L/export/home/vagrant/chicken-core/tests/../lib/ -Wl,-R'/export/home/vagrant/chicken-core/lib/' -static -lchicken -lsocket -lnsl -lm -ldl -lrt
Test output on Solaris 11:
==> solaris-solaris-11-i386: ======================================== linking tests ... ==> solaris-solaris-11-i386: [... snip ...] ==> solaris-solaris-11-i386: /export/home/vagrant/chicken-core/tests/../chicken 'linking-tests.scm' -output-file 'linking-tests.c' -feature chicken-compile-static -verbose -include-path /export/home/vagrant/chicken-core/tests/.. -uses reverser ==> solaris-solaris-11-i386: 'gcc' 'linking-tests.c' -o 'linking-tests.o' -c -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -I/export/home/vagrant/chicken-core/tests/.. -I/export/home/vagrant/chicken-core/tests/../include/chicken/ ==> solaris-solaris-11-i386: rm linking-tests.c ==> solaris-solaris-11-i386: 'gcc' 'linking-tests.o' 'reverser.o' -o 'linking-tests' -L/export/home/vagrant/chicken-core/tests/.. -L/export/home/vagrant/chicken-core/tests/../lib/ -Wl,-R'/export/home/vagrant/chicken-core/lib/' -static -lchicken -lsocket -lnsl -lm -ldl -lrt ==> solaris-solaris-11-i386: ld: fatal: option '-R/export/home/vagrant/chicken-core/lib/' is incompatible with building a static executable ==> solaris-solaris-11-i386: ==> solaris-solaris-11-i386: Error: shell command terminated with non-zero exit status 256: 'gcc' 'linking-tests.o' 'reverser.o' -o 'linking-tests' -L/export/home/vagrant/chicken-core/tests/.. -L/export/home/vagrant/chicken-core/tests/../lib/ -Wl,-R'/export/home/vagrant/chicken-core/lib/' -static -lchicken -lsocket -lnsl -lm -ldl -lrt
Changes and comments
[2017-03-12 20:50:57 UTC] sjamaan wrote:
It looks like static linking against system libraries simply isn't supported on Solaris...
Maybe we need to do something with LIBRARIES so that we know which ones need to be put in front of an (optional) -static flag, so that they are linked dynamically? Alternatively, disable static linking altogether on Solaris...
[2017-03-12 21:00:40 UTC] sjamaan wrote:
I asked on #openindiana and people there confirmed that indeed, static system libraries are not available.
[2017-03-12 22:14:04 UTC] sjamaan wrote:
TODO: Check how Golang deals with this. They support Solaris since version 1.3
[2026-07-14 21:55:40 UTC] felix wrote:
not sure if this is really worth the effort...