-
Notifications
You must be signed in to change notification settings - Fork 39
Respect CMAKE_EXE_LINKER_FLAGS/CMAKE_SHARED_LINKER_FLAGS flags set via CLI #830
base: master
Are you sure you want to change the base?
Conversation
…a CLI In case of Clang, we were always overriding the above mentioned flags and hence cmake args were ignored (resuliting in link errors)
010d8c6
to
6f9c31e
Compare
@@ -113,8 +113,8 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST}) | |||
# Force same ld behavior as when called from gcc --as-needed forces the linker to check whether | |||
# a dynamic library mentioned in the command line is actually needed by the objects being | |||
# linked. Symbols needed in shared objects are already linked when building that library. | |||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") | |||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") | |||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}") |
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.
You can use https://cmake.org/cmake/help/latest/command/string.html#append to avoid repeating the variable name, I think, but no big deal.
-I$(CORENRN_INC_DIR) $(INCFLAGS) \ | ||
-L$(OUTPUT_DIR) -l$(COREMECH_LIB_NAME) $(CORENRNLIB_FLAGS) $(LDFLAGS) \ | ||
-L$(OUTPUT_DIR) -l$(COREMECH_LIB_NAME) $(CORENRNLIB_FLAGS) $(LDFLAGS) $(CXX_LINK_EXE_FLAGS) \ |
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.
As far as I can see the changes to this file just re-order some flags. Is that important?
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 now see the commit message about it needing to be later. Can you add a comment/documentation about that issue/detail?
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.
yeah, I should have put this PR in draft - haven't thoroughly checked how/why -Wl,--as-needed
causes this but I remember this flag was needed in case wheel building. I will check this bit later and get back here.
Description
In the case of Clang, we were always overriding the above-mentioned flags
and hence cmake args were ignored (resulting in link errors)
How to test this?
On BB5 with Clang compiler
Test System
BB5