Skip to content

Commit 89eb329

Browse files
authored
Rollup merge of #154566 - heiher:loong-mcount-sym, r=chenyukang
loongarch: use "_mcount" as the default mcount symbol Set the `mcount` field to "_mcount" for all LoongArch targets to match Clang/GCC behavior [1]. This fixes linking failures when using `-Z instrument-mcount`, where the runtime expects "_mcount" instead of "mcount". [1] https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/LoongArch.h#L60
2 parents 7275f7e + 6e984cd commit 89eb329

7 files changed

Lines changed: 7 additions & 0 deletions

compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
2222
linker: Some("rust-lld".into()),
2323
llvm_abiname: LlvmAbi::Ilp32d,
2424
max_atomic_width: Some(32),
25+
mcount: "_mcount".into(),
2526
relocation_model: RelocModel::Static,
2627
panic_strategy: PanicStrategy::Abort,
2728
..Default::default()

compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
linker: Some("rust-lld".into()),
2424
llvm_abiname: LlvmAbi::Ilp32s,
2525
max_atomic_width: Some(32),
26+
mcount: "_mcount".into(),
2627
relocation_model: RelocModel::Static,
2728
panic_strategy: PanicStrategy::Abort,
2829
..Default::default()

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
2020
features: "+f,+d,+lsx,+relax".into(),
2121
llvm_abiname: LlvmAbi::Lp64d,
2222
max_atomic_width: Some(64),
23+
mcount: "_mcount".into(),
2324
supported_sanitizers: SanitizerSet::ADDRESS
2425
| SanitizerSet::CFI
2526
| SanitizerSet::LEAK

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
2020
features: "+f,+d,+lsx,+relax".into(),
2121
llvm_abiname: LlvmAbi::Lp64d,
2222
max_atomic_width: Some(64),
23+
mcount: "_mcount".into(),
2324
crt_static_default: false,
2425
supported_sanitizers: SanitizerSet::ADDRESS
2526
| SanitizerSet::CFI

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
2020
features: "+f,+d,+lsx,+relax".into(),
2121
llvm_abiname: LlvmAbi::Lp64d,
2222
max_atomic_width: Some(64),
23+
mcount: "_mcount".into(),
2324
supported_sanitizers: SanitizerSet::ADDRESS
2425
| SanitizerSet::CFI
2526
| SanitizerSet::LEAK

compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
2222
linker: Some("rust-lld".into()),
2323
llvm_abiname: LlvmAbi::Lp64d,
2424
max_atomic_width: Some(64),
25+
mcount: "_mcount".into(),
2526
relocation_model: RelocModel::Static,
2627
panic_strategy: PanicStrategy::Abort,
2728
code_model: Some(CodeModel::Medium),

compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
linker: Some("rust-lld".into()),
2424
llvm_abiname: LlvmAbi::Lp64s,
2525
max_atomic_width: Some(64),
26+
mcount: "_mcount".into(),
2627
relocation_model: RelocModel::Static,
2728
panic_strategy: PanicStrategy::Abort,
2829
code_model: Some(CodeModel::Medium),

0 commit comments

Comments
 (0)