[PATCH] daemon: Fix linking gcrypt when --as-needed linker arg is used

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Do?an Çeçen
Owner
unassigned
Submitted by
Do?an Çeçen
Severity
normal
D
D
Do?an Çeçen wrote on 4 Dec 11:10 +0100
(address . guix-patches@gnu.org)(name . Do?an Çeçen)(address . sepeth@fastmail.com)
5a89940f415ff9475062136c4e29e27d650fdbe3.1733307011.git.sepeth@fastmail.com
As it is mentioned in autoconf manual that library names should be
specified in LIBS, not LDFLAGS. See:


This change also brings back the save_* vars trick that was there
before. I missed in my earlier change that nix/local.mk was referring
LIBGCRYPT_* vars directly.

And, instead of CXXFLAGS, CPPFLAGS is used since the latter is probably
more correct as this is used for include dirs, therefore using
preprocessor flags.

Tested with ./configure LDFLAGS="-Wl,--as-needed" --with-libgcrypt-prefix=... combinations.

Change-Id: Iadb10e1994c9a78e2927847af2cfe5e096fbb2a8
---
config-daemon.ac | 20 ++++++++++++++------
nix/local.mk | 8 ++++++--
2 files changed, 20 insertions(+), 8 deletions(-)

Toggle diff (90 lines)
diff --git a/config-daemon.ac b/config-daemon.ac
index 1ac204ceed1..6731c68bc39 100644
--- a/config-daemon.ac
+++ b/config-daemon.ac
@@ -39,27 +39,32 @@ if test "x$guix_build_daemon" = "xyes"; then
case "$LIBGCRYPT_PREFIX" in
no)
- LIBGCRYPT_CXXFLAGS=""
+ LIBGCRYPT_CPPFLAGS=""
;;
*)
- LIBGCRYPT_CXXFLAGS="-I$LIBGCRYPT_PREFIX/include"
+ LIBGCRYPT_CPPFLAGS="-I$LIBGCRYPT_PREFIX/include"
;;
esac
case "$LIBGCRYPT_LIBDIR" in
no | "")
- LIBGCRYPT_LDFLAGS="-lgcrypt"
;;
*)
- LIBGCRYPT_LDFLAGS="-L$LIBGCRYPT_LIBDIR -lgcrypt"
+ LIBGCRYPT_LDFLAGS="-L$LIBGCRYPT_LIBDIR"
;;
esac
- AC_SUBST([LIBGCRYPT_CXXFLAGS])
+ LIBGCRYPT_LIBS="-lgcrypt"
+ AC_SUBST([LIBGCRYPT_CPPFLAGS])
AC_SUBST([LIBGCRYPT_LDFLAGS])
+ AC_SUBST([LIBGCRYPT_LIBS])
- CXXFLAGS="$CXXFLAGS $LIBGCRYPT_CXXFLAGS"
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ save_LIBS="$LIBS"
+ CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBGCRYPT_LDFLAGS"
+ LIBS="$LIBS $LIBGCRYPT_LIBS"
have_gcrypt=yes
AC_CHECK_LIB([gcrypt], [gcry_md_open], [:], [have_gcrypt=no])
@@ -67,6 +72,9 @@ if test "x$guix_build_daemon" = "xyes"; then
if test "x$have_gcrypt" != "xyes"; then
AC_MSG_ERROR([GNU libgcrypt not found; please install it.])
fi
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
dnl Chroot support.
AC_CHECK_FUNCS([chroot unshare])
diff --git a/nix/local.mk b/nix/local.mk
index 8a2b2b88e86..0d23a48a024 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -69,7 +69,8 @@ libutil_headers = \
libutil_a_CPPFLAGS = \
-I$(top_builddir)/nix \
-I$(top_srcdir)/%D%/libutil \
- $(libformat_a_CPPFLAGS)
+ $(libformat_a_CPPFLAGS) \
+ $(LIBGCRYPT_CPPFLAGS)
libstore_a_SOURCES = \
%D%/libstore/gc.cc \
@@ -109,7 +110,7 @@ libstore_a_CPPFLAGS = \
-DDEFAULT_CHROOT_DIRS="\"\""
libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
- $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
+ $(SQLITE3_CFLAGS)
bin_PROGRAMS = guix-daemon
@@ -122,6 +123,9 @@ guix_daemon_CPPFLAGS = \
$(libutil_a_CPPFLAGS) \
-I$(top_srcdir)/%D%/libstore
+guix_daemon_LDFLAGS = \
+ $(LIBGCRYPT_LDFLAGS)
+
guix_daemon_LDADD = \
libstore.a libutil.a libformat.a -lz \
$(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)

base-commit: 1c4a00820a1ba6265d2d96f4f7804d0807d69dcc
--
2.46.0
L
L
Ludovic Courtès wrote 2 days ago
(name . Do?an Çeçen)(address . sepeth@fastmail.com)(address . 74686-done@debbugs.gnu.org)
877c88ld1k.fsf@gnu.org
Hi,

Do?an Çeçen <sepeth@fastmail.com> skribis:

Toggle quote (17 lines)
> As it is mentioned in autoconf manual that library names should be
> specified in LIBS, not LDFLAGS. See:
>
> https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/html_node/Preset-Output-Variables.html#index-LDFLAGS-2
>
> This change also brings back the save_* vars trick that was there
> before. I missed in my earlier change that nix/local.mk was referring
> LIBGCRYPT_* vars directly.
>
> And, instead of CXXFLAGS, CPPFLAGS is used since the latter is probably
> more correct as this is used for include dirs, therefore using
> preprocessor flags.
>
> Tested with ./configure LDFLAGS="-Wl,--as-needed" --with-libgcrypt-prefix=... combinations.
>
> Change-Id: Iadb10e1994c9a78e2927847af2cfe5e096fbb2a8

Applied with a ChangeLog-style commit log, thanks.

(I was surprised by some of the changes in the first patch; thanks for
following up!)

Ludo’.
Closed
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74686@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74686
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch