Skip to content

Commit 91eaa85

Browse files
committed
Don't mangle probes all the time
1 parent f9f6bd0 commit 91eaa85

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

build.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ fn main() {
2121
#[cfg(feature = "gen-tests")]
2222
tests::generate();
2323

24-
// Build missing intrinsics from compiler-rt C source code
25-
#[cfg(feature = "c")]
26-
c::compile(&llvm_target);
24+
// Build missing intrinsics from compiler-rt C source code. If we're
25+
// mangling names though we assume that we're also in test mode so we don't
26+
// build anything and we rely on the upstream implementation of compiler-rt
27+
// functions
28+
if !cfg!(feature = "mangled-names") {
29+
#[cfg(feature = "c")]
30+
c::compile(&llvm_target);
31+
}
2732

2833
// To compile intrinsics.rs for thumb targets, where there is no libc
2934
if llvm_target[0].starts_with("thumb") {
@@ -4099,11 +4104,9 @@ mod c {
40994104
// also needs to satisfy intrinsics that jemalloc or C in general may
41004105
// need, so include a few more that aren't typically needed by
41014106
// LLVM/Rust.
4102-
if env::var_os("CARGO_FEATURE_RUSTBUILD").is_some() {
4103-
sources.extend(&[
4104-
"ffsdi2.c",
4105-
]);
4106-
}
4107+
sources.extend(&[
4108+
"ffsdi2.c",
4109+
]);
41074110

41084111
if target_os != "ios" {
41094112
sources.extend(

ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ for rlib in $(echo $path); do
9393
uniq -d | \
9494
grep -v __x86.get_pc_thunk | \
9595
grep -v __builtin_cl | \
96+
grep -v __builtin_ctz | \
9697
grep 'T __'
9798

9899
if test $? = 0; then

examples/intrinsics.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#![feature(lang_items)]
1414
#![feature(start)]
1515
#![feature(i128_type)]
16+
#![feature(global_allocator)]
17+
#![feature(allocator_api)]
1618
#![cfg_attr(windows, feature(panic_unwind))]
1719
#![no_std]
1820

@@ -22,6 +24,10 @@ extern crate compiler_builtins;
2224
#[cfg(windows)]
2325
extern crate panic_unwind;
2426

27+
#[cfg(not(thumb))]
28+
#[global_allocator]
29+
static A: alloc_system::System = alloc_system::System;
30+
2531
// NOTE cfg(not(thumbv6m)) means that the operation is not supported on ARMv6-M at all. Not even
2632
// compiler-rt provides a C/assembly implementation.
2733

src/float/conv.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ intrinsics! {
112112
int_to_float!(i, u32, f64)
113113
}
114114

115-
#[use_c_shim_if(all(any(target_arch = "x86", target_arch = "x86_64"),
116-
not(windows)))]
115+
#[use_c_shim_if(all(not(target_env = "msvc"),
116+
any(target_arch = "x86",
117+
all(not(windows), target_arch = "x86_64"))))]
117118
#[arm_aeabi_alias = __aeabi_ul2d]
118119
pub extern "C" fn __floatundidf(i: u64) -> f64 {
119120
int_to_float!(i, u64, f64)

src/probestack.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#![cfg(not(windows))] // Windows already has builtins to do this
4545

4646
#[naked]
47-
#[no_mangle]
47+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
4848
#[cfg(target_arch = "x86_64")]
4949
pub unsafe extern fn __rust_probestack() {
5050
// Our goal here is to touch each page between %rsp+8 and %rsp+8-%rax,
@@ -87,7 +87,7 @@ pub unsafe extern fn __rust_probestack() {
8787
}
8888

8989
#[naked]
90-
#[no_mangle]
90+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
9191
#[cfg(target_arch = "x86")]
9292
pub unsafe extern fn __rust_probestack() {
9393
// This is the same as x86_64 above, only translated for 32-bit sizes. Note

src/x86_64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::intrinsics;
1010

1111
#[cfg(windows)]
1212
#[naked]
13-
#[no_mangle]
13+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
1414
pub unsafe fn ___chkstk_ms() {
1515
asm!("push %rcx
1616
push %rax
@@ -34,7 +34,7 @@ pub unsafe fn ___chkstk_ms() {
3434

3535
#[cfg(windows)]
3636
#[naked]
37-
#[no_mangle]
37+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
3838
pub unsafe fn __alloca() {
3939
asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
4040
jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable");
@@ -43,7 +43,7 @@ pub unsafe fn __alloca() {
4343

4444
#[cfg(windows)]
4545
#[naked]
46-
#[no_mangle]
46+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
4747
pub unsafe fn ___chkstk() {
4848
asm!("push %rcx
4949
cmp $$0x1000,%rax

0 commit comments

Comments
 (0)