forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[link] enable packed bundled lib in non stable cases
- Loading branch information
Showing
19 changed files
with
146 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
# ignore-cross-compile | ||
# only-linux | ||
|
||
# Make sure -Zpacked_bundled_libs-like behavior activates with 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 -Zpacked_bundled_libs | ||
$(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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate rust_dep; | ||
|
||
pub fn main() { | ||
rust_dep::rust_dep(); | ||
} |
1 change: 1 addition & 0 deletions
1
tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int native_f1() { return 1; } |
1 change: 1 addition & 0 deletions
1
tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int native_f2() { return 2; } |
1 change: 1 addition & 0 deletions
1
tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int native_f3() { return 3; } |
1 change: 1 addition & 0 deletions
1
tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int native_f4() { return 4; } |
16 changes: 16 additions & 0 deletions
16
tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(packed_bundled_libs)] | ||
|
||
#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")] | ||
extern "C" {} | ||
|
||
#[link(name = "native_dep_2", kind = "static", modifiers = "+whole-archive,-bundle")] | ||
extern "C" {} | ||
|
||
#[link(name = "native_dep_3", kind = "static", modifiers = "+bundle")] | ||
extern "C" {} | ||
|
||
#[link(name = "native_dep_4", kind = "static", modifiers = "-bundle")] | ||
extern "C" {} | ||
|
||
#[no_mangle] | ||
pub fn rust_dep() {} |
10 changes: 10 additions & 0 deletions
10
tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(link_cfg)] | ||
|
||
#[link(name = "native_dep_1", kind = "static", cfg(should_add))] | ||
extern "C" {} | ||
|
||
#[link(name = "native_dep_2", kind = "static", cfg(should_not_add))] | ||
extern "C" {} | ||
|
||
#[no_mangle] | ||
pub fn rust_dep() {} |
13 changes: 8 additions & 5 deletions
13
tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// compile-flags: -Zunstable-options --crate-type rlib | ||
// 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 | ||
// error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs | ||
|
||
#[link(name = "mylib", kind = "static", modifiers = "+bundle,+whole-archive")] | ||
extern "C" { } | ||
#[link(name = "rust_test_helpers", kind = "static", modifiers = "+bundle,+whole-archive")] | ||
extern "C" {} | ||
|
||
fn main() { } | ||
fn main() {} |
6 changes: 2 additions & 4 deletions
6
tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
error: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs | ||
error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs | ||
|
||
error: could not find native static library `mylib`, perhaps an -L flag is missing? | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to previous error | ||
|
Oops, something went wrong.