-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Restore #![no_builtins]
crates participation in LTO.
#113923
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5200817
Restore `#![no_builtins]` crates participation in LTO.
dianqk 6762d64
Removes the useless DisableSimplifyLibCalls parameter.
dianqk a6f7596
Add `PreservedSymbols` from LLVM to LTO.
dianqk 7d06751
Update tests/run-make/wasm-builtins-import/main.rs
pnkfelix 665da1e
Update tests/run-make/wasm-builtins-import/main.rs
pnkfelix b592f29
Treat extern in compiler-builtins as `used`
dianqk d047968
Removes fields from `CrateInfo` that are no longer used.
dianqk 8d69a1e
Add crate `compiler_builtins` to LTO even if the `Linkage` is `Includ…
dianqk 436d4f6
Fix link name for `extern "C"` in msvc
dianqk b9f53be
Put `$(LLVM_BIN_DIR)` in quotes to prevent missing backslashes
dianqk 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
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
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
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
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
include ../tools.mk | ||
|
||
# only-x86_64 | ||
|
||
# We want to check that `no_builtins` is correctly participating in LTO. | ||
# First, verify that the `foo::foo` symbol can be found when linking. | ||
# Next, verify that `memcpy` can be customized using `no_builtins` under LTO. | ||
# Others will use the built-in memcpy. | ||
|
||
all: | ||
# Compile a `#![no_builtins]` rlib crate | ||
$(RUSTC) no_builtins.rs | ||
# Build an executable that depends on that crate using LTO. The no_builtins crate doesn't | ||
# participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by | ||
# grepping the linker arguments. | ||
$(RUSTC) main.rs -C lto --print link-args | $(CGREP) 'libno_builtins.rlib' | ||
$(RUSTC) -C linker-plugin-lto -C opt-level=2 -C debuginfo=0 foo.rs | ||
$(RUSTC) -C linker-plugin-lto -C opt-level=2 -C debuginfo=0 no_builtins.rs | ||
$(RUSTC) main.rs -C lto -C opt-level=2 -C debuginfo=0 -C save-temps -C metadata=1 -C codegen-units=1 | ||
"$(LLVM_BIN_DIR)"/llvm-dis $(TMPDIR)/main.main.*-cgu.0.rcgu.lto.input.bc -o $(TMPDIR)/lto.ll | ||
cat "$(TMPDIR)"/lto.ll | "$(LLVM_FILECHECK)" filecheck.lto.txt |
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,17 @@ | ||
CHECK: define{{.*}} void @bar | ||
CHECK-NEXT: call void @no_builtins | ||
CHECK-NEXT: call void @llvm.memcpy | ||
|
||
CHECK: define{{.*}} i32 @main | ||
CHECK: call void @bar | ||
|
||
CHECK: define{{.*}} void @foo | ||
CHECK-NEXT: call void @llvm.memcpy | ||
|
||
CHECK: define{{.*}} void @no_builtins | ||
CHECK-SAME: #[[ATTR:[0-9]+]] { | ||
CHECK: call void @foo | ||
CHECK-NEXT: call{{.*}} @memcpy | ||
|
||
CHECK: attributes #[[ATTR]] | ||
CHECK-SAME: no-builtins |
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,33 @@ | ||
#![feature(lang_items, no_core)] | ||
#![no_std] | ||
#![no_core] | ||
#![crate_type = "lib"] | ||
|
||
#[inline(never)] | ||
#[no_mangle] | ||
pub unsafe fn foo(dest: *mut u8, src: *const u8) { | ||
// should call `@llvm.memcpy`. | ||
memcpy(dest, src, 1024); | ||
} | ||
|
||
#[no_mangle] | ||
#[inline(never)] | ||
pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, _n: usize) -> *mut u8 { | ||
*dest = 0; | ||
return src as *mut u8; | ||
} | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
impl Copy for *mut u8 {} | ||
impl Copy for *const u8 {} | ||
|
||
#[lang = "drop_in_place"] | ||
#[allow(unconditional_recursion)] | ||
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { | ||
// Code here does not matter - this is replaced by the | ||
// real drop glue by the compiler. | ||
drop_in_place(to_drop); | ||
} |
Oops, something went wrong.
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.