about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-04-29 12:28:25 -0400
committerGitHub <noreply@github.com>2025-04-29 12:28:25 -0400
commitff6a9800a38f30161ea7f819e2808f9bf97b5864 (patch)
tree293f2e2e50223905110b3f460c08ee5381742ee1
parent561f6a13094100ad0023b3c8a92f643165ae1cfc (diff)
parent6aea9f40ce2140a00b7d85bf036150b7e62bfa54 (diff)
downloadrust-ff6a9800a38f30161ea7f819e2808f9bf97b5864.tar.gz
rust-ff6a9800a38f30161ea7f819e2808f9bf97b5864.zip
Rollup merge of #140433 - BjoernLange:master, r=nnethercote
Replace the \01__gnu_mcount_nc to LLVM intrinsic for additional ARM targets

This is an extension to #113814 which seems to have missed two targets which also need this patch for instrumentation with `-Z instrument-mcount` to work correctly.

For anyone who might stumble over this issue again in the future: As a workaround one can dump the current target configuration using

```
rustc +nightly -Z unstable-options --target armv7-unknown-linux-gnueabihf --print target-spec-json
```

(assuming `armv7-unknown-linux-gnueabihf` is the target to build for) add the line

```
    "llvm-mcount-intrinsic": "llvm.arm.gnu.eabi.mcount",
```

and compile with

```
RUSTFLAGS="-Z instrument-mcount -C passes=ee-instrument<post-inline>" cargo +nightly build -Z build-std --target <path to directory with modified target config>/armv7-unknown-linux-gnueabihf.json
```

It might be necessary to set the compiler for cross compiling using something like

```
export TARGET_CC=arm-linux-gnueabihf-gcc
```
-rw-r--r--compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs1
-rw-r--r--compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs1
2 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs
index 52e786de3ed..7b93672dbe0 100644
--- a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs
+++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs
@@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
             max_atomic_width: Some(32),
             mcount: "\u{1}__gnu_mcount_nc".into(),
             has_thumb_interworking: true,
+            llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()),
             ..base::linux_gnu::opts()
         },
     }
diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs
index 3b5a337b4f1..a3b35d658e9 100644
--- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs
+++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
             features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
             max_atomic_width: Some(64),
             mcount: "\u{1}__gnu_mcount_nc".into(),
+            llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()),
             ..base::linux_gnu::opts()
         },
     }