Auto merge of #113301 - Be-ing:stabilize_bundle_whole-archive, r=petrochenkov

stabilize combining +bundle and +whole-archive link modifiers

Per discussion on https://github.com/rust-lang/rust/issues/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`
This commit is contained in:
bors 2023-09-29 15:51:48 +00:00
commit 56ada88e7e
13 changed files with 5 additions and 48 deletions

View file

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

View file

@ -365,15 +365,9 @@ fn link_rlib<'a>(
// loaded from the libraries found here and then encode that into the
// metadata of the rlib we're generating somehow.
for lib in codegen_results.crate_info.used_libraries.iter() {
let NativeLibKind::Static { bundle: None | Some(true), whole_archive } = lib.kind else {
let NativeLibKind::Static { bundle: None | Some(true), .. } = lib.kind else {
continue;
};
if whole_archive == Some(true)
&& flavor == RlibFlavor::Normal
&& !codegen_results.crate_info.feature_packed_bundled_libs
{
sess.emit_err(errors::IncompatibleLinkingModifiers);
}
if flavor == RlibFlavor::Normal && let Some(filename) = lib.filename {
let path = find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
let src = read(path).map_err(|e| sess.emit_fatal(errors::ReadFileError {message: e }))?;

View file

@ -857,7 +857,6 @@ impl CrateInfo {
dependency_formats: tcx.dependency_formats(()).clone(),
windows_subsystem,
natvis_debugger_visualizers: Default::default(),
feature_packed_bundled_libs: tcx.features().packed_bundled_libs,
};
let crates = tcx.crates(());

View file

@ -107,10 +107,6 @@ pub struct CreateTempDir {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_incompatible_linking_modifiers)]
pub struct IncompatibleLinkingModifiers;
#[derive(Diagnostic)]
#[diag(codegen_ssa_add_native_library)]
pub struct AddNativeLibrary {

View file

@ -164,7 +164,6 @@ pub struct CrateInfo {
pub dependency_formats: Lrc<Dependencies>,
pub windows_subsystem: Option<String>,
pub natvis_debugger_visualizers: BTreeSet<DebuggerVisualizerFile>,
pub feature_packed_bundled_libs: bool, // unstable feature flag.
}
#[derive(Encodable, Decodable)]

View file

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

View file

@ -241,8 +241,6 @@ declare_features! (
(active, linkage, "1.0.0", Some(29603), None),
/// Allows declaring with `#![needs_panic_runtime]` that a panic runtime is needed.
(internal, needs_panic_runtime, "1.10.0", Some(32837), None),
/// Allows using `+bundled,+whole-archive` native libs.
(active, packed_bundled_libs, "1.69.0", Some(108081), None),
/// Allows using the `#![panic_runtime]` attribute.
(internal, panic_runtime, "1.10.0", Some(32837), None),
/// Allows `extern "platform-intrinsic" { ... }`.

View file

@ -3,7 +3,7 @@ include ../tools.mk
# ignore-cross-compile
# only-linux
# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+whole-archive.
# We're using the llvm-nm instead of the system nm to ensure it is compatible
# with the LLVM bitcode generated by rustc.
@ -11,7 +11,7 @@ NM = "$(LLVM_BIN_DIR)"/llvm-nm
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)
# test cfg with packed bundle
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
$(RUSTC) rust_dep_cfg.rs --crate-type=rlib
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"

View file

@ -1,5 +1,3 @@
#![feature(packed_bundled_libs)]
#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")]
extern "C" {}

View file

@ -1,11 +0,0 @@
// gate-test-packed_bundled_libs
// ignore-wasm32-bare
// compile-flags: --crate-type rlib
// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
// build-fail
#[link(name = "rust_test_helpers", kind = "static", modifiers = "+bundle,+whole-archive")]
extern "C" {}
fn main() {}

View file

@ -1,4 +0,0 @@
error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
error: aborting due to previous error

View file

@ -1,8 +0,0 @@
// gate-test-packed_bundled_libs
// ignore-wasm32-bare
// compile-flags: -l static:+bundle,+whole-archive=rust_test_helpers --crate-type rlib
// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
// build-fail
fn main() {}

View file

@ -1,4 +0,0 @@
error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
error: aborting due to previous error