-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
msvc: handle flags that come from native-static-libs #511
msvc: handle flags that come from native-static-libs #511
Conversation
As of https://github.com/rust-lang/rust/pull/122268/files, rust emits /defaultlib:msvcrt in native-static-libs This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file: ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. If there is some better way to detect flags, I'm all for it. We could also have it have anything that starts with `-` but not start with `-l` be detected as a flag, but that seems a bit more likely to be disruptive. I checked commandlines and it does indeed get propaged properly to the commandline.
Could you also add an entry to the changelog in |
thanks! |
* msvc: handle flags that come from native-static-libs As of https://github.com/rust-lang/rust/pull/122268/files, rust emits /defaultlib:msvcrt in native-static-libs This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file: ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. (cherry picked from commit fce4fe5)
* msvc: handle flags that come from native-static-libs As of https://github.com/rust-lang/rust/pull/122268/files, rust emits /defaultlib:msvcrt in native-static-libs This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file: ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. (cherry picked from commit fce4fe5)
* msvc: handle flags that come from native-static-libs As of https://github.com/rust-lang/rust/pull/122268/files, rust emits /defaultlib:msvcrt in native-static-libs This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file: ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. (cherry picked from commit fce4fe5)
* msvc: handle flags that come from native-static-libs As of https://github.com/rust-lang/rust/pull/122268/files, rust emits /defaultlib:msvcrt in native-static-libs This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file: ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. (cherry picked from commit fce4fe5)
We need the bug fix corrosion-rs/corrosion#511.
endif() | ||
|
||
if(Rust_CROSSCOMPILING AND NOT DEFINED CACHE{Rust_CARGO_HOST_TARGET_LINK_NATIVE_LIBS}) | ||
message(STATUS "Determining required link libraries for target ${Rust_CARGO_HOST_TARGET_CACHED}") | ||
unset(host_libs) | ||
_corrosion_determine_libs_new("${Rust_CARGO_HOST_TARGET_CACHED}" host_libs) | ||
_corrosion_determine_libs_new("${Rust_CARGO_HOST_TARGET_CACHED}" host_libs host_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.
It seems that we should add the following message after line 797, similar to lines 777-779 above:
if(DEFINED host_flags)
message(STATUS "Required link flags for host target ${Rust_CARGO_HOST_TARGET_CACHED}: ${host_flags}" )
endif()
@@ -762,28 +770,35 @@ set(Rust_CARGO_HOST_ENV "${rust_host_env}" CACHE INTERNAL "Host environment") | |||
if(NOT DEFINED CACHE{Rust_CARGO_TARGET_LINK_NATIVE_LIBS}) | |||
message(STATUS "Determining required link libraries for target ${Rust_CARGO_TARGET_CACHED}") | |||
unset(required_native_libs) | |||
_corrosion_determine_libs_new("${Rust_CARGO_TARGET_CACHED}" required_native_libs) | |||
_corrosion_determine_libs_new("${Rust_CARGO_TARGET_CACHED}" required_native_libs required_link_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.
Should we add unset(required_link_flags)
before this line?
endif() | ||
|
||
if(Rust_CROSSCOMPILING AND NOT DEFINED CACHE{Rust_CARGO_HOST_TARGET_LINK_NATIVE_LIBS}) | ||
message(STATUS "Determining required link libraries for target ${Rust_CARGO_HOST_TARGET_CACHED}") | ||
unset(host_libs) | ||
_corrosion_determine_libs_new("${Rust_CARGO_HOST_TARGET_CACHED}" host_libs) | ||
_corrosion_determine_libs_new("${Rust_CARGO_HOST_TARGET_CACHED}" host_libs host_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.
Should we add unset(ost_flags)
before this line?
We need the bug fix corrosion-rs/corrosion#511.
As of rust-lang/rust#122268, rust emits /defaultlib:msvcrt in native-static-libs
This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file:
ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it
This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. If there is some better way to detect flags, I'm all for it. We could also have it have anything that starts with
-
but not start with-l
be detected as a flag, but that seems a bit more likely to be disruptive.I checked commandlines and it does indeed get propaged properly to the commandline.