Skip to content

Commit bcdd8bd

Browse files
authored
Rollup merge of rust-lang#95818 - petrochenkov:stabundle, r=wesleywiser
Stabilize the `bundle` native library modifier And remove the legacy `static-nobundle` linking kind. Stabilization report - rust-lang#95818 (comment). cc rust-lang#81490 Closes rust-lang#37403
2 parents 16a0d03 + 0462cc3 commit bcdd8bd

35 files changed

+88
-196
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
19521952
add_local_native_libraries(cmd, sess, codegen_results);
19531953
}
19541954

1955-
// Upstream rust libraries and their nobundle static libraries
1955+
// Upstream rust libraries and their non-bundled static libraries
19561956
add_upstream_rust_crates::<B>(cmd, sess, codegen_results, crate_type, tmpdir);
19571957

19581958
// Upstream dynamic native libraries linked with `#[link]` attributes at and `-l`
@@ -2237,7 +2237,7 @@ fn add_local_native_libraries(
22372237
}
22382238
}
22392239

2240-
/// # Linking Rust crates and their nobundle static libraries
2240+
/// # Linking Rust crates and their non-bundled static libraries
22412241
///
22422242
/// Rust crates are not considered at all when creating an rlib output. All dependencies will be
22432243
/// linked when producing the final output (instead of the intermediate rlib version).

compiler/rustc_error_codes/src/error_codes/E0060.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Using this declaration, it must be called with at least one argument, so
1616
simply calling `printf()` is invalid. But the following uses are allowed:
1717

