mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
72e29da3ec
Currently, combining +bundle and +whole-archive works only with #![feature(packed_bundled_libs)] This crate feature is independent of the -Zpacked-bundled-libs command line option. This commit stabilizes the #![feature(packed_bundled_libs)] crate feature and implicitly enables it only when the +bundle and +whole-archive link modifiers are combined. This allows rlib crates to use the +whole-archive link modifier with native libraries and have all symbols included in the linked library to be included in downstream staticlib crates that use the rlib as a dependency. Other cases requiring the packed_bundled_libs behavior still require the -Zpacked-bundled-libs command line option, which can be stabilized independently in the future. Per discussion on https://github.com/rust-lang/rust/issues/108081 there is no risk of regression stabilizing the crate feature in this way because the combination of +bundle,+whole-archive link modifiers was previously not allowed.
36 lines
1.6 KiB
Makefile
36 lines
1.6 KiB
Makefile
include ../tools.mk
|
|
|
|
# ignore-cross-compile
|
|
# only-linux
|
|
|
|
# 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.
|
|
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
|
|
$(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"
|
|
$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o"
|
|
$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o"
|
|
|
|
|
|
# test bundle with whole_archive
|
|
$(RUSTC) rust_dep.rs --crate-type=rlib
|
|
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1"
|
|
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3"
|
|
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2"
|
|
$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4"
|
|
|
|
# Make sure compiler doesn't use files, that it shouldn't know about.
|
|
rm $(TMPDIR)/libnative_dep_1.a
|
|
rm $(TMPDIR)/libnative_dep_3.a
|
|
|
|
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args
|
|
cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3"
|
|
cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4"
|