Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 56ada88

Browse files
committedSep 29, 2023
Auto merge of #113301 - Be-ing:stabilize_bundle_whole-archive, r=petrochenkov
stabilize combining +bundle and +whole-archive link modifiers Per discussion on #108081 combining +bundle and +whole-archive already works and can be stabilized independently of other aspects of the packed_bundled_libs feature. There is no risk of regression because this was not previously allowed. r? `@petrochenkov`
2 parents a6dfd89 + 72e29da commit 56ada88

File tree

13 files changed

+5
-48
lines changed

13 files changed

+5
-48
lines changed
 

‎compiler/rustc_codegen_ssa/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ codegen_ssa_ignoring_output = ignoring -o because multiple .{$extension} files w
4646
codegen_ssa_illegal_link_ordinal_format = illegal ordinal format in `link_ordinal`
4747
.note = an unsuffixed integer value, e.g., `1`, is expected
4848
49-
codegen_ssa_incompatible_linking_modifiers = link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
50-
5149
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
5250
5351
codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`

‎compiler/rustc_codegen_ssa/src/back/link.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,9 @@ fn link_rlib<'a>(
365365
// loaded from the libraries found here and then encode that into the
366366
// metadata of the rlib we're generating somehow.
367367
for lib in codegen_results.crate_info.used_libraries.iter() {
368-
let NativeLibKind::Static { bundle: None | Some(true), whole_archive } = lib.kind else {
368+
let NativeLibKind::Static { bundle: None | Some(true), .. } = lib.kind else {
369369
continue;
370370
};
371-
if whole_archive == Some(true)
372-
&& flavor == RlibFlavor::Normal
373-
&& !codegen_results.crate_info.feature_packed_bundled_libs
374-
{
375-
sess.emit_err(errors::IncompatibleLinkingModifiers);
376-
}
377371
if flavor == RlibFlavor::Normal && let Some(filename) = lib.filename {
378372
let path = find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
379373
let src = read(path).map_err(|e| sess.emit_fatal(errors::ReadFileError {message: e }))?;

‎compiler/rustc_codegen_ssa/src/base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ impl CrateInfo {
857857
dependency_formats: tcx.dependency_formats(()).clone(),
858858
windows_subsystem,
859859
natvis_debugger_visualizers: Default::default(),
860-
feature_packed_bundled_libs: tcx.features().packed_bundled_libs,
861860
};
862861
let crates = tcx.crates(());
863862

‎compiler/rustc_codegen_ssa/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ pub struct CreateTempDir {
107107
pub error: Error,
108108
}
109109

110-
#[derive(Diagnostic)]
111-
#[diag(codegen_ssa_incompatible_linking_modifiers)]
112-
pub struct IncompatibleLinkingModifiers;
113-
114110
#[derive(Diagnostic)]
115111
#[diag(codegen_ssa_add_native_library)]
116112
pub struct AddNativeLibrary {

‎compiler/rustc_codegen_ssa/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ pub struct CrateInfo {
164164
pub dependency_formats: Lrc<Dependencies>,
165165
pub windows_subsystem: Option<String>,
166166
pub natvis_debugger_visualizers: BTreeSet<DebuggerVisualizerFile>,
167-
pub feature_packed_bundled_libs: bool, // unstable feature flag.
168167
}
169168

170169
#[derive(Encodable, Decodable)]

‎compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ declare_features! (
269269
(accepted, non_modrs_mods, "1.30.0", Some(44660), None),
270270
/// Allows the use of or-patterns (e.g., `0 | 1`).
271271
(accepted, or_patterns, "1.53.0", Some(54883), None),
272+
/// Allows using `+bundle,+whole-archive` link modifiers with native libs.
273+
(accepted, packed_bundled_libs, "CURRENT_RUSTC_VERSION", Some(108081), None),
272274
/// Allows annotating functions conforming to `fn(&PanicInfo) -> !` with `#[panic_handler]`.
273275
/// This defines the behavior of panics.
274276
(accepted, panic_handler, "1.30.0", Some(44489), None),

‎compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ declare_features! (
241241
(active, linkage, "1.0.0", Some(29603), None),
242242
/// Allows declaring with `#![needs_panic_runtime]` that a panic runtime is needed.
243243
(internal, needs_panic_runtime, "1.10.0", Some(32837), None),
244-
/// Allows using `+bundled,+whole-archive` native libs.
245-
(active, packed_bundled_libs, "1.69.0", Some(108081), None),
246244
/// Allows using the `#![panic_runtime]` attribute.
247245
(internal, panic_runtime, "1.10.0", Some(32837), None),
248246
/// Allows `extern "platform-intrinsic" { ... }`.

‎tests/run-make/rlib-format-packed-bundled-libs-3/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ include ../tools.mk
33
# ignore-cross-compile
44
# only-linux
55

6-
# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
6+
# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+whole-archive.
77

88
# We're using the llvm-nm instead of the system nm to ensure it is compatible
99
# with the LLVM bitcode generated by rustc.
1010
NM = "$(LLVM_BIN_DIR)"/llvm-nm
1111

1212
all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4)
1313
# test cfg with packed bundle
14-
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
14+
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib
1515
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
1616
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
1717
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"

‎tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(packed_bundled_libs)]
2-
31
#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")]
42
extern "C" {}
53

‎tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs

-11
This file was deleted.

‎tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr

-4
This file was deleted.

‎tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs

-8
This file was deleted.

‎tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr

-4
This file was deleted.

0 commit comments

Comments
 (0)
Failed to load comments.