1818
```
19-
# #![feature(static_nobundle)]
2019
# use std::os::raw::{c_char, c_int};
2120
# #[cfg_attr(all(windows, target_env = "msvc"),
22-
# link(name = "legacy_stdio_definitions", kind = "static-nobundle"))]
21+
# link(name = "legacy_stdio_definitions",
22+
# kind = "static", modifiers = "-bundle"))]
2323
# extern "C" { fn printf(_: *const c_char, ...) -> c_int; }
2424
# fn main() {
2525
unsafe {

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ declare_features! (
219219
(accepted, move_ref_pattern, "1.49.0", Some(68354), None),
220220
/// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]`
221221
(accepted, native_link_modifiers, "1.61.0", Some(81490), None),
222+
/// Allows specifying the bundle link modifier
223+
(accepted, native_link_modifiers_bundle, "1.63.0", Some(81490), None),
222224
/// Allows specifying the whole-archive link modifier
223225
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490), None),
224226
/// Allows using `#![no_std]`.

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ declare_features! (
449449
(active, naked_functions, "1.9.0", Some(32408), None),
450450
/// Allows specifying the as-needed link modifier
451451
(active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None),
452-
/// Allows specifying the bundle link modifier
453-
(active, native_link_modifiers_bundle, "1.53.0", Some(81490), None),
454452
/// Allows specifying the verbatim link modifier
455453
(active, native_link_modifiers_verbatim, "1.53.0", Some(81490), None),
456454
/// Allow negative trait implementations.
@@ -500,8 +498,6 @@ declare_features! (
500498
(active, simd_ffi, "1.0.0", Some(27731), None),
501499
/// Allows specialization of implementations (RFC 1210).
502500
(incomplete, specialization, "1.7.0", Some(31844), None),
503-
/// Allows `#[link(kind="static-nobundle"...)]`.
504-
(active, static_nobundle, "1.16.0", Some(37403), None),
505501
/// Allows attributes on expressions and non-item statements.
506502
(active, stmt_expr_attributes, "1.6.0", Some(15701), None),
507503
/// Allows lints part of the strict provenance effort.

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ declare_features! (
169169
(removed, sanitizer_runtime, "1.17.0", None, None, None),
170170
(removed, simd, "1.0.0", Some(27731), None,
171171
Some("removed in favor of `#[repr(simd)]`")),
172+
/// Allows `#[link(kind = "static-nobundle", ...)]`.
173+
(removed, static_nobundle, "1.16.0", Some(37403), None,
174+
Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#)),
172175
(removed, struct_inherit, "1.0.0", None, None, None),
173176
(removed, test_removed_feature, "1.0.0", None, None, None),
174177
/// Allows using items which are missing stability attributes

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,6 @@ impl<'tcx> Collector<'tcx> {
9797
let span = item.name_value_literal_span().unwrap();
9898
let link_kind = match link_kind.as_str() {
9999
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
100-
"static-nobundle" => {
101-
sess.struct_span_warn(
102-
span,
103-
"link kind `static-nobundle` has been superseded by specifying \
104-
modifier `-bundle` with link kind `static`",
105-
)
106-
.emit();
107-
if !features.static_nobundle {
108-
feature_err(
109-
&sess.parse_sess,
110-
sym::static_nobundle,
111-
span,
112-
"link kind `static-nobundle` is unstable",
113-
)
114-
.emit();
115-
}
116-
NativeLibKind::Static { bundle: Some(false), whole_archive: None }
117-
}
118100
"dylib" => NativeLibKind::Dylib { as_needed: None },
119101
"framework" => {
120102
if !sess.target.is_like_osx {
@@ -264,7 +246,6 @@ impl<'tcx> Collector<'tcx> {
264246
};
265247
match (modifier, &mut kind) {
266248
("bundle", Some(NativeLibKind::Static { bundle, .. })) => {
267-
report_unstable_modifier!(native_link_modifiers_bundle);
268249
assign_modifier(bundle)
269250
}
270251
("bundle", _) => {

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,21 +1938,6 @@ fn parse_native_lib_kind(
19381938

19391939
let kind = match kind {
19401940
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
1941-
"static-nobundle" => {
1942-
early_warn(
1943-
error_format,
1944-
"library kind `static-nobundle` has been superseded by specifying \
1945-
modifier `-bundle` with library kind `static`. Try `static:-bundle`",
1946-
);
1947-
if !nightly_options::match_is_nightly_build(matches) {
1948-
early_error(
1949-
error_format,
1950-
"library kind `static-nobundle` is unstable \
1951-
and only accepted on the nightly compiler",
1952-
);
1953-
}
1954-
NativeLibKind::Static { bundle: Some(false), whole_archive: None }
1955-
}
19561941
"dylib" => NativeLibKind::Dylib { as_needed: None },
19571942
"framework" => NativeLibKind::Framework { as_needed: None },
19581943
_ => early_error(
@@ -2005,10 +1990,7 @@ fn parse_native_lib_modifiers(
20051990
}
20061991
};
20071992
match (modifier, &mut kind) {
2008-
("bundle", NativeLibKind::Static { bundle, .. }) => {
2009-
report_unstable_modifier();
2010-
assign_modifier(bundle)
2011-
}
1993+
("bundle", NativeLibKind::Static { bundle, .. }) => assign_modifier(bundle),
20121994
("bundle", _) => early_error(
20131995
error_format,
20141996
"linking modifier `bundle` is only compatible with `static` linking kind",

library/unwind/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![no_std]
22
#![unstable(feature = "panic_unwind", issue = "32837")]
33
#![feature(link_cfg)]
4-
#![feature(native_link_modifiers_bundle)]
4+
#![cfg_attr(bootstrap, feature(native_link_modifiers_bundle))]
55
#![feature(nll)]
66
#![feature(staged_api)]
77
#![feature(c_unwind)]

src/doc/rustc/src/command-line-arguments.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@ The default for this modifier is `-whole-archive`. \
8484
NOTE: The default may currently be different in some cases for backward compatibility,
8585
but it is not guaranteed. If you need whole archive semantics use `+whole-archive` explicitly.
8686

87+
### Linking modifiers: `bundle`
88+
89+
This modifier is only compatible with the `static` linking kind.
90+
Using any other kind will result in a compiler error.
91+
92+
When building a rlib or staticlib `+bundle` means that all object files from the native static
93+
library will be added to the rlib or staticlib archive, and then used from it during linking of
94+
the final binary.
95+
96+
When building a rlib `-bundle` means that the native static library is registered as a dependency
97+
of that rlib "by name", and object files from it are included only during linking of the final
98+
binary, the file search by that name is also performed during final linking. \
99+
When building a staticlib `-bundle` means that the native static library is simply not included
100+
into the archive and some higher level build system will need to add it later during linking of
101+
the final binary.
102+
103+
This modifier has no effect when building other targets like executables or dynamic libraries.
104+
105+
The default for this modifier is `+bundle`.
106+
87107
<a id="option-crate-type"></a>
88108
## `--crate-type`: a list of types of crates for the compiler to emit
89109

src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)