Skip to content

Commit 3dea003

Browse files
committed
Auto merge of #95818 - petrochenkov:stabundle, r=wesleywiser
Stabilize the `bundle` native library modifier And remove the legacy `static-nobundle` linking kind. Stabilization report - #95818 (comment). cc #81490 Closes #37403
2 parents 52ee2a2 + a8ee1f3 commit 3dea003

35 files changed

+91
-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 non lexical lifetimes (RFC 2094).

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ declare_features! (
451451
(active, naked_functions, "1.9.0", Some(32408), None),
452452
/// Allows specifying the as-needed link modifier
453453
(active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None),
454-
/// Allows specifying the bundle link modifier
455-
(active, native_link_modifiers_bundle, "1.53.0", Some(81490), None),
456454
/// Allows specifying the verbatim link modifier
457455
(active, native_link_modifiers_verbatim, "1.53.0", Some(81490), None),
458456
/// Allow negative trait implementations.
@@ -502,8 +500,6 @@ declare_features! (
502500
(active, simd_ffi, "1.0.0", Some(27731), None),
503501
/// Allows specialization of implementations (RFC 1210).
504502
(incomplete, specialization, "1.7.0", Some(31844), None),
505-
/// Allows `#[link(kind="static-nobundle"...)]`.
506-
(active, static_nobundle, "1.16.0", Some(37403), None),
507503
/// Allows attributes on expressions and non-item statements.
508504
(active, stmt_expr_attributes, "1.6.0", Some(15701), None),
509505
/// 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
@@ -1920,21 +1920,6 @@ fn parse_native_lib_kind(
19201920

19211921
let kind = match kind {
19221922
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
1923-
"static-nobundle" => {
1924-
early_warn(
1925-
error_format,
1926-
"library kind `static-nobundle` has been superseded by specifying \
1927-
modifier `-bundle` with library kind `static`. Try `static:-bundle`",
1928-
);
1929-
if !nightly_options::match_is_nightly_build(matches) {
1930-
early_error(
1931-
error_format,
1932-
"library kind `static-nobundle` is unstable \
1933-
and only accepted on the nightly compiler",
1934-
);
1935-
}
1936-
NativeLibKind::Static { bundle: Some(false), whole_archive: None }
1937-
}
19381923
"dylib" => NativeLibKind::Dylib { as_needed: None },
19391924
"framework" => NativeLibKind::Framework { as_needed: None },
19401925
_ => early_error(
@@ -1987,10 +1972,7 @@ fn parse_native_lib_modifiers(
19871972
}
19881973
};
19891974
match (modifier, &mut kind) {
1990-
("bundle", NativeLibKind::Static { bundle, .. }) => {
1991-
report_unstable_modifier();
1992-
assign_modifier(bundle)
1993-
}
1975+
("bundle", NativeLibKind::Static { bundle, .. }) => assign_modifier(bundle),
19941976
("bundle", _) => early_error(
19951977
error_format,
19961978
"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(staged_api)]
66
#![feature(c_unwind)]
77
#![feature(cfg_target_abi)]

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)