-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for linker arguments respecting their relative order with -l
library options
#99427
Comments
Implemented in #99467. |
…ochenkov flag '-l link-arg=___ was added rust-lang#99427
…ochenkov flag '-l link-arg=___ was added rust-lang#99427
…henkov flag '-l link-arg=___ was added rust-lang#99427
There's one possible improvement to
This would help to make #[link(kind = "link-arg", name = "--start-group")]
#[link(kind = "static", name = "c")]
#[link(kind = "static", name = "gcc")]
#[link(kind = "link-arg", name = "--end-group")] (*) to address cyclic dependencies between them This is an analogue of CMake's cc @krasimirgg |
I think |
@Be-ing |
What is needed to move this forward? I have run into another situation in which println!("cargo:rustc-link-lib=static:+verbatim=/home/be/qt6-installed/lib/objects-Release/Quick_resources_2/.rcc/qrc_scenegraph_shaders.cpp.o"); but that fails with |
…, r=petrochenkov Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," for cc-like linker args and not verbatim rust-lang#99427 (comment) > here's one possible improvement to -l link-arg making it more portable between linkers and useful - befriending it with the verbatim modifier (rust-lang#99425). > > -l link-arg:-verbatim=-foo would add -Wl,-foo (or equivalent) when C compiler is used as a linker, and just -foo when bare linker is used. > -l link-arg:+verbatim=-bar on the other hand would always pass just -bar.
Rollup merge of rust-lang#118202 - azhogin:azhogin/link_args_wrapping, r=petrochenkov Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," for cc-like linker args and not verbatim rust-lang#99427 (comment) > here's one possible improvement to -l link-arg making it more portable between linkers and useful - befriending it with the verbatim modifier (rust-lang#99425). > > -l link-arg:-verbatim=-foo would add -Wl,-foo (or equivalent) when C compiler is used as a linker, and just -foo when bare linker is used. > -l link-arg:+verbatim=-bar on the other hand would always pass just -bar.
Update: #118202 implemented the new behavior for This may be a breaking change for the current users of If some flag needs to be passed specifically to the C/C++ compiler, and not to the underlying linker, then the |
…trochenkov Enable `link-arg` link kind inside of `#[link]` attribute rust-lang#99427 (comment) > ... > This would help to make `link-arg` usable in `#[link]` attributes and e.g. wrap libc and libgcc into a group (*) in the libc crate like > > ``` > #[link(kind = "link-arg", name = "--start-group")] > #[link(kind = "static", name = "c")] > #[link(kind = "static", name = "gcc")] > #[link(kind = "link-arg", name = "--end-group")] > ``` > > (*) to address cyclic dependencies between them > > This is an analogue of CMake's LINKER: prefix (https://cmake.org/cmake/help/git-stage/command/target_link_options.html#handling-compiler-driver-differences), and was discussed as a possible future extension in the link modifier RFC (https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#support-linkarg--string-in-addition-to-the-modifiers).
…trochenkov Enable `link-arg` link kind inside of `#[link]` attribute rust-lang#99427 (comment) > ... > This would help to make `link-arg` usable in `#[link]` attributes and e.g. wrap libc and libgcc into a group (*) in the libc crate like > > ``` > #[link(kind = "link-arg", name = "--start-group")] > #[link(kind = "static", name = "c")] > #[link(kind = "static", name = "gcc")] > #[link(kind = "link-arg", name = "--end-group")] > ``` > > (*) to address cyclic dependencies between them > > This is an analogue of CMake's LINKER: prefix (https://cmake.org/cmake/help/git-stage/command/target_link_options.html#handling-compiler-driver-differences), and was discussed as a possible future extension in the link modifier RFC (https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#support-linkarg--string-in-addition-to-the-modifiers).
Is this intended to also be used to weakly link frameworks on Apple platforms? As in, the equivalent of #![feature(link_arg_attribute)]
#[link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim")]
#[link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")]
extern "C" {} Or must this be implemented separately as |
@madsmtm |
Cool, thanks, I've submitted a test for this in #118644. (I actually think it works exactly like |
Also tagging @grovesNL, you asked about this functionality a while ago on this internals thread. |
…=b-naber Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…=b-naber Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…-naber Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…ompiler-errors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…ompiler-errors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…ompiler-errors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang#99427.
…rrors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang/rust#99427.
…rrors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang/rust#99427.
…rrors Add test for Apple's `-weak_framework` linker argument The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets. So I made a test to ensure that it continues to work. Discussed in rust-lang/rust#99427.
This is a tracking issue for link arguments respecting their relative order with
-l
library options, which is a part of RFC "Linking modifiers for native libraries" (#81490, rust-lang/rfcs#2951), https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#relative-order-of--l-and--clink-args-options specifically.There's no feature gate for the issue.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Unresolved Questions
The feature is unlikely to be implementable in the form that is specified in the RFC, i.e. by preserving relative order of
-l
and-Clink-arg(s)
options.-C link-arg
was usable for overriding options previously passed by the compiler for long time, so is pretty much guaranteed to be passed at the end of command line at this point.The suggested solution (see #81490 and below) is to reuse the
-l
option for such arguments and introduce-l link-arg=arbitrary-link-argument
, which is exactly like-C link-arg=arbitrary-link-argument
, except that its relative order to other-l
options is respected.Implementation history
The text was updated successfully, but these errors were encountered: