-
Notifications
You must be signed in to change notification settings - Fork 36.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: make linker checks more robust #17874
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Gitian builds
|
Concept ACK |
Needs rebase |
8b048b6
to
7963904
Compare
Needs rebase |
7963904
to
feecd9f
Compare
feecd9f
to
d3ddae6
Compare
Going to restate my understanding just to make sure I'm clear on the logic here: The @fanquake does that sound right? |
Concept ACK. |
d3ddae6
to
d333883
Compare
@dongcarl Thanks for restating. I didn't like how I'd split the addition of the flag up, so I've pushed a new version of this change where they are together. What this currently does is adding (either variant of) The practical affect of this change is that linker flags which previously would have been tested, thrown a warning, and still been added to For example, if we were to add an obsoleted macOS linker flag, such as Master (b5c7665)AX_CHECK_LINK_FLAG([[-Wl,-nofixprebinding]]....
# configure checks and adds to $LDFLAGS
checking whether the linker accepts -Wl,-nofixprebinding... yes
# link time
ld: warning: option -nofixprebinding is obsolete and being ignored config.log: configure:18716: checking whether the linker accepts -Wl,-nofixprebinding
configure:18735: g++ -std=c++11 -o conftest -g -O2 -Wl,-nofixprebinding conftest.cpp >&5
ld: warning: option -nofixprebinding is obsolete and being ignored
configure:18735: $? = 0
configure:18745: result: yes This PR (d333883)# configure check fails
checking whether the linker accepts -Wl,-nofixprebinding... no config.log: configure:18752: checking whether the linker accepts -Wl,-nofixprebinding
configure:18771: g++ -std=c++11 -o conftest -g -O2 -Wl,-fatal_warnings -Wl,-nofixprebinding conftest.cpp >&5
ld: warning: option -nofixprebinding is obsolete and being ignored
ld: fatal warning(s) induced error (-fatal_warnings)
clang: error: linker command failed with exit code 1 (use -v to see invocation) NoteFor master, using an option that would otherwise cause an error, such as a linker flag that doesn't exist, is already a failure case. i.e: AX_CHECK_LINK_FLAG([[-Wl,-doesnt_exist]]...
checking whether the linker accepts -Wl,-doesnt_exist... no config.log:
Is this inline with your understanding? One other thought I had is, somewhat similar to how we have an option for |
AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings],[LDFLAG_WERROR="-Wl,-fatal_warnings"],[LDFLAG_WERROR=""]) | ||
;; | ||
*) | ||
AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings],[LDFLAG_WERROR="-Wl,--fatal-warnings"],[LDFLAG_WERROR=""]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very subtle difference, was about to respond 'these two cases are the same' then noticed -
versus --
option prefix 🤦♀️
From the
It seems when the The only case when a warning could be raised is passing a valid but obsolete options, right? I've tested this pr suggestion on macOS 10.15.3 with an obsolete option But I could not test on Linux Mint 19.3 because I did not find any mention of obsolete options in the
Passing |
cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug #17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
ACK d333883 So, the semantics of this are different than those of compilation warnings (e.g. So, with this PR, we are not going to use I tested this on FreeBSD 12 and confirm it works as expected - it is being used when checking whether other linker flags are supported. No linker flags are being excluded due to it - before and after the PR This PR omitted the following, I guess on purpose? if test x$enable_determinism = xyes; then
if test x$TARGET_OS = xwindows; then
AX_CHECK_LINK_FLAG([[-Wl,--no-insert-timestamp]], [LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"])
fi
fi |
Check for a flag to turn linker warnings into errors. When flags are passed to linkers via the compiler driver using a -Wl,-foo flag, linker warnings may be swallowed rather than bubbling up. Co-authored-by: fanquake <[email protected]>
d333883
to
03da4c7
Compare
Thanks for the review.
Nope. I've added that to configure.ac in the interim, and hadn't updated this PR. Good catch. Have pushed the fix. |
re-ACK 03da4c7 My thought was "this is something Windows-specific, I do not want to know about it"... |
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
…ptions cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake) Pull request description: There's also now more than a single option being special cased for darwin. If we didn't special case these options they would still end up on the link line and the binaries produced would just segfault. I'm going to plug bitcoin#17874 here as well, because adding `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would mostly prevent this sort of option mangling from happening. An example of the warning behaviour: ```bash echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip - /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040 nm -C a.out 0000000000001000 t _init 0000000000001040 T _start U ad_strip ``` ACKs for top commit: dongcarl: ACK cd24f37 Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
Check for a flag to turn linker warnings into errors. When flags are passed to
linkers via the compiler driver using a -Wl,-foo flag, linker warnings may be
swallowed rather than bubbling up.
This is one of Corys commits that I've modified to also add
-Wl,-fatal_warnings
for darwin.