-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 link_args
stabilization
#29596
Comments
@alexcrichton (or anyone else), any ideas what the blockers are here? |
From the reference:
|
Some thoughts of mine:
|
Since we do not have a good solution for now, but as a system language, it is sometimes necessary to specify args like this (even only for specific platforms), put it behind a feature gate and only letting nightly branch to use it seems to be a compromise to make. |
Got hit by this issue when trying out https://gist.github.com/jansegre/043f5ab7f53e23890eed. As LuaJIT requires, I need to link the binary with flags Could this be done without using Rust nightly? Obviously
|
You can use the command line flag |
It seems strange to allow |
I'd rather we fix the issue with being unable to have spaces in the linker arguments before stabilizing either of them. Unfortunately |
So uh, is it intentional that this became accidentally stable? #![link_args = "-l bunny"]
fn main() {}
Also it warns that the attribute is unused despite having a very obvious effect. Also we still don't have a superior |
@retep998 I guess its a mistake, yes. There is a working feature gate, together with a gate test, but it seems to be only active on the foreign module declaration, so |
But there's no reason to even tie a |
@retep998 I guess its simply a mistake. The bug in the feature gate is probably that way since the initial implementation e338a41 (no idea what IMO we should do one of these two things:
|
cc @rust-lang/compiler, it appears that there was an unintended stabilization here; decision needed. |
Unless there's a sign of usage in the wild, I think the right answer here is to fix the broken feature gate and keep this unstable. |
triage: P-high We decided to try and fix this. @pnkfelix will either prep a PR or write-up some mentoring instructions. |
This would be very useful for embedded applications, which currently all have to create a custom What happens with |
ping <wg-embedded> (how to ping it?) @jamesmunns @japaric @therealprof I'd like to remove this attribute (preferably?) or bring it to some reasonable state. Given the already listed issues
and other issues
what are the current use cases for this feature? Is it possible to comfortably replace it with command line options from cargo configs or build scripts? |
Passing arbitrary linker flags from build.rs would also work, I believe. Not for all the nice feature I had in mind, but at least it would allow removing |
I have submitted an RFC about some more fine-grained control over linking - rust-lang/rfcs#2951. The "Future possibilities" section contains a paragraph about a potential order-preserving, propagating and single-argument alternative to |
Ping works. ;) I don't recall ever having seen |
If I could specify linker arguments from build scripts then I wouldn't care for this attribute at all, but I currently have neither so... |
? (There's also |
@petrochenkov |
In order to use the switchless feature of the SGX, the app binary needs to be linked with the following flags. ``` -Wl,--whole-archive -lsgx_uswitchless -Wl,--no-whole-archive ```` Noted that there is currently no proper way to pass custom link flags to all the binaries in a cargo project. As such, the `link_args` macro need to be set for each of Rust files with `main` methods. References: * Build flags used in Intel SGX sample code: https://github.com/intel/linux-sgx/blob/ce4a18d9a0963b14f717cc7462241cfadd233f55/SampleCode/Switchless/Makefile#L104 * Rust tracking issue on `link_args`: rust-lang/rust#29596 * PR for `cargo:rustc-link-arg-bins` in cargo build script: rust-lang/cargo#8441
|
Cargo now supports passing I've submitted a PR doing that - #83820. |
Remove attribute `#[link_args]` Closes rust-lang#29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
Remove attribute `#[link_args]` Closes rust-lang/rust#29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
The removal of this makes it hard to do certain things in the playground. I realize that's probably not a priority or reason to keep it, I'm just pointing it out. There's no |
I really wanted this as an attribute because It turns out that #[link(kind = "link-arg", name="-nostartfiles", modifiers="+verbatim")]
extern "C" {} Leaving this comment mostly for anyone else who comes across this issue trying to figure out how to do it. I did a few weeks ago and at the time just gave up on using |
This issue tracks stabilization for the
#[link_args]
attribute.The text was updated successfully, but these errors were encountered: