From 6d19ab339ae74c44d98ec7f24352824d38fa100b Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Sun, 12 Jul 2020 14:40:09 +0100 Subject: [PATCH 1/2] cpython: set separateDebugInfo --- pkgs/development/interpreters/python/cpython/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index e6c8b301c0b..f45aae9953a 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -296,6 +296,8 @@ in with passthru; stdenv.mkDerivation { pythonForBuild buildPackages.bash ]; + separateDebugInfo = true; + inherit passthru; enableParallelBuilding = true; From ede2e00c9fffb0fcdb3929f045039485b5b2f99a Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Sun, 12 Jul 2020 14:48:10 +0100 Subject: [PATCH 2/2] cpython: expose gdb libpython.py used together with cpython's debugging symbols, this allows inspection of the python stack of cpython programs in gdb. this file is a little different from the rest of the python output by this package, in that it's not intended to be run by the current python being built, instead by the python being used by the gdb in question, which could be very different. therefore placed in its own, but hopefully logical & predictable location. --- pkgs/development/interpreters/python/cpython/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index f45aae9953a..7b42f2c7565 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -279,6 +279,13 @@ in with passthru; stdenv.mkDerivation { find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i - '' + optionalString stripBytecode '' find $out -type d -name __pycache__ -print0 | xargs -0 -I {} rm -rf "{}" + '' + '' + # *strip* shebang from libpython gdb script - it should be dual-syntax and + # interpretable by whatever python the gdb in question is using, which may + # not even match the major version of this python. doing this after the + # bytecode compilations for the same reason. + mkdir -p $out/share/gdb + sed '/^#!/d' Tools/gdb/libpython.py > $out/share/gdb/libpython.py ''; preFixup = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''