mirror of https://github.com/pwndbg/pwndbg.git
Portable release use gdb/lldb from pypi (#3425)
* use gdb/lldb from pypi * test * test * test * add lldb * fixy * fixy * fixy * fix toml * revert bundle * fix bundlepull/3452/head
parent
7c83a2acd4
commit
4e85c8cc2b
@ -1,55 +0,0 @@
|
||||
--- a/gdb/python/python-config.py (revision fa93e88f754e10dfb60dd4c9bf9cef858d4c7e4a)
|
||||
+++ b/gdb/python/python-config.py (revision 1605cab3f0f578a75778efdc4c380bbb8463ad6f)
|
||||
@@ -1,6 +1,15 @@
|
||||
# Program to fetch python compilation parameters.
|
||||
# Copied from python-config of the 2.7 release.
|
||||
|
||||
+# In this script, we should only use the following to retrieve configuration values:
|
||||
+# - `sysconfig.get_config_var`
|
||||
+# - `sysconfig.get_platform`
|
||||
+# This is because certain variables may return invalid data during cross-compilation, for example:
|
||||
+# - sys.prefix -> Use sysconfig.get_config_var("prefix") instead.
|
||||
+# - sysconfig.get_path("include") -> Don't use, it may return paths for native python, not our target python
|
||||
+# - os.name -> Use sysconfig.get_platform() for platform detection.
|
||||
+
|
||||
+
|
||||
import getopt
|
||||
import os
|
||||
import sys
|
||||
@@ -26,7 +35,7 @@
|
||||
|
||||
pyver = sysconfig.get_config_var("VERSION")
|
||||
getvar = sysconfig.get_config_var
|
||||
-abiflags = getattr(sys, "abiflags", "")
|
||||
+abiflags = getvar("ABIFLAGS")
|
||||
|
||||
opt_flags = [flag for (flag, val) in opts]
|
||||
|
||||
@@ -49,15 +58,14 @@
|
||||
|
||||
for opt in opt_flags:
|
||||
if opt == "--prefix":
|
||||
- print(to_unix_path(os.path.normpath(sys.prefix)))
|
||||
+ print(to_unix_path(os.path.normpath(getvar("prefix"))))
|
||||
|
||||
elif opt == "--exec-prefix":
|
||||
- print(to_unix_path(os.path.normpath(sys.exec_prefix)))
|
||||
+ print(to_unix_path(os.path.normpath(getvar("exec_prefix"))))
|
||||
|
||||
elif opt in ("--includes", "--cflags"):
|
||||
flags = [
|
||||
- "-I" + sysconfig.get_path("include"),
|
||||
- "-I" + sysconfig.get_path("platinclude"),
|
||||
+ "-I" + getvar("INCLUDEPY"),
|
||||
]
|
||||
if opt == "--cflags":
|
||||
flags.extend(getvar("CFLAGS").split())
|
||||
@@ -76,7 +84,7 @@
|
||||
if getvar("LIBPL") is not None:
|
||||
libs.insert(0, "-L" + getvar("LIBPL"))
|
||||
elif os.name == "nt":
|
||||
- libs.insert(0, "-L" + os.path.normpath(sys.prefix) + "/libs")
|
||||
+ libs.insert(0, "-L" + os.path.normpath(getvar("prefix")) + "/libs")
|
||||
if getvar("LINKFORSHARED") is not None:
|
||||
libs.extend(getvar("LINKFORSHARED").split())
|
||||
print(to_unix_path(" ".join(libs)))
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
prev,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Copied from: https://github.com/NixOS/nixpkgs/pull/275731
|
||||
isCross = prev.stdenv.hostPlatform != prev.stdenv.buildPlatform;
|
||||
|
||||
drv =
|
||||
if !isCross then
|
||||
prev.pwndbg_gdb
|
||||
else
|
||||
(prev.pwndbg_gdb.override { pythonSupport = true; }).overrideAttrs (old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
./gdb-fix-cross-python.patch
|
||||
];
|
||||
configureFlags = (old.configureFlags ++ [ ]) ++ [
|
||||
"--with-python=${prev.python3.pythonOnBuildForHost.interpreter}"
|
||||
];
|
||||
});
|
||||
in
|
||||
drv
|
||||
@ -1,107 +0,0 @@
|
||||
Subject: [PATCH] test1
|
||||
---
|
||||
Index: lldb/CMakeLists.txt
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt (revision 4740e097031d231cd39680c16a31771d22fe84c9)
|
||||
+++ b/CMakeLists.txt (date 1739005831013)
|
||||
@@ -60,7 +60,7 @@
|
||||
"Filename extension for native code python modules")
|
||||
|
||||
foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
|
||||
- if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
|
||||
+ if(NOT DEFINED ${var})
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
|
||||
Index: lldb/bindings/python/get-python-config.py
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
diff --git a/bindings/python/get-python-config.py b/bindings/python/get-python-config.py
|
||||
--- a/bindings/python/get-python-config.py (revision 4740e097031d231cd39680c16a31771d22fe84c9)
|
||||
+++ b/bindings/python/get-python-config.py (date 1738953843941)
|
||||
@@ -1,5 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
+# In this script, we should only use the following to retrieve configuration values:
|
||||
+# - `sysconfig.get_config_var`
|
||||
+# - `sysconfig.get_platform`
|
||||
+# - `sysconfig.get_path`
|
||||
+# This is because certain variables may return invalid data during cross-compilation, for example:
|
||||
+# - sys.prefix -> Use sysconfig.get_config_var("prefix") instead.
|
||||
+# - sys.executable -> Use sysconfig.get_config_var("EXENAME") instead.
|
||||
+# - os.name -> Use sysconfig.get_platform() for platform detection.
|
||||
+
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
@@ -32,20 +41,25 @@
|
||||
# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
|
||||
# to figure out where it is.
|
||||
try:
|
||||
- print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
|
||||
+ print(relpath_nodots(sysconfig.get_path("platlib"), sysconfig.get_config_var("prefix")))
|
||||
except ValueError:
|
||||
# Try to fall back to something reasonable if sysconfig's platlib
|
||||
# is outside of sys.prefix
|
||||
if os.name == "posix":
|
||||
- print("lib/python%d.%d/site-packages" % sys.version_info[:2])
|
||||
+ print("lib/python%s/site-packages" % sysconfig.get_config_var("VERSION"))
|
||||
elif os.name == "nt":
|
||||
print("Lib\\site-packages")
|
||||
else:
|
||||
raise
|
||||
elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
|
||||
tried = list()
|
||||
- exe = sys.executable
|
||||
- prefix = os.path.realpath(sys.prefix)
|
||||
+ exe = sysconfig.get_config_var("EXENAME")
|
||||
+ if not exe:
|
||||
+ # Fallback: 'EXENAME' is not available on Windows
|
||||
+ exe_name = "python" + sysconfig.get_config_var("VERSION") + sysconfig.get_config_var("EXE")
|
||||
+ exe = os.path.join(sysconfig.get_config_var("BINDIR"), exe_name)
|
||||
+
|
||||
+ prefix = os.path.realpath(sysconfig.get_config_var("prefix"))
|
||||
while True:
|
||||
try:
|
||||
print(relpath_nodots(exe, prefix))
|
||||
@@ -59,13 +73,13 @@
|
||||
continue
|
||||
else:
|
||||
print(
|
||||
- "Could not find a relative path to sys.executable under sys.prefix",
|
||||
+ "Could not find a relative path to sysconfig.get_config_var(\"EXENAME\") under sysconfig.get_config_var(\"prefix\")",
|
||||
file=sys.stderr,
|
||||
)
|
||||
for e in tried:
|
||||
print("tried:", e, file=sys.stderr)
|
||||
- print("realpath(sys.prefix):", prefix, file=sys.stderr)
|
||||
- print("sys.prefix:", sys.prefix, file=sys.stderr)
|
||||
+ print("realpath(sysconfig.get_config_var(\"prefix\")):", prefix, file=sys.stderr)
|
||||
+ print("sysconfig.get_config_var(\"prefix\"):", sysconfig.get_config_var("prefix"), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
|
||||
print(sysconfig.get_config_var("EXT_SUFFIX"))
|
||||
Index: lldb/cmake/modules/FindPythonAndSwig.cmake
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
diff --git a/cmake/modules/FindPythonAndSwig.cmake b/cmake/modules/FindPythonAndSwig.cmake
|
||||
--- a/cmake/modules/FindPythonAndSwig.cmake (revision 4740e097031d231cd39680c16a31771d22fe84c9)
|
||||
+++ b/cmake/modules/FindPythonAndSwig.cmake (date 1739019752496)
|
||||
@@ -8,6 +8,9 @@
|
||||
# Use PYTHON_HOME as a hint to find Python 3.
|
||||
set(Python3_ROOT_DIR "${PYTHON_HOME}")
|
||||
find_package(Python3 COMPONENTS Interpreter Development)
|
||||
+ if (DEFINED Python3_EXECUTABLE_NATIVE)
|
||||
+ set(Python3_EXECUTABLE "${Python3_EXECUTABLE_NATIVE}" CACHE STRING "Native Python3 executable" FORCE)
|
||||
+ endif()
|
||||
if(Python3_FOUND AND Python3_Interpreter_FOUND)
|
||||
|
||||
# The install name for the Python 3 framework in Xcode is relative to
|
||||
@ -1,65 +0,0 @@
|
||||
{
|
||||
prev,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Copied from: https://github.com/NixOS/nixpkgs/pull/375484
|
||||
isCross = prev.stdenv.hostPlatform != prev.stdenv.buildPlatform;
|
||||
lib = prev.lib;
|
||||
|
||||
tblgen = prev.pkgsBuildHost.callPackage ./tblgen.nix {
|
||||
release_version = builtins.elemAt (lib.strings.splitString "." prev.pwndbg_lldb.version) 0;
|
||||
version = prev.pwndbg_lldb.version;
|
||||
monorepoSrc = prev.pwndbg_lldb.passthru.monorepoSrc;
|
||||
};
|
||||
|
||||
drv =
|
||||
if !isCross then
|
||||
prev.pwndbg_lldb
|
||||
else
|
||||
prev.callPackage (
|
||||
{
|
||||
llvmPackages,
|
||||
llvmPackages_20,
|
||||
cmake,
|
||||
which,
|
||||
swig,
|
||||
lit,
|
||||
makeWrapper,
|
||||
ninja,
|
||||
python3,
|
||||
lua5_3,
|
||||
}:
|
||||
(prev.pwndbg_lldb.override {
|
||||
stdenv = llvmPackages.stdenv;
|
||||
# Out-of-memory when building with debuginfo enabled.. build use more than 32gb+ ram
|
||||
libclang = llvmPackages_20.libclang.overrideAttrs (old: {
|
||||
separateDebugInfo = false;
|
||||
});
|
||||
}).overrideAttrs
|
||||
(old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
./lldb-fix-cross-python.patch
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
which
|
||||
swig
|
||||
makeWrapper
|
||||
ninja
|
||||
];
|
||||
buildInputs = (old.buildInputs ++ [ ]) ++ [
|
||||
python3
|
||||
lua5_3
|
||||
];
|
||||
cmakeFlags = (old.cmakeFlags ++ [ ]) ++ [
|
||||
"-DPYTHON_HOME=${python3}"
|
||||
"-DPython3_EXECUTABLE_NATIVE=${python3.pythonOnBuildForHost.interpreter}"
|
||||
"-DLLVM_TABLEGEN=${tblgen}/bin/llvm-tblgen"
|
||||
"-DCLANG_TABLEGEN=${tblgen}/bin/clang-tblgen"
|
||||
"-DLLDB_TABLEGEN_EXE=${tblgen}/bin/lldb-tblgen"
|
||||
];
|
||||
})
|
||||
) { };
|
||||
in
|
||||
drv
|
||||
@ -1,134 +0,0 @@
|
||||
# Copied from: https://github.com/NixOS/nixpkgs/pull/377225
|
||||
{
|
||||
cmake,
|
||||
devExtraCmakeFlags ? [ ],
|
||||
lib,
|
||||
monorepoSrc ? null,
|
||||
ninja,
|
||||
patches ? [ ],
|
||||
python3,
|
||||
release_version,
|
||||
runCommand,
|
||||
src ? null,
|
||||
stdenv,
|
||||
version,
|
||||
clangPatches ? [ ],
|
||||
}:
|
||||
|
||||
let
|
||||
# This is a synthetic package which is not an official part of the llvm-project.
|
||||
# See https://github.com/NixOS/nixpkgs/pull/362384 for discussion.
|
||||
#
|
||||
# LLVM has tools that run at build time. In native builds, these are
|
||||
# built as a part of the usual build, but in cross builds they need to
|
||||
# come from buildPackages.
|
||||
#
|
||||
# In many scenarios this is a small problem because LLVM from
|
||||
# buildPackages is already available as a build; but if cross building a
|
||||
# version of LLVM which is not available (e.g. a new git commit of LLVM)
|
||||
# this results in two builds of LLVM and clang, one native and one for the
|
||||
# cross.
|
||||
#
|
||||
# Full builds of LLVM are expensive; and unnecessary in this scenario. We
|
||||
# don't need a native LLVM, only a native copy of the tools which run at
|
||||
# build time. This is only tablegen and related tooling, which are cheap
|
||||
# to build.
|
||||
pname = "llvm-tblgen";
|
||||
|
||||
src' =
|
||||
if monorepoSrc != null then
|
||||
runCommand "${pname}-src-${version}" { } (
|
||||
''
|
||||
mkdir -p "$out"
|
||||
''
|
||||
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/third-party "$out"
|
||||
''
|
||||
+ ''
|
||||
cp -r ${monorepoSrc}/llvm "$out"
|
||||
cp -r ${monorepoSrc}/clang "$out"
|
||||
cp -r ${monorepoSrc}/clang-tools-extra "$out"
|
||||
cp -r ${monorepoSrc}/mlir "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
''
|
||||
)
|
||||
else
|
||||
src;
|
||||
|
||||
self = stdenv.mkDerivation (finalAttrs: rec {
|
||||
inherit pname version patches;
|
||||
|
||||
src = src';
|
||||
sourceRoot = "${src.name}/llvm";
|
||||
|
||||
postPatch = ''
|
||||
(
|
||||
cd ../clang
|
||||
chmod u+rwX -R .
|
||||
for p in ${toString clangPatches}
|
||||
do
|
||||
patch -p1 < $p
|
||||
done
|
||||
)
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
ninja
|
||||
python3
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
# Projects with tablegen-like tools.
|
||||
"-DLLVM_ENABLE_PROJECTS=${
|
||||
lib.concatStringsSep ";" (
|
||||
[
|
||||
"llvm"
|
||||
"clang"
|
||||
"clang-tools-extra"
|
||||
"lldb"
|
||||
]
|
||||
++ lib.optionals (lib.versionAtLeast release_version "16") [
|
||||
"mlir"
|
||||
]
|
||||
)
|
||||
}"
|
||||
]
|
||||
# LLDB test suite requires libc++ on darwin, but we need compile only lldb-tblgen
|
||||
# These flags are needed only for evaluating the CMake file.
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
"-DLLDB_INCLUDE_TESTS=OFF"
|
||||
"-DLIBXML2_INCLUDE_DIR=/non-existent"
|
||||
]
|
||||
++ devExtraCmakeFlags;
|
||||
|
||||
# List of tablegen targets.
|
||||
ninjaFlags = [
|
||||
"clang-tblgen"
|
||||
"llvm-tblgen"
|
||||
"lldb-tblgen"
|
||||
]
|
||||
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||
"clang-tidy-confusable-chars-gen"
|
||||
]
|
||||
++ lib.optionals (lib.versionAtLeast release_version "16") [
|
||||
"mlir-tblgen"
|
||||
]
|
||||
++
|
||||
lib.optionals ((lib.versionAtLeast release_version "15") && (lib.versionOlder release_version "20"))
|
||||
[
|
||||
"clang-pseudo-gen" # Removed in LLVM 20 @ ed8f78827895050442f544edef2933a60d4a7935.
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
# Remove useless files
|
||||
rm -f bin/{lldb-dotest,lldb-repro,llvm-lit,update_core_linalg_named_ops.sh}
|
||||
|
||||
cp -ar bin $out/bin
|
||||
'';
|
||||
});
|
||||
in
|
||||
self
|
||||
Loading…
Reference in new issue