-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Tweak visibility of some lang items
This commit tweaks the linker-level visibility of some lang items that rustc uses and defines. Notably this means that `#[panic_implementation]` and `#[alloc_error_handler]` functions are never marked as `internal`. It's up to the linker to eliminate these, not rustc. Additionally `#[global_allocator]` generated symbols are no longer forced to `Default` visibility (fully exported), but rather they're relaxed to `Hidden` visibility). This symbols are *not* needed across DLL boundaries, only as a local implementation detail of the compiler-injected allocator symbols, so `Hidden` should suffice. Closes #51342 Closes #52795
- Loading branch information
1 parent
38eeebd
commit 7c58ab6
Showing
9 changed files
with
238 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
ifeq ($(TARGET),wasm32-unknown-unknown) | ||
all: | ||
$(RUSTC) foo.rs --target wasm32-unknown-unknown | ||
$(NODE) verify-exported-symbols.js $(TMPDIR)/foo.wasm | ||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O | ||
$(NODE) verify-exported-symbols.js $(TMPDIR)/foo.wasm | ||
$(RUSTC) bar.rs --target wasm32-unknown-unknown | ||
$(NODE) verify-exported-symbols.js $(TMPDIR)/bar.wasm | ||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -O | ||
$(NODE) verify-exported-symbols.js $(TMPDIR)/bar.wasm | ||
else | ||
all: | ||
endif | ||
|
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,45 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(panic_implementation, alloc_error_handler)] | ||
#![crate_type = "cdylib"] | ||
#![no_std] | ||
|
||
use core::alloc::*; | ||
|
||
struct B; | ||
|
||
unsafe impl GlobalAlloc for B { | ||
unsafe fn alloc(&self, x: Layout) -> *mut u8 { | ||
1 as *mut u8 | ||
} | ||
|
||
unsafe fn dealloc(&self, ptr: *mut u8, x: Layout) { | ||
} | ||
} | ||
|
||
#[global_allocator] | ||
static A: B = B; | ||
|
||
#[no_mangle] | ||
pub extern fn foo(a: u32) -> u32 { | ||
assert_eq!(a, 3); | ||
a * 2 | ||
} | ||
|
||
#[alloc_error_handler] | ||
fn a(_: core::alloc::Layout) -> ! { | ||
loop {} | ||
} | ||
|
||
#[panic_implementation] | ||
fn b(_: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} |
Oops, something went wrong.