about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-04-05 00:24:33 +0200
committerGitHub <noreply@github.com>2021-04-05 00:24:33 +0200
commit3c2e4ff525a710987c4e01805edf051740cb022b (patch)
tree5d5d3047093a747e9f411de20de4227ec8c0cf78 /src
parentfbe89e20e83bd726b34ee0462ac96f2515f5945d (diff)
parent5839bff0bac6063147c8905388713a787577208f (diff)
downloadrust-3c2e4ff525a710987c4e01805edf051740cb022b.tar.gz
rust-3c2e4ff525a710987c4e01805edf051740cb022b.zip
Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Remove attribute `#[link_args]`

Closes https://github.com/rust-lang/rust/issues/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.
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/language-features/link-args.md32
-rw-r--r--src/test/incremental/hashes/extern_mods.rs16
-rw-r--r--src/test/run-make-fulldeps/link-args-order/Makefile2
-rw-r--r--src/test/run-make-fulldeps/link-args-order/empty.rs5
-rw-r--r--src/test/ui/feature-gates/feature-gate-link_args.rs17
-rw-r--r--src/test/ui/feature-gates/feature-gate-link_args.stderr30
-rw-r--r--src/test/ui/issues/issue-15487.rs13
-rw-r--r--src/test/ui/linkage-attr/invalid-link-args.rs14
-rw-r--r--src/tools/clippy/tests/ui/crate_level_checks/no_std_main_recursion.rs4
-rw-r--r--src/tools/clippy/tests/ui/empty_loop_no_std.rs4
10 files changed, 5 insertions, 132 deletions
diff --git a/src/doc/unstable-book/src/language-features/link-args.md b/src/doc/unstable-book/src/language-features/link-args.md
deleted file mode 100644
index da36e158001..00000000000
--- a/src/doc/unstable-book/src/language-features/link-args.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# `link_args`
-
-The tracking issue for this feature is: [#29596]
-
-[#29596]: https://github.com/rust-lang/rust/issues/29596
-
-------------------------
-
-You can tell `rustc` how to customize linking, and that is via the `link_args`
-attribute. This attribute is applied to `extern` blocks and specifies raw flags
-which need to get passed to the linker when producing an artifact. An example
-usage would be:
-
-```rust,no_run
-#![feature(link_args)]
-
-#[link_args = "-foo -bar -baz"]
-extern "C" {}
-# fn main() {}
-```
-
-Note that this feature is currently hidden behind the `feature(link_args)` gate
-because this is not a sanctioned way of performing linking. Right now `rustc`
-shells out to the system linker (`gcc` on most systems, `link.exe` on MSVC), so
-it makes sense to provide extra command line arguments, but this will not
-always be the case. In the future `rustc` may use LLVM directly to link native
-libraries, in which case `link_args` will have no meaning. You can achieve the
-same effect as the `link_args` attribute with the `-C link-args` argument to
-`rustc`.
-
-It is highly recommended to *not* use this attribute, and rather use the more
-formal `#[link(...)]` attribute on `extern` blocks instead.
diff --git a/src/test/incremental/hashes/extern_mods.rs b/src/test/incremental/hashes/extern_mods.rs
index 7a923134331..93e70d3792c 100644
--- a/src/test/incremental/hashes/extern_mods.rs
+++ b/src/test/incremental/hashes/extern_mods.rs
@@ -12,7 +12,6 @@
 #![allow(warnings)]
 #![feature(rustc_attrs)]
 #![feature(unboxed_closures)]
-#![feature(link_args)]
 #![crate_type = "rlib"]
 
 // Change function name --------------------------------------------------------
@@ -146,21 +145,6 @@ extern "C" {
     pub fn add_function2();
 }
 
-// Change link-args ------------------------------------------------------------
-#[cfg(cfail1)]
-#[link_args = "-foo -bar"]
-extern "C" {
-    pub fn change_link_args(c: i32);
-}
-
-#[cfg(not(cfail1))]
-#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
-#[rustc_clean(cfg = "cfail3")]
-#[link_args = "-foo -bar -baz"]
-extern "C" {
-    pub fn change_link_args(c: i32);
-}
-
 // Change link-name ------------------------------------------------------------
 #[cfg(cfail1)]
 #[link(name = "foo")]
diff --git a/src/test/run-make-fulldeps/link-args-order/Makefile b/src/test/run-make-fulldeps/link-args-order/Makefile
index 98c1e0eac3b..f94e882ccb6 100644
--- a/src/test/run-make-fulldeps/link-args-order/Makefile
+++ b/src/test/run-make-fulldeps/link-args-order/Makefile
@@ -6,5 +6,5 @@ RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args=
 RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
 
 all:
-	$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f" "g"'
+	$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
 	$(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
diff --git a/src/test/run-make-fulldeps/link-args-order/empty.rs b/src/test/run-make-fulldeps/link-args-order/empty.rs
index 2439171004b..f328e4d9d04 100644
--- a/src/test/run-make-fulldeps/link-args-order/empty.rs
+++ b/src/test/run-make-fulldeps/link-args-order/empty.rs
@@ -1,6 +1 @@
-#![feature(link_args)]
-
-#[link_args = "g"]
-extern "C" {}
-
 fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-link_args.rs b/src/test/ui/feature-gates/feature-gate-link_args.rs
deleted file mode 100644
index e1c651f46fb..00000000000
--- a/src/test/ui/feature-gates/feature-gate-link_args.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Test that `#[link_args]` attribute is gated by `link_args`
-// feature gate, both when it occurs where expected (atop
-// `extern { }` blocks) and where unexpected.
-
-// sidestep warning (which is correct, but misleading for
-// purposes of this test)
-#![allow(unused_attributes)]
-#![link_args = "-l unexpected_use_as_inner_attr_on_mod"]
-//~^ ERROR the `link_args` attribute is experimental
-
-#[link_args = "-l expected_use_case"]
-//~^ ERROR the `link_args` attribute is experimental
-extern "C" {}
-
-#[link_args = "-l unexected_use_on_non_extern_item"]
-//~^ ERROR: the `link_args` attribute is experimental
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-link_args.stderr b/src/test/ui/feature-gates/feature-gate-link_args.stderr
deleted file mode 100644
index ae4918f5c9f..00000000000
--- a/src/test/ui/feature-gates/feature-gate-link_args.stderr
+++ /dev/null
@@ -1,30 +0,0 @@
-error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead
-  --> $DIR/feature-gate-link_args.rs:11:1
-   |
-LL | #[link_args = "-l expected_use_case"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #29596 <https://github.com/rust-lang/rust/issues/29596> for more information
-   = help: add `#![feature(link_args)]` to the crate attributes to enable
-
-error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead
-  --> $DIR/feature-gate-link_args.rs:15:1
-   |
-LL | #[link_args = "-l unexected_use_on_non_extern_item"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #29596 <https://github.com/rust-lang/rust/issues/29596> for more information
-   = help: add `#![feature(link_args)]` to the crate attributes to enable
-
-error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead
-  --> $DIR/feature-gate-link_args.rs:8:1
-   |
-LL | #![link_args = "-l unexpected_use_as_inner_attr_on_mod"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #29596 <https://github.com/rust-lang/rust/issues/29596> for more information
-   = help: add `#![feature(link_args)]` to the crate attributes to enable
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/issues/issue-15487.rs b/src/test/ui/issues/issue-15487.rs
deleted file mode 100644
index 34ac53be5be..00000000000
--- a/src/test/ui/issues/issue-15487.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// run-pass
-#![allow(unused_attributes)]
-// ignore-windows
-// ignore-wasm32-bare no libs to link
-// ignore-sgx no libs to link
-#![feature(link_args)]
-
-#[link_args = "-lc  -lm"]
-#[link_args = " -lc"]
-#[link_args = "-lc "]
-extern "C" {}
-
-fn main() {}
diff --git a/src/test/ui/linkage-attr/invalid-link-args.rs b/src/test/ui/linkage-attr/invalid-link-args.rs
deleted file mode 100644
index 7418691d014..00000000000
--- a/src/test/ui/linkage-attr/invalid-link-args.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// build-fail
-// dont-check-compiler-stderr
-// ignore-msvc due to linker-flavor=ld
-// error-pattern:aFdEfSeVEEE
-// compile-flags: -C linker-flavor=ld
-
-/* Make sure invalid link_args are printed to stderr. */
-
-#![feature(link_args)]
-
-#[link_args = "aFdEfSeVEEE"]
-extern "C" {}
-
-fn main() {}
diff --git a/src/tools/clippy/tests/ui/crate_level_checks/no_std_main_recursion.rs b/src/tools/clippy/tests/ui/crate_level_checks/no_std_main_recursion.rs
index 25b1417be97..be4348e2bb7 100644
--- a/src/tools/clippy/tests/ui/crate_level_checks/no_std_main_recursion.rs
+++ b/src/tools/clippy/tests/ui/crate_level_checks/no_std_main_recursion.rs
@@ -1,8 +1,8 @@
+// compile-flags: -Clink-arg=-nostartfiles
 // ignore-macos
 // ignore-windows
 
-#![feature(lang_items, link_args, start, libc)]
-#![link_args = "-nostartfiles"]
+#![feature(lang_items, start, libc)]
 #![no_std]
 
 use core::panic::PanicInfo;
diff --git a/src/tools/clippy/tests/ui/empty_loop_no_std.rs b/src/tools/clippy/tests/ui/empty_loop_no_std.rs
index 4553d3ec505..235e0fc5179 100644
--- a/src/tools/clippy/tests/ui/empty_loop_no_std.rs
+++ b/src/tools/clippy/tests/ui/empty_loop_no_std.rs
@@ -1,9 +1,9 @@
+// compile-flags: -Clink-arg=-nostartfiles
 // ignore-macos
 // ignore-windows
 
 #![warn(clippy::empty_loop)]
-#![feature(lang_items, link_args, start, libc)]
-#![link_args = "-nostartfiles"]
+#![feature(lang_items, start, libc)]
 #![no_std]
 
 use core::panic::PanicInfo;