python3Packages.warp-lang: 1.7.2.post1 -> 1.8.0 (#422104)

This commit is contained in:
Connor Baker
2025-07-07 22:48:19 -07:00
committed by GitHub
5 changed files with 71 additions and 60 deletions
@@ -1,22 +1,20 @@
diff --git a/warp/build_dll.py b/warp/build_dll.py
index 4d411e1b..a9304c6a 100644
index 2218ff13..53786017 100644
--- a/warp/build_dll.py
+++ b/warp/build_dll.py
@@ -316,6 +316,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
@@ -408,6 +408,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
cpp_includes += f' -I"{warp_home_path.parent}/_build/host-deps/llvm-project/release-{arch}/include"'
cuda_includes = f' -I"{cuda_home}/include"' if cu_path else ""
includes = cpp_includes + cuda_includes
+ includes += " -isystem @LIBCXX_DEV@/include/c++/v1"
+
if sys.platform == "darwin":
version = f"--target={arch}-apple-macos11"
else:
@@ -345,6 +347,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
build_cmd = f'g++ {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
@@ -441,6 +442,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
build_cmd = f'{cpp_compiler} {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
run_cmd(build_cmd)
+ ld_inputs.append('-L"@LIBCXX_LIB@/lib" -lc++')
+
if cu_path:
cu_out = cu_path + ".o"
@@ -1,11 +1,12 @@
diff --git a/build_llvm.py b/build_llvm.py
index 9d5a26a7..0be02a89 100644
index aee0a9f1..bf281f6d 100644
--- a/build_llvm.py
+++ b/build_llvm.py
@@ -389,15 +389,4 @@ def build_warp_clang_for_arch(args, lib_name, arch):
@@ -402,16 +402,4 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
def build_warp_clang(args, lib_name):
def build_warp_clang(args, lib_name: str) -> None:
"""Build the CPU-only Warp library using Clang/LLVM."""
-
- if sys.platform == "darwin":
- # create a universal binary by combining x86-64 and AArch64 builds
- build_warp_clang_for_arch(args, lib_name + "-x86_64", "x86_64")
@@ -20,31 +21,31 @@ index 9d5a26a7..0be02a89 100644
- build_warp_clang_for_arch(args, lib_name, machine_architecture())
+ build_warp_clang_for_arch(args, lib_name, machine_architecture())
diff --git a/warp/build_dll.py b/warp/build_dll.py
index 4d411e1b..4cf4a6c2 100644
index 2218ff13..c0d978ce 100644
--- a/warp/build_dll.py
+++ b/warp/build_dll.py
@@ -317,7 +317,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
@@ -410,7 +410,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
includes = cpp_includes + cuda_includes
if sys.platform == "darwin":
- version = f"--target={arch}-apple-macos11"
+ version = ""
else:
version = "-fabi-version=13" # GCC 8.2+
if cpp_compiler == "g++":
version = "-fabi-version=13" # GCC 8.2+
@@ -491,14 +491,4 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
@@ -392,14 +392,4 @@ def build_dll(args, dll_path, cpp_paths, cu_path, libs=None):
if libs is None:
libs = []
def build_dll(args, dll_path, cpp_paths, cu_path, libs=None):
- if sys.platform == "darwin":
- # create a universal binary by combining x86-64 and AArch64 builds
- build_dll_for_arch(args, dll_path + "-x86_64", cpp_paths, cu_path, libs, "x86_64")
- build_dll_for_arch(args, dll_path + "-aarch64", cpp_paths, cu_path, libs, "aarch64")
- build_dll_for_arch(args, dll_path + "-x86_64", cpp_paths, cu_path, "x86_64", libs)
- build_dll_for_arch(args, dll_path + "-aarch64", cpp_paths, cu_path, "aarch64", libs)
-
- run_cmd(f"lipo -create -output {dll_path} {dll_path}-x86_64 {dll_path}-aarch64")
- os.remove(f"{dll_path}-x86_64")
- os.remove(f"{dll_path}-aarch64")
-
- else:
- build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture())
+ build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture())
- build_dll_for_arch(args, dll_path, cpp_paths, cu_path, machine_architecture(), libs)
+ build_dll_for_arch(args, dll_path, cpp_paths, cu_path, machine_architecture(), libs)
@@ -37,13 +37,13 @@ let
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else args.stdenv;
stdenv = builtins.throw "Use effectiveStdenv instead of stdenv directly, as it may be replaced by cudaPackages.backendStdenv";
version = "1.7.2.post1";
version = "1.8.0";
libmathdx = effectiveStdenv.mkDerivation (finalAttrs: {
# NOTE: The version used should match the version Warp requires:
# https://github.com/NVIDIA/warp/blob/4ad209076ce09668b18dedc74dce0d5cf8b9e409/deps/libmathdx-deps.packman.xml
# https://github.com/NVIDIA/warp/blob/${version}/deps/libmathdx-deps.packman.xml
pname = "libmathdx";
version = "0.1.2";
version = "0.2.1";
outputs = [
"out"
@@ -59,9 +59,11 @@ let
effectiveStdenv.hostPlatform.parsed.cpu.name
finalAttrs.version
];
# nix-hash --type sha256 --to-sri $(nix-prefetch-url "https://...")
hashes = {
aarch64-linux = "sha256-7HEXfzxPF62q/7pdZidj4eO09u588yxcpSu/bWot/9A=";
x86_64-linux = "sha256-MImBFv+ooRSUqdL/YEe/bJIcVBnHMCk7SLS5eSeh0cQ=";
aarch64-linux = "sha256-smB13xev2TG1xUx4+06KRgYEnPMczpjBOOX7uC1APbE=";
x86_64-linux = "sha256-+3TbLuL5Y2flLRicQgPVLs8KZQBqNYJYJ8P3etgX7g0=";
};
in
lib.mapNullable (
@@ -76,12 +78,11 @@ let
dontConfigure = true;
dontBuild = true;
# NOTE: The leading component is stripped because the 0.1.2 release is within the `libmathdx` directory.
installPhase = ''
runHook preInstall
mkdir -p "$out"
tar -xzf "$src" --strip-components=1 -C "$out"
tar -xzf "$src" -C "$out"
mkdir -p "$static"
moveToOutput "lib/libmathdx_static.a" "$static"
@@ -138,7 +139,7 @@ buildPythonPackage {
owner = "NVIDIA";
repo = "warp";
tag = "v${version}";
hash = "sha256-cT0CrD71nNZnQMimGrmnSQl6RQx4MiUv2xBFPWNI/0s=";
hash = "sha256-zCRB92acxOiIFGjfRh2Cr1qq8pbhm+Rd011quMP/D88=";
};
patches =
@@ -161,16 +162,21 @@ buildPythonPackage {
postPatch =
# Patch build_dll.py to use our gencode flags rather than NVIDIA's very broad defaults.
# NOTE: After 1.7.2, patching will need to be updated like this:
# https://github.com/ConnorBaker/cuda-packages/blob/2fc8ba8c37acee427a94cdd1def55c2ec701ad82/pkgs/development/python-modules/warp/default.nix#L56-L65
lib.optionalString cudaSupport ''
nixLog "patching $PWD/warp/build_dll.py to use our gencode flags"
substituteInPlace "$PWD/warp/build_dll.py" \
--replace-fail \
'nvcc_opts = gencode_opts + [' \
'nvcc_opts = [ ${
lib.concatMapStringsSep ", " (gencodeString: ''"${gencodeString}"'') cudaPackages.flags.gencode
}, '
--replace-fail \
'*gencode_opts,' \
'${
lib.concatMapStringsSep ", " (gencodeString: ''"${gencodeString}"'') cudaPackages.flags.gencode
},' \
--replace-fail \
'*clang_arch_flags,' \
'${
lib.concatMapStringsSep ", " (
realArch: ''"--cuda-gpu-arch=${realArch}"''
) cudaPackages.flags.realArches
},'
''
# Patch build_dll.py to use dynamic libraries rather than static ones.
# NOTE: We do not patch the `nvptxcompiler_static` path because it is not available as a dynamic library.
@@ -193,11 +199,6 @@ buildPythonPackage {
'-lmathdx_static' \
'-lmathdx'
''
+ ''
nixLog "patching $PWD/warp/build_dll.py to use our C++ compiler"
substituteInPlace "$PWD/warp/build_dll.py" \
--replace-fail "g++" "c++"
''
# Broken tests on aarch64. Since unittest doesn't support disabling a
# single test, and pytest isn't compatible, we patch the test file directly
# instead.
@@ -210,6 +211,14 @@ buildPythonPackage {
'add_function_test(TestFem, "test_integrate_gradient", test_integrate_gradient, devices=devices)' \
""
''
# AssertionError: 0.4082476496696472 != 0.40824246406555176 within 5 places
+ lib.optionalString effectiveStdenv.hostPlatform.isDarwin ''
nixLog "patching $PWD/warp/tests/test_fem.py to disable broken tests on darwin"
substituteInPlace "$PWD/warp/tests/test_codegen.py" \
--replace-fail \
'places=5' \
'places=4'
''
# These tests fail on CPU and CUDA.
+ ''
nixLog "patching $PWD/warp/tests/test_reload.py to disable broken tests"
@@ -261,7 +270,10 @@ buildPythonPackage {
preBuild =
let
buildOptions =
lib.optionals (!standaloneSupport) [
lib.optionals effectiveStdenv.cc.isClang [
"--clang_build_toolchain"
]
++ lib.optionals (!standaloneSupport) [
"--no_standalone"
]
++ lib.optionals cudaSupport [
@@ -1,8 +1,8 @@
diff --git a/build_llvm.py b/build_llvm.py
index 9d5a26a7..839909ad 100644
index aee0a9f1..5e1c3557 100644
--- a/build_llvm.py
+++ b/build_llvm.py
@@ -161,7 +161,6 @@ def build_from_source_for_arch(args, arch, llvm_source):
@@ -171,7 +171,6 @@ def build_llvm_clang_from_source_for_arch(args, arch: str, llvm_source: str) ->
"-D", "LLVM_INCLUDE_TESTS=FALSE",
"-D", "LLVM_INCLUDE_TOOLS=TRUE", # Needed by Clang
"-D", "LLVM_INCLUDE_UTILS=FALSE",
@@ -11,15 +11,15 @@ index 9d5a26a7..839909ad 100644
"-D", f"LLVM_HOST_TRIPLE={host_triple}",
"-D", f"CMAKE_OSX_ARCHITECTURES={osx_architectures}",
diff --git a/warp/build_dll.py b/warp/build_dll.py
index 4d411e1b..4177725b 100644
index 2218ff13..2354f69f 100644
--- a/warp/build_dll.py
+++ b/warp/build_dll.py
@@ -321,7 +321,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
else:
version = "-fabi-version=13" # GCC 8.2+
- cpp_flags = f'{version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -D_GLIBCXX_USE_CXX11_ABI=0 -I"{native_dir}" {includes} '
+ cpp_flags = f'{version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -I"{native_dir}" {includes} '
@@ -417,7 +417,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
else:
version = ""
- cpp_flags = f'-Werror -Wuninitialized {version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -D_GLIBCXX_USE_CXX11_ABI=0 -I"{native_dir}" {includes} '
+ cpp_flags = f'-Werror -Wuninitialized {version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -I"{native_dir}" {includes} '
if mode == "debug":
cpp_flags += "-O0 -g -D_DEBUG -DWP_ENABLE_DEBUG=1 -fkeep-inline-functions"
@@ -1,8 +1,8 @@
diff --git a/build_llvm.py b/build_llvm.py
index 9d5a26a7..3663e9c9 100644
index aee0a9f1..6b9806c9 100644
--- a/build_llvm.py
+++ b/build_llvm.py
@@ -338,25 +338,19 @@ def build_warp_clang_for_arch(args, lib_name, arch):
@@ -350,25 +350,19 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
clang_dll_path = os.path.join(build_path, f"bin/{lib_name}")
@@ -36,7 +36,7 @@ index 9d5a26a7..3663e9c9 100644
else:
libs = [f"-l{lib[3:-2]}" for lib in libs if os.path.splitext(lib)[1] == ".a"]
if sys.platform == "darwin":
@@ -364,7 +358,8 @@ def build_warp_clang_for_arch(args, lib_name, arch):
@@ -376,7 +370,8 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
else:
libs.insert(0, "-Wl,--start-group")
libs.append("-Wl,--end-group")
@@ -47,13 +47,13 @@ index 9d5a26a7..3663e9c9 100644
libs.append("-ldl")
if sys.platform != "darwin":
diff --git a/warp/build_dll.py b/warp/build_dll.py
index 4d411e1b..95fb7eaf 100644
index 2218ff13..3fcf5796 100644
--- a/warp/build_dll.py
+++ b/warp/build_dll.py
@@ -311,8 +311,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
run_cmd(link_cmd)
@@ -404,8 +404,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
cuda_compiler = "clang++" if getattr(args, "clang_build_toolchain", False) else "nvcc"
cpp_compiler = "clang++" if getattr(args, "clang_build_toolchain", False) else "g++"
else:
- cpp_includes = f' -I"{warp_home_path.parent}/external/llvm-project/out/install/{mode}-{arch}/include"'
- cpp_includes += f' -I"{warp_home_path.parent}/_build/host-deps/llvm-project/release-{arch}/include"'
+ cpp_includes = ' -I"@LLVM_DEV@/include"'