Skip to content

Commit 245a0af

Browse files
authored
Rollup merge of #59506 - JohnTitor:improve-mcount, r=nagisa
Use platform dependent mcount function close #59097 This pull-request is based on #57244 and [here](https://github.com/llvm-mirror/clang/search?q=MCountName&unscoped_MCountName). r? @nagisa
2 parents dffdd8f + 7b26a43 commit 245a0af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+141
-40
lines changed

src/librustc_codegen_llvm/attributes.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
7777
if cx.sess().instrument_mcount() {
7878
// Similar to `clang -pg` behavior. Handled by the
7979
// `post-inline-ee-instrument` LLVM pass.
80+
81+
// The function name varies on platforms.
82+
// See test/CodeGen/mcount.c in clang.
83+
let mcount_name = CString::new(
84+
cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();
85+
8086
llvm::AddFunctionAttrStringValue(
8187
llfn, llvm::AttributePlace::Function,
82-
const_cstr!("instrument-function-entry-inlined"), const_cstr!("mcount"));
88+
const_cstr!("instrument-function-entry-inlined"), &mcount_name);
8389
}
8490
}
8591

src/librustc_target/spec/aarch64_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
1717
linker_flavor: LinkerFlavor::Gcc,
1818
options: TargetOptions {
1919
abi_blacklist: super::arm_base::abi_blacklist(),
20+
target_mcount: "\u{1}_mcount".to_string(),
2021
.. base
2122
},
2223
})

src/librustc_target/spec/aarch64_unknown_linux_musl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
1717
linker_flavor: LinkerFlavor::Gcc,
1818
options: TargetOptions {
1919
abi_blacklist: super::arm_base::abi_blacklist(),
20+
target_mcount: "\u{1}_mcount".to_string(),
2021
.. base
2122
},
2223
})

src/librustc_target/spec/aarch64_unknown_netbsd.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{LinkerFlavor, Target, TargetResult};
1+
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
22

33
pub fn target() -> TargetResult {
44
let mut base = super::netbsd_base::opts();
@@ -16,6 +16,9 @@ pub fn target() -> TargetResult {
1616
target_env: String::new(),
1717
target_vendor: "unknown".to_string(),
1818
linker_flavor: LinkerFlavor::Gcc,
19-
options: base,
19+
options: TargetOptions {
20+
target_mcount: "__mcount".to_string(),
21+
.. base
22+
},
2023
})
2124
}

src/librustc_target/spec/arm_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
1818
options: TargetOptions {
1919
features: "+strict-align,+v6".to_string(),
2020
abi_blacklist: super::arm_base::abi_blacklist(),
21+
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
2122
.. base
2223
},
2324
})

src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
1818
options: TargetOptions {
1919
features: "+strict-align,+v6,+vfp2".to_string(),
2020
abi_blacklist: super::arm_base::abi_blacklist(),
21+
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
2122
.. base
2223
}
2324
})

src/librustc_target/spec/arm_unknown_linux_musleabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
2323
linker_flavor: LinkerFlavor::Gcc,
2424
options: TargetOptions {
2525
abi_blacklist: super::arm_base::abi_blacklist(),
26+
target_mcount: "\u{1}mcount".to_string(),
2627
.. base
2728
},
2829
})

src/librustc_target/spec/arm_unknown_linux_musleabihf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
2323
linker_flavor: LinkerFlavor::Gcc,
2424
options: TargetOptions {
2525
abi_blacklist: super::arm_base::abi_blacklist(),
26+
target_mcount: "\u{1}mcount".to_string(),
2627
.. base
2728
},
2829
})

src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
1919
// Atomic operations provided by compiler-builtins
2020
max_atomic_width: Some(32),
2121
abi_blacklist: super::arm_base::abi_blacklist(),
22+
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
2223
.. base
2324
}
2425
})

src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
1919
// Atomic operations provided by compiler-builtins
2020
max_atomic_width: Some(32),
2121
abi_blacklist: super::arm_base::abi_blacklist(),
22+
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
2223
.. base
2324
}
2425
})

0 commit comments

Comments
 (0)