-
Notifications
You must be signed in to change notification settings - Fork 1k
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
cmake: Add --no-undefined
linker option
#1559
base: master
Are you sure you want to change the base?
Conversation
Concept ACK. I think we might be after |
From my experience, it fails to catch an issue like one I demoed in #1556. |
If https://stackoverflow.com/a/2356407 is right, then |
Concept ACK |
Added a commit for the Autotools-based build system. |
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.
I think we need to make add an exception to this if external default callbacks are enabled because the entire point of this option is that the user provides the callbacks at link time.
Right. I did it in CMake, but forgot about it in Autotools. Fixed. |
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
string(APPEND " -Wl,-fatal_warnings") | ||
else() | ||
string(APPEND " -Wl,--fatal-warnings") |
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.
Shouldn't this depend on the linker and not on the OS?
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.
I don't think it can be implemented in a simple way; see https://gitlab.kitware.com/cmake/cmake/-/issues/18209.
However, we can just check each variant.
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.
Okay, I think checking CMAKE_SYSTEM_NAME
is good enough and pragmatic. GNU ld doesn't even support the creation of macOS binaries, and even clang's macOS linker ld64.lld
uses -fatal_warnings
...
But shouldn't we append -Wl,-fatal_warnings
or -Wl,--fatal-warnings
also for the autotools build?
This PR adds the
--no-undefined
option to a linker, which supports it.From the GNU ld docs:
Closes #1556.
Looking for Concept (N)ACKs. Once ACKed, I'll add the same functionality to the Autotools-based build system.