From 65037cffdb986acb08035988674765b6cf0f34e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 29 Nov 2025 15:21:57 +0100 Subject: [PATCH] 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. --- pkgs/by-name/ca/cargo-llvm-cov/package.nix | 3 +-- pkgs/development/compilers/rust/rustc.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ca/cargo-llvm-cov/package.nix b/pkgs/by-name/ca/cargo-llvm-cov/package.nix index 52db65a97405..4de52a2360c3 100644 --- a/pkgs/by-name/ca/cargo-llvm-cov/package.nix +++ b/pkgs/by-name/ca/cargo-llvm-cov/package.nix @@ -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; }; }) diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index d2364f7aa533..b483594f7979 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -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}" ]