On Sun, Feb 2, 2020 at 11:06 PM Niels Möller nisse@lysator.liu.se wrote:
Jeffrey Walton noloader@gmail.com writes:
When linking the shared object with -G on Solaris:
gcc -g2 -O2 -m64 -march=native -fPIC -pthread -Wno-pointer-sign -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -L/usr/local/lib -m64 -Wl,-R,'$ORIGIN/../lib' -Wl,-R,/usr/local/lib -G -h libnettle.so.7 aes-decrypt-internal.o aes-decrypt.o aes-encrypt-internal.o aes-encrypt.o aes-encrypt-table.o ...
It results in:
ld.so.1: aes-test: fatal: relocation error: R_AMD64_PC32: file ../.lib/libhogweed.so.5: symbol _init: value 0x7f004df15e9d does not fit ../run-tests: line 61: 12934: Killed FAIL: aes ld.so.1: arcfour-test: fatal: relocation error: R_AMD64_PC32: file ../.lib/libhogweed.so.5: symbol _init: value 0x7f004df15a1d does not fit ../run-tests: line 61: 12939: Killed FAIL: arcfour ld.so.1: arctwo-test: fatal: relocation error: R_AMD64_PC32: file ../.lib/libhogweed.so.5: symbol _init: value 0x7f004df153dd does not fit ../run-tests: line 61: 12944: Killed FAIL: arctwo ...
Here's the full paste of the build using -G: https://pastebin.com/SKZxKfdZ.
Please use -shared, not -G. -shared works as expected on Solaris.
So you're suggesting the following change, right?
Yes, for GCC.
diff --git a/configure.ac b/configure.ac index 09f719a0..ba3ab7c6 100644 --- a/configure.ac +++ b/configure.ac @@ -655,13 +655,13 @@ case "$host_os" in LIBNETTLE_FORLINK=libnettle.so LIBNETTLE_SONAME='$(LIBNETTLE_FORLINK).$(LIBNETTLE_MAJOR)' LIBNETTLE_FILE='$(LIBNETTLE_SONAME).$(LIBNETTLE_MINOR)'
- LIBNETTLE_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -G -h $(LIBNETTLE_SONAME)'
LIBNETTLE_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -shared -h $(LIBNETTLE_SONAME)' LIBNETTLE_LIBS=''
LIBHOGWEED_FORLINK=libhogweed.so LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)' LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
- LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -G -h $(LIBHOGWEED_SONAME)'
- LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) --shared -h $(LIBHOGWEED_SONAME)' LIBHOGWEED_LIBS='libnettle.so $(LIBS)' ;; *)
IIRC, the reason for current use of -G rather than -shared is that it worked better with Solaris cc. But according to
https://docs.oracle.com/cd/E77782_01/html/E77792/gqexw.html#OSGCCgqfch
-shared was added as an alias for -G in Oracle Developer Studio 12.4, and changed to be more gcc-compatible in 12.6.
Yeah, -G and -shared seems to be a moving target with some features undocumented.
Are you able to test if building shared libraries still works with these tools? Support for unusual proprietary compilers linkers is not that high a priority, but it would be nice to keep it working, or at least, know when breaking it.
Not at the moment.
I have a Solaris 11.3 box, but it does not have Sun Studio on it. Two other testing machines have Sun Studio 12.1 through 12.6, but both are dead at the moment. I need to order some parts.
Maybe the OpenCSW folks have something that can test Sun Studio. They provide free accounts to developers.
Here's the full paste of the build using -G: https://pastebin.com/SKZxKfdZ.
: checking build system type... i386-pc-solaris2.11 : checking host system type... x86_64-sun-solaris2
Looks like a cross-compile configuration. Is that intentional?
Braindead Autotools. Sun provides a multilib system out of the box, running a 64-bit kernel:
jwalton@Solaris:~$ isainfo amd64 i386 jwalton@Solaris:~$ isainfo -b 64
Sun says to build 64-bit binaries on 64-bit systems. Confer, https://docs.oracle.com/cd/E37838_01/html/E66175/features-1.html.
But Autotools detects the system as i386:
$ /usr/share/automake-1.11/config.guess i386-pc-solaris2.11
So I have to tell Autotools to build for a 64-bit system via --host=amd64-sun-solaris
Jeff