rustc, cargo-llvm-cov: enable profiler runtime on Darwin

Enable the LLVM profiler runtime on macOS by passing `--enable-profiler`
to rustc's configure. This allows cargo-llvm-cov and other coverage tools
to work on Darwin platforms.

The profiler is explicitly disabled for wasm and bpf targets which don't
support it.
This commit is contained in:
Jörg Thalheim
2025-11-29 15:21:57 +01:00
parent 59b6c96bea
commit 65037cffdb
2 changed files with 10 additions and 2 deletions
+1 -2
View File
@@ -93,7 +93,6 @@ rustPlatform.buildRustPackage (finalAttrs: {
CobaltCause
];
# The profiler runtime is (currently) disabled on non-Linux platforms
broken = !(stdenv.hostPlatform.isLinux && !stdenv.targetPlatform.isRedox);
broken = stdenv.targetPlatform.isRedox;
};
})
@@ -240,6 +240,15 @@ stdenv.mkDerivation (finalAttrs: {
++ optionals (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) [
"--enable-profiler" # build libprofiler_builtins
]
++ optionals stdenv.targetPlatform.isDarwin [
# potentially other llvm targets work with the same fix?
"--enable-profiler" # build libprofiler_builtins
# Disable profiler for targets that don't support it
"--set=target.wasm32-unknown-unknown.profiler=false"
"--set=target.wasm32v1-none.profiler=false"
"--set=target.bpfel-unknown-none.profiler=false"
"--set=target.bpfeb-unknown-none.profiler=false"
]
++ optionals stdenv.buildPlatform.isMusl [
"${setBuild}.musl-root=${pkgsBuildBuild.targetPackages.stdenv.cc.libc}"
]