-
Notifications
You must be signed in to change notification settings - Fork 7.8k
cmake: linker: Use the same linker for cmake checks and final build #77666
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ set(CMAKE_LINKER ${LLVMLLD_LINKER}) | |
|
||
set_ifndef(LINKERFLAGPREFIX -Wl) | ||
|
||
list(APPEND TOOLCHAIN_LD_FLAGS -fuse-ld=lld) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two thoughts here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
agree. unfortunately the existing toolchain_ld_base and toolchain_ld_baremetal macros has become a bit messy over time and thus diverted from their initial purpose. A first approach in cleaning up this without introducing functional changes is done here #77887.
👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thank you for the pointer (and for the patch itself too)! That makes sense to me--I'll fix this up accordingly soon now that that one has landed! |
||
list(APPEND CMAKE_REQUIRED_FLAGS -fuse-ld=lld) | ||
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
|
||
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_script_gen} | ||
# NOTE: ${linker_script_gen} will be produced at build-time; not at configure-time | ||
macro(configure_linker_script linker_script_gen linker_pass_define) | ||
|
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 moving this here is valid but I'm not entirely sure. IIUC, previously
-fuse-ld=bfd
would only be added whentoolchain_ld_link_elf
is called for a given target (and it's dependencies). By adding this toTOOLCHAIN_LD_FLAGS
instead (which will then be added viazephyr_ld_options
whentoolchain_ld_base
is invoked), I think we'll effectively add-fuse-ld=bfd
everywhere we link. Astoolchain_ld_link_elf
is (IIUC) invoked for each of the link stages (pre0/1, final) it seems like this change should be equivalent--are there use cases where we're both linking other things and truly don't want to use the same linker variant as the "main".elfs
?I don't see anything concerning in 39f06e0 where this was first added, but I'm not sure if I'm missing/misunderstanding something.
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 this is a fine location.