-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Fix LDC compilation with LDC 1.37 universal on macOS. Make ExtractDMDSystemLinker.cmake compatible with -target
and -arch
#4431
Conversation
@@ -64,6 +64,9 @@ separate_arguments(linker_line) | |||
list(GET linker_line 0 D_LINKER_COMMAND) | |||
list(REMOVE_AT linker_line 0) | |||
|
|||
# Fixup "-target triple" argument, which would be turned into "-target;triple" by `separate_arguments`. Replace ";" with "=". | |||
string(REGEX REPLACE ";-target;" ";--target=" linker_line "${linker_line}") |
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.
linker_line
and D_LINKER_ARGS
later are CMake lists, so semicolons separating individual args should be fine. IIRC, Apple clang is picky and requires -target <bla>
, not accepting --target=bla
- might have been an older version though.
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.
The problem is that the D_LINKER_ARGS is passed to CMake, which does something smart: if the argument does not start with -
, it assumes it is a library and will add -l
in front of it. Thus -target some-triple
is converted to -target -lsome-triple
.
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.
OMG - yeah I hit that too sometime. That's because we use target_link_libraries()
for these (with LDC_LINK_MANUALLY=ON
). There's https://cmake.org/cmake/help/latest/command/target_link_options.html since CMake v3.13, which would presumably fix this and similar ugliness.
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.
thnx for the target_link_options suggestion.
I've been conservative in applying it (not changing it for other linker args that we pass), because some of the linker "flags" in our script are actually linker dependencies (i.e. libraries) such as LDC_LIB==LDCShared.
I just hit this when trying to build LDC locally with LDC 1.36.0 universal, because our ldc2.conf contains:
|
b15c2c8
to
9854d09
Compare
Updated the PR to use target_link_options. This increases the CMake requirement from 3.4 to 3.13. Note that LLVM requires v3.20. |
This reverts commit 9854d09.
reverted to the old solution if CI likes that better; perhaps somehow the flags are not passed correctly for some of the CI cases with more complex flag setups |
This patch without using |
The difference between
There is also this note in CMake documentation about |
I think I have it working well now. Will clean up after CI confirms. |
This reverts commit 04c7239.
-target
-target
and -arch
Thx, just in time for v1.37. :) |
…SystemLinker.cmake compatible with `-target` and `-arch` (ldc-developers#4431) The attempt to use CMake's `target_link_options` for `D_LINKER_ARGS` failed, because the list can be a mix of library dependencies and options. LDC upstream: 0b62d9d
I need this fix when the system D compiler has
-target
in its default linker line