Static link error with nettle built on Debian bookworm on arm64
When doing a linux-arm64 static build, the linkage errors out if I build the external deps on arm64 on Debian Bookworm:
build/deps/linux-arm64-default_10/lib/libnettle.a(fat-arm64.o): in function `fat_init':
Unvanquished/daemon/external_deps/build-linux-arm64-default_10/nettle/nettle-3.8.1/fat-arm64.c:219:(.text.startup+0x154):
relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `_nettle_aes256_decrypt_c'
defined in .text section in build/deps/linux-arm64-default_10/lib/libnettle.a(aes256-decrypt.o)
/usr/bin/ld: Unvanquished/daemon/external_deps/build-linux-arm64-default_10/nettle/nettle-3.8.1/fat-arm64.c:219:
warning: too many GOT entries for -fpic, please recompile with -fPIC
For our release builds, we cross-compile the linux-arm64 external deps amd64 and Debian Buster, so there are multiple variations at play that may prevent us to face this problem in our release build.
When I force the -fPIC flag for the whole external deps build, the error is still there.
When I force the
-fPICflag for the whole external deps build, the error is still there.
Weird, days later I noticed it, now it worked with that flag. Well, good news then.
No, now that I cleaned-up the build folder, I get this error again…
I faced a different problem with the i686 build: the build system returns successfully, but it mysteriously does not build libhogweed.a. This was due to not building the gmp dependency first. A regression caused by reordering package lists/building them by concatenating variables. Annoyingly, I don't see any Nettle configure option to require building the component.
So I suspect your problems are based on whether you built gmp first or not. If you haven't built gmp, the build system might be grabbing a libhogweed from the system packages with incompatible flags. But if you still get this error you might try configuring with --disable-fat.
To be clear, I'm testing with #1433. The commit that moves Nettle first in the package list ordering is external_deps: add the “release” meta package. That moves Nettle to the "all" list with the idea that is too broken for the release. If my previous comment is right, this bug could be caused by its own workaround 😛
Interesting. After reproducing the bug one day I may have tried to build nettle without building other packages and then, reproducing the bug. I only did the re-ordering after that, and then, maybe engraved the bug in stone by doing so. 🤪
I'll try chaining the build of gmp and nettle then.
Woohoo, nettle built in bookworm for linux-arm64!
Ah no:
/Unvanquished/daemon/external_deps/linux-arm64-default_11/lib/libnettle.a(fat-arm64.o): in function `fat_init':
/Unvanquished/daemon/external_deps/build-linux-arm64-default_11/nettle/nettle-3.10.2/fat-arm64.c:289:(.text.startup+0x1d4): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `_nettle_sha256_compress_n_c' defined in .text section in /Unvanquished/daemon/external_deps/linux-arm64-default_11/lib/libnettle.a(sha256-compress-n.o)
/usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /Unvanquished/daemon/external_deps/build-linux-arm64-default_11/nettle/nettle-3.10.2/fat-arm64.c:289: warning: too many GOT entries for -fpic, please recompile with -fPIC
Well, let's try --disable-fat, I remember having tested that, but well…
OK now it works. I reached the stage where dump_syms crashes when extracting the symbols, meaning all the binaries were built successfully.