-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Finish implementation of -Zextra-link-arg
.
#8441
Conversation
r? @ehuss (rust_highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #8427) made this pull request unmergeable. Please resolve the merge conflicts. |
Are arguments passed with |
Thanks for picking this back up @reitermarkus! I just wanted to let you know that this is in my queue, and I'll try to get to it soon. I think there was still an open issue of how the syntax can be extended for setting args for different targets, and I'd like to discuss that with the team some more. |
Sorry about the delay. The main stickler on this was just making sure that the syntax for specifying which targets get the flags for different scenarios. I'd like to make a proposal to use something like the following structure:
I'm not proposing that this PR needs to implement all of these, but that there is a long-term plan for how new targets can be added. This specifically has an impact on the bare For now I wouldn't bother renaming Does that seem like a reasonable path forward? |
If that is implemented as a |
@ehuss, I renamed |
Hi! I was just experimenting with this branch for pyo3, where we need to situationally link Currently this is solved by enabling a feature which switches off I was hoping that we might be able to use this feature to achieve finer-grain control over this issue. However, it looks like build script directives emitted in Would it be within the scope of this feature to pass link args to dependencies? Or, can it be extended to do so? |
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
@davidhewitt It looks like dependencies that use Sorry again for the delay on this. I think this seems reasonable to move forward with. @rust-lang/cargo This is an unstable feature which allows build scripts to specify link args for additional targets. cdylib is already supported on stable, but this adds unstable support for bins, and "all targets". If people need finer-grained target selection, the syntax suggested in #8441 (comment) could be used as needed. I'm going to FCP this, even though it is unstable, since we've been discussing it off and on. @rfcbot merge |
Team member @ehuss has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
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.
Looks reasonable to me, but I wanted to clarify something before signing off. Does "binary" here include binaries for --test
? (or examples, benchmarks, etc) Or is it only the executables in src/bin/*.rs
effectively?
Additionally does rustc-link-arg
apply to all of the above, or only [[bin]]
and cdylib? Does rustc-link-arg
apply to dylib crate types too?
@rfcbot concern rustc-link-arg should match all linkable targets @reitermarkus do you think you could look at that? |
Ok yeah that sounds good to me and is what I would expect, could the documentation be updated here as well? |
📌 Commit 51f7a44 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 10 commits in 2af662e22177a839763ac8fb70d245a680b15214..bfca1cd22bf514d5f2b6c1089b0ded0ba7dfaa6e 2020-11-12 19:04:56 +0000 to 2020-11-24 16:33:21 +0000 - Shrink the progress bar, to give more space after it. (rust-lang/cargo#8892) - Add some comments to the toml code (rust-lang/cargo#8887) - Start searching git config at new path (rust-lang/cargo#8886) - Fix documentation for CARGO_PRIMARY_PACKAGE. (rust-lang/cargo#8891) - Bump to 0.51.0, update changelog (rust-lang/cargo#8894) - Publish target's "doc" setting when emitting metadata (rust-lang/cargo#8869) - Relaxes expectation of `cargo test` tests to accept test execution time (rust-lang/cargo#8884) - Finish implementation of `-Zextra-link-arg`. (rust-lang/cargo#8441) - Reproducible crate builds (rust-lang/cargo#8864) - Allow resolver="1" to explicitly use the old resolver behavior. (rust-lang/cargo#8857)
Is there a tracking issue for stabilizing this? |
Change `rustc-cdylib-link-arg` error to a warning. In #9523, an error was added if `cargo:rustc-cdylib-link-arg` was issued in a build script without actually having a cdylib target. This uncovered that there was an unintentional change in #8441 to cause those link args to be applied to transitive dependencies. This changes it so that the error is now a warning, with a note that this may become an error in the future. It also changes it so that the unstable `rustc-link-arg*` instructions only apply to the package that emitted them.
Change `rustc-cdylib-link-arg` error to a warning. In rust-lang#9523, an error was added if `cargo:rustc-cdylib-link-arg` was issued in a build script without actually having a cdylib target. This uncovered that there was an unintentional change in rust-lang#8441 to cause those link args to be applied to transitive dependencies. This changes it so that the error is now a warning, with a note that this may become an error in the future. It also changes it so that the unstable `rustc-link-arg*` instructions only apply to the package that emitted them.
Stabilize the rustc-link-arg option This change removes the unstable option (tracked by #9426) and unconditionally accepts additional linker arguments (as implemented in #7811 and #8441). Documentation is moved from unstable to what appeared to be the correct location. I am not aware of any significant concerns with the option and it appears consistent with some other existing stable linker options. Please let me know if this is not the appropriate process or if there is anything that I am missing from the PR.
Enable triagebot's relabel functionality ### What does this PR try to resolve? This fixes the following failure that rustbot currently posts whenever someone tries to use "<b>`@</b><b>rustbot</b>` label" in this repository. > **Error**: The feature `relabel` is not enabled in this repository. > To enable it add its section in the `triagebot.toml` in the root of the repository. Unauthenticated relabel has been enabled in rust-lang/rust for nearly 4 years. People overwhelmingly use it in good faith. <br> ### How should we test and review this PR? Compare against https://github.com/rust-lang/rust/blob/1.66.0/triagebot.toml. Also skim through the 7 pages of labels on https://github.com/rust-lang/cargo/labels, whether it makes sense the ones I decided to allow arbitrary GitHub users to apply. <br> ### Additional information Attempted uses of "<b>`@</b><b>rustbot</b>` label", that failed, but this PR would allow: - #10343 (comment) - #10243 (comment) - #9982 (comment) - #9128 (comment) - #9067 (comment) - #8441 (comment) - #11432 (comment) - #8841 (comment) - #10820 (comment) - #10572 (comment) - #9114 (comment) - #8980 (comment) - #9064 (comment) - #8726 (comment) - #8089 (comment)
This is a continuation of #7811, which adds tests and a warning if the
-Zextra-link-arg
flag is not specified. Also moved the documentation intounstable.md
.