-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WIP] add -Z split_bundled_libs #99773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6204f65
add -Z split_bundled_libs
Bryanskiy 3398306
fix staticlib bundling
Bryanskiy 7fc1864
fix error message
Bryanskiy 42a200d
fix rustdoc-ui test
Bryanskiy f766077
add test + small fix
Bryanskiy 70fa93d
test cleaunup
Bryanskiy 604e4b0
fix test
Bryanskiy 9702309
code cleanup
Bryanskiy 7ffd8d3
merge tests + cleanup
Bryanskiy 6a368f5
delete unused files
Bryanskiy 5ac82d2
cleanup
Bryanskiy d00f605
Merge branch 'master' into bundle-whole-archive
Bryanskiy 8d09ef9
cleanup
Bryanskiy 1215ea4
add cdylib-bundled-split test
Bryanskiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
35 changes: 35 additions & 0 deletions
35
src/test/run-make/native-link-modifier-bundle-split/Makefile
This file contains hidden or 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 @@ | ||
# ignore-cross-compile | ||
# ignore-windows-msvc | ||
|
||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
# 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 | ||
SPLIT = "-Zsplit-bundled-libs" | ||
BUNDLED_LIB = "libbundled.rlib.bundle.native-staticlib.a" | ||
|
||
all: $(call NATIVE_STATICLIB,native-staticlib) | ||
# Build a staticlib and a rlib, the `native_func` symbol will be bundled only into staticlib | ||
$(RUSTC) bundled.rs --crate-type=staticlib --crate-type=rlib $(SPLIT) | ||
$(NM) $(TMPDIR)/libbundled.a | $(CGREP) -e "T _*native_func" | ||
$(NM) $(TMPDIR)/libbundled.a | $(CGREP) -e "U _*native_func" | ||
$(NM) $(TMPDIR)/libbundled.rlib | $(CGREP) -ve "T _*native_func" | ||
$(NM) $(TMPDIR)/libbundled.rlib | $(CGREP) -e "U _*native_func" | ||
|
||
# Build a staticlib and a rlib, the `native_func` symbol will not be bundled into it | ||
$(RUSTC) non-bundled.rs --crate-type=staticlib --crate-type=rlib $(SPLIT) | ||
$(NM) $(TMPDIR)/libnon_bundled.a | $(CGREP) -ve "T _*native_func" | ||
$(NM) $(TMPDIR)/libnon_bundled.a | $(CGREP) -e "U _*native_func" | ||
$(NM) $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -ve "T _*native_func" | ||
$(NM) $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -e "U _*native_func" | ||
petrochenkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Build a cdylib, 'BUNDLED_LIB' will appear on the linker line | ||
# The cdylib will contain the `native_func` symbol in the end | ||
$(RUSTC) cdylib-bundled.rs --crate-type=cdylib --print link-args $(SPLIT) | $(CGREP) -e $(BUNDLED_LIB) | ||
$(NM) $(call DYLIB,cdylib_bundled) | $(CGREP) -e "[Tt] _*native_func" | ||
|
||
# Build a cdylib, `native-staticlib` will appear on the linker line because it was not bundled previously | ||
# The cdylib will contain the `native_func` symbol in the end | ||
$(RUSTC) cdylib-non-bundled.rs --crate-type=cdylib --print link-args $(SPLIT) | $(CGREP) -e '-l[" ]*native-staticlib' | ||
$(NM) $(call DYLIB,cdylib_non_bundled) | $(CGREP) -e "[Tt] _*native_func" |
11 changes: 11 additions & 0 deletions
11
src/test/run-make/native-link-modifier-bundle-split/bundled.rs
This file contains hidden or 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,11 @@ | ||
#[link(name = "native-staticlib", kind = "static", modifiers = "+bundle")] | ||
extern "C" { | ||
pub fn native_func(); | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn wrapped_func() { | ||
unsafe { | ||
native_func(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/test/run-make/native-link-modifier-bundle-split/cdylib-bundled.rs
This file contains hidden or 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 @@ | ||
extern crate bundled; |
1 change: 1 addition & 0 deletions
1
src/test/run-make/native-link-modifier-bundle-split/cdylib-non-bundled.rs
This file contains hidden or 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 @@ | ||
extern crate non_bundled; |
1 change: 1 addition & 0 deletions
1
src/test/run-make/native-link-modifier-bundle-split/native-staticlib.c
This file contains hidden or 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 @@ | ||
void native_func() {} |
11 changes: 11 additions & 0 deletions
11
src/test/run-make/native-link-modifier-bundle-split/non-bundled.rs
This file contains hidden or 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,11 @@ | ||
#[link(name = "native-staticlib", kind = "static", modifiers = "-bundle")] | ||
extern "C" { | ||
pub fn native_func(); | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn wrapped_func() { | ||
unsafe { | ||
native_func(); | ||
} | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.