Skip to content

Remove attribute #[link_args] #83820

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 5, 2021
Merged

Conversation

petrochenkov
Copy link
Contributor

Closes #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.

@rust-highfive
Copy link
Contributor

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rust-highfive
Copy link
Contributor

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 3, 2021
@petrochenkov petrochenkov added I-nominated S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2021
@nagisa
Copy link
Member

nagisa commented Apr 4, 2021

SGTM. This seems somewhat similar in direction as the also very well motivated removal of the #[crate_type] and #[crate_name] attributes.

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 4, 2021

📌 Commit 5839bff has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Apr 4, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 4, 2021
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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#80525 (wasm64 support)
 - rust-lang#83019 (core: disable `ptr::swap_nonoverlapping_one`'s block optimization on SPIR-V.)
 - rust-lang#83717 (rustdoc: Separate filter-empty-string out into its own function)
 - rust-lang#83807 (Tests: Remove redundant `ignore-tidy-linelength` annotations)
 - rust-lang#83815 (ptr::addr_of documentation improvements)
 - rust-lang#83820 (Remove attribute `#[link_args]`)
 - rust-lang#83841 (Allow clobbering unsupported registers in asm!)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3c2e4ff into rust-lang:master Apr 5, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 5, 2021
@petrochenkov
Copy link
Contributor Author

This was fast.
I nominated this for the compiler team to make the change visible to some wider audience.
Anyway, if there are some critical concerns, then it can be reverted (which I don't expect though).

flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 8, 2021
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.
@Dirbaio
Copy link
Contributor

Dirbaio commented May 11, 2021

With this removal it's now impossible to pass different link_args to different binaries within the same crate. cargo:rustc-link-arg=FLAG applies to all binaries, while this allowed specifying different args in each main.rs binary.

Is there some workaround for this?

@petrochenkov
Copy link
Contributor Author

@Dirbaio
It's better to ask about this on cargo repo, it's unlikely that any relevant person will see this comment here.
Tracking issue for cargo:rust-link-arg* is rust-lang/cargo#9426.

bors added a commit to rust-lang/cargo that referenced this pull request May 24, 2021
Add `cargo:rustc-link-arg-bin` flag.

This PR implements a `cargo:rustc-link-arg-bin` command to specify per-binary link args from build scripts. This follows the suggestion from the tracking issue #9426.

Syntax is `cargo:rustc-link-arg-bin=BIN_NAME=ARG`

This was previously possible to do using the `#[link_args=".."]` attribute, but it was removed in rust-lang/rust#83820 in favor of the Cargo extra-link-args feature, which can currently not specify different link args for different bins in the same crate. This PR adds back the ability to do that.
@petrochenkov petrochenkov deleted the nolinkargs branch February 22, 2025 18:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for link_args stabilization
7 participants