rustPlatform.buildRustPackage: provide debug symbols on darwin (#327136)

This commit is contained in:
Jörg Thalheim 2024-09-21 18:30:46 +02:00 committed by GitHub
commit a50dabe867
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -97,6 +97,11 @@ assert useSysroot -> !(args.doCheck or true);
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoLock" ]) // lib.optionalAttrs useSysroot {
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
} // lib.optionalAttrs (stdenv.isDarwin && buildType == "debug") {
RUSTFLAGS =
"-C split-debuginfo=packed "
+ lib.optionalString useSysroot "--sysroot ${sysroot} "
+ (args.RUSTFLAGS or "");
} // {
inherit buildAndTestSubdir cargoDeps;

View File

@ -36,6 +36,11 @@ cargoInstallHook() {
-maxdepth 1 \
-regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
-print0 | xargs -r -0 cp -t $out/lib
# If present, copy any .dSYM directories for debugging on darwin
# https://github.com/NixOS/nixpkgs/issues/330036
find "${releaseDir}" -maxdepth 1 -name '*.dSYM' -exec cp -RLt $out/bin/ {} +
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
runHook postInstall