autotools: avoid passing LDFLAGS twice for libcurl#12310
Closed
vszakats wants to merge 1 commit into
Closed
Conversation
LDFLAGS twice to libcurlLDFLAGS twice for libcurl
autotools passes `LDFLAGS` automatically linker commands. curl's `lib/Makefile.am` customizes libcurl linker flags. In that customization, it added `LDFLAGS` to the custom flags. This resulted in passing `LDFLAGS` _twice_ to the `libtool` command. Most of the time this is benign, but some `LDFLAGS` options can break the build when passed twice. One such example is passing `.o` files, e.g. `crt*.o` files necessary when customizing the C runtime, e.g. for MUSL builds. Passing them twice resulted in duplicate symbol errors: ``` libtool: link: clang-15 --target=aarch64-unknown-linux-musl [...] /usr/lib/aarch64-linux-musl/crt1.o [...] /usr/lib/aarch64-linux-musl/crt1.o [...] ld.lld-15: error: duplicate symbol: _start >>> defined at crt1.c >>> /usr/lib/aarch64-linux-musl/crt1.o:(.text+0x0) >>> defined at crt1.c >>> /usr/lib/aarch64-linux-musl/crt1.o:(.text+0x0) [...] clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` This behaviour came with commit 1a59319 (2013-07-23) as a fix for bug https://curl.haxx.se/bug/view.cgi?id=1217. The patch was a works-for-me hack that ended up merged in curl: https://sourceforge.net/p/curl/bugs/1217/#06ef With the root cause remaining unclear. Perhaps the SUNPro 12 linker was sensitive to `-L` `-l` order, requiring `-L` first? This would be unusual and suggests a bug in either the linker or in `libtool`. The curl build does pass the list of detected libs via its own `LIBCURL_LIBS` variable, which ends up before `LDFLAGS` on the `libtool` command line, but it's the job of `libtool` to ensure that even a peculiar linker gets the options in the expected order. Also because autotools passes `LDFLAGS` last, making it hardly possible to pass anything after it. Perhaps in the 10 years since this issue, this already got a fix upstream. This patch deletes `LDFLAGS` from our customized libcurl options, leaving a single copy of them as passed by autotools automatically. Reverts 1a59319 Closes curl#12310
03b881a to
095a7d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
autotools passes
LDFLAGSautomatically linker commands. curl'slib/Makefile.amcustomizes libcurl linker flags. In thatcustomization, it added
LDFLAGSto the custom flags. This resultedin passing
LDFLAGStwice to thelibtoolcommand.Most of the time this is benign, but some
LDFLAGSoptions can breakthe build when passed twice. One such example is passing
.ofiles,e.g.
crt*.ofiles necessary when customizing the C runtime, e.g. forMUSL builds.
Passing them twice resulted in duplicate symbol errors:
This behaviour came with commit 1a59319
(2013-07-23) as a fix for bug https://curl.haxx.se/bug/view.cgi?id=1217.
The patch was a works-for-me hack that ended up merged in curl:
https://sourceforge.net/p/curl/bugs/1217/#06ef
With the root cause remaining unclear.
Perhaps the SUNPro 12 linker was sensitive to
-L-lorder, requiring-Lfirst? This would be unusual and suggests a bug in either thelinker or in
libtool.The curl build does pass the list of detected libs via its own
LIBCURL_LIBSvariable, which ends up beforeLDFLAGSon thelibtoolcommand line, but it's the job of
libtoolto ensure that evena peculiar linker gets the options in the expected order. Also because
autotools passes
LDFLAGSlast, making it hardly possible to passanything after it.
Perhaps in the 10 years since this issue, this already got a fix
upstream.
This patch deletes
LDFLAGSfrom our customized libcurl options,leaving a single copy of them as passed by autotools automatically.
Reverts 1a59319
Closes #12310