Skip to content

Commit

Permalink
Don't mangle probes all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jul 8, 2017
1 parent f9f6bd0 commit 89400c8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
8 changes: 3 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4099,11 +4099,9 @@ mod c {
// also needs to satisfy intrinsics that jemalloc or C in general may
// need, so include a few more that aren't typically needed by
// LLVM/Rust.
if env::var_os("CARGO_FEATURE_RUSTBUILD").is_some() {
sources.extend(&[
"ffsdi2.c",
]);
}
sources.extend(&[
"ffsdi2.c",
]);

if target_os != "ios" {
sources.extend(
Expand Down
1 change: 1 addition & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ for rlib in $(echo $path); do
uniq -d | \
grep -v __x86.get_pc_thunk | \
grep -v __builtin_cl | \
grep -v __builtin_ctz | \
grep 'T __'

if test $? = 0; then
Expand Down
6 changes: 6 additions & 0 deletions examples/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#![feature(lang_items)]
#![feature(start)]
#![feature(i128_type)]
#![feature(global_allocator)]
#![feature(allocator_api)]
#![cfg_attr(windows, feature(panic_unwind))]
#![no_std]

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

#[cfg(not(thumb))]
#[global_allocator]
static A: alloc_system::System = alloc_system::System;

// NOTE cfg(not(thumbv6m)) means that the operation is not supported on ARMv6-M at all. Not even
// compiler-rt provides a C/assembly implementation.

Expand Down
5 changes: 3 additions & 2 deletions src/float/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ intrinsics! {
int_to_float!(i, u32, f64)
}

#[use_c_shim_if(all(any(target_arch = "x86", target_arch = "x86_64"),
not(windows)))]
#[use_c_shim_if(all(not(target_env = "msvc"),
any(target_arch = "x86",
all(not(windows), target_arch = "x86_64"))))]
#[arm_aeabi_alias = __aeabi_ul2d]
pub extern "C" fn __floatundidf(i: u64) -> f64 {
int_to_float!(i, u64, f64)
Expand Down
4 changes: 2 additions & 2 deletions src/probestack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#![cfg(not(windows))] // Windows already has builtins to do this

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

#[naked]
#[no_mangle]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
#[cfg(target_arch = "x86")]
pub unsafe extern fn __rust_probestack() {
// This is the same as x86_64 above, only translated for 32-bit sizes. Note
Expand Down
6 changes: 3 additions & 3 deletions src/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::intrinsics;

#[cfg(windows)]
#[naked]
#[no_mangle]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
pub unsafe fn ___chkstk_ms() {
asm!("push %rcx
push %rax
Expand All @@ -34,7 +34,7 @@ pub unsafe fn ___chkstk_ms() {

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

#[cfg(windows)]
#[naked]
#[no_mangle]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
pub unsafe fn ___chkstk() {
asm!("push %rcx
cmp $$0x1000,%rax
Expand Down

0 comments on commit 89400c8

Please sign in to comment.