From 45cc44bcf945a8ec707b846a957e2c8ad07173be Mon Sep 17 00:00:00 2001 From: fanquake Date: Sun, 14 May 2023 11:08:37 +0100 Subject: [PATCH] Merge bitcoin/bitcoin#27628: build: Fix shared lib linking for darwin with lld 67aacc73ea427f89f005ae17d5fd1572409e649e build: cleanup comments after adding yet another libtool hack (Cory Fields) 283d95516a11166631818dd448ed53a2374b5db8 build: Fix shared lib linking for darwin with lld (Cory Fields) Pull request description: Solves one of the last remaining blockers for #21778. Fixes lld linking shared libs for macos via libtool. lld fails one of libtool's earliest checks [because it happens to output a warning that contains a specific string](https://git.savannah.gnu.org/cgit/libtool.git/tree/m4/libtool.m4#n999): > # If there is a non-empty error log, and "single_module" > # appears in it, assume the flag caused a linker warning And here is the test being run: > x86_64-apple-darwin-ld: warning: Option `-single_module' is deprecated in ld64: > x86_64-apple-darwin-ld: warning: Unnecessary option: this is already the default Because the warning is printed the test fails. So libtool falls back to a very primitive and broken link-line for shared libs. Arguably this should be worked-around in upstream lld by changing the warning string, as otherwise every libtool project will fail to link with it. Like many other libtool hacks, the solution is to simply disable the check and hard-code the answer we know to be correct. ACKs for top commit: hebasto: re-ACK 67aacc73ea427f89f005ae17d5fd1572409e649e Tree-SHA512: 792e4d208a3a4921edb5f267f43ecd052b5b650df0db5cb2788ee1e4f3c4087413f354b22e407ff5fa2f99a22a16154ec6826d14c6654a57c00aae3b3e744bca --- configure.ac | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 929d264229..bf8e000fde 100644 --- a/configure.ac +++ b/configure.ac @@ -57,13 +57,24 @@ else fi AC_PROG_CXX -dnl By default, libtool for mingw refuses to link static libs into a dll for -dnl fear of mixing pic/non-pic objects, and import/export complications. Since -dnl we have those under control, re-enable that functionality. +dnl libtool overrides case $host in *mingw*) + dnl By default, libtool for mingw refuses to link static libs into a dll for + dnl fear of mixing pic/non-pic objects, and import/export complications. Since + dnl we have those under control, re-enable that functionality. lt_cv_deplibs_check_method="pass_all" ;; + *darwin*) + dnl Because it prints a verbose warning, lld fails the following check + dnl for "-Wl,-single_module" from libtool.m4: + dnl # If there is a non-empty error log, and "single_module" + dnl # appears in it, assume the flag caused a linker warning + dnl "-single_module" works fine on ld64 and lld, so just bypass the test. + dnl Failure to set this to "yes" causes libtool to use a very broken + dnl link-line for shared libs. + lt_cv_apple_cc_single_mod="yes" + ;; esac AC_ARG_ENABLE([c++20],