Subject: Re: [bug#74677] [PATCH] nix/local.mk: fix -lgcrypt link on --as-needed toolchains

From: Ludovic Courtès <[email-masked]>
Date: Mon, 09 Dec 2024 23:17:31 +0100

Hi Sergei,

Sergei Trofimovich <[email-masked]> skribis:

> https://git.savannah.gnu.org/cgit/guix.git/commit/?id=8a7bd211d21f06c1234fbb82bb905d202d58f598
> introduced a build regression on Gentoo as:
>
>     x86_64-pc-linux-gnu-g++ -Wall -std=c++11 -O2 -pipe   -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--hash-style=gnu -lgcrypt -o guix-daemon nix/nix-daemon/guix_daemon-nix-daemon.o nix/nix-daemon/guix_daemon-guix-daemon.o libstore.a libutil.a libformat.a -lz -lsqlite3  -lbz2
>     /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: nix/nix-daemon/guix_daemon-guix-daemon.o: in function `main':
> guix-daemon.cc:(.text.startup+0x62): undefined reference to `gcry_check_version'
>
> This happens because:
> - Gentoo linker is using --Wl,-as-needed by default
> - -lgcrypt is passed before actual use of it's symbols in `guix-daemon.cc`

I pushed as dcaccc8b722cee279c00bb321baa48ae73563931 the patch
Doğan Çeçen submitted to fix this regression and more:

  https://issues.guix.gnu.org/74686

Thanks,
Ludo’.