mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
rustPlatform.buildRustPackage: provide debug symbols on darwin
Currently we cannot debug rust binaries on darwin (via lldb). The debug symbols seem to be provided by default in a number of files in `target/debug/deps/*.rcgu.o`. As far as I can tell these have hardcoded paths referring to the ephemeral build directory. However, `split-debuginfo=packed` conveniently produces a `.dSYM` file that can be copied to `$out/bin/` and immediately provide debugging information. Fixes https://github.com/NixOS/nixpkgs/issues/262131
This commit is contained in:
parent
a3836576dd
commit
16f3c7ebcb
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user