Skip to content

Commit 5dbc8a3

Browse files
authored
python3Packages.warp-lang: 1.7.2.post1 -> 1.8.0 (#422104)
2 parents 2727879 + 780f0f4 commit 5dbc8a3

5 files changed

Lines changed: 71 additions & 60 deletions

File tree

pkgs/development/python-modules/warp-lang/darwin-libcxx.patch

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
diff --git a/warp/build_dll.py b/warp/build_dll.py
2-
index 4d411e1b..a9304c6a 100644
2+
index 2218ff13..53786017 100644
33
--- a/warp/build_dll.py
44
+++ b/warp/build_dll.py
5-
@@ -316,6 +316,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
5+
@@ -408,6 +408,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
6+
cpp_includes += f' -I"{warp_home_path.parent}/_build/host-deps/llvm-project/release-{arch}/include"'
67
cuda_includes = f' -I"{cuda_home}/include"' if cu_path else ""
78
includes = cpp_includes + cuda_includes
8-
99
+ includes += " -isystem @LIBCXX_DEV@/include/c++/v1"
10-
+
10+
1111
if sys.platform == "darwin":
1212
version = f"--target={arch}-apple-macos11"
13-
else:
14-
@@ -345,6 +347,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
15-
build_cmd = f'g++ {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
13+
@@ -441,6 +442,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
14+
build_cmd = f'{cpp_compiler} {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
1615
run_cmd(build_cmd)
1716

1817
+ ld_inputs.append('-L"@LIBCXX_LIB@/lib" -lc++')
19-
+
2018
if cu_path:
2119
cu_out = cu_path + ".o"
2220

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
diff --git a/build_llvm.py b/build_llvm.py
2-
index 9d5a26a7..0be02a89 100644
2+
index aee0a9f1..bf281f6d 100644
33
--- a/build_llvm.py
44
+++ b/build_llvm.py
5-
@@ -389,15 +389,4 @@ def build_warp_clang_for_arch(args, lib_name, arch):
5+
@@ -402,16 +402,4 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
66

7-
8-
def build_warp_clang(args, lib_name):
7+
def build_warp_clang(args, lib_name: str) -> None:
8+
"""Build the CPU-only Warp library using Clang/LLVM."""
9+
-
910
- if sys.platform == "darwin":
1011
- # create a universal binary by combining x86-64 and AArch64 builds
1112
- build_warp_clang_for_arch(args, lib_name + "-x86_64", "x86_64")
@@ -20,31 +21,31 @@ index 9d5a26a7..0be02a89 100644
2021
- build_warp_clang_for_arch(args, lib_name, machine_architecture())
2122
+ build_warp_clang_for_arch(args, lib_name, machine_architecture())
2223
diff --git a/warp/build_dll.py b/warp/build_dll.py
23-
index 4d411e1b..4cf4a6c2 100644
24+
index 2218ff13..c0d978ce 100644
2425
--- a/warp/build_dll.py
2526
+++ b/warp/build_dll.py
26-
@@ -317,7 +317,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
27+
@@ -410,7 +410,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
2728
includes = cpp_includes + cuda_includes
2829

2930
if sys.platform == "darwin":
3031
- version = f"--target={arch}-apple-macos11"
3132
+ version = ""
3233
else:
33-
version = "-fabi-version=13" # GCC 8.2+
34+
if cpp_compiler == "g++":
35+
version = "-fabi-version=13" # GCC 8.2+
36+
@@ -491,14 +491,4 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
3437

35-
@@ -392,14 +392,4 @@ def build_dll(args, dll_path, cpp_paths, cu_path, libs=None):
36-
if libs is None:
37-
libs = []
3838

39+
def build_dll(args, dll_path, cpp_paths, cu_path, libs=None):
3940
- if sys.platform == "darwin":
4041
- # create a universal binary by combining x86-64 and AArch64 builds
41-
- build_dll_for_arch(args, dll_path + "-x86_64", cpp_paths, cu_path, libs, "x86_64")
42-
- build_dll_for_arch(args, dll_path + "-aarch64", cpp_paths, cu_path, libs, "aarch64")
42+
- build_dll_for_arch(args, dll_path + "-x86_64", cpp_paths, cu_path, "x86_64", libs)
43+
- build_dll_for_arch(args, dll_path + "-aarch64", cpp_paths, cu_path, "aarch64", libs)
4344
-
4445
- run_cmd(f"lipo -create -output {dll_path} {dll_path}-x86_64 {dll_path}-aarch64")
4546
- os.remove(f"{dll_path}-x86_64")
4647
- os.remove(f"{dll_path}-aarch64")
4748
-
4849
- else:
49-
- build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture())
50-
+ build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture())
50+
- build_dll_for_arch(args, dll_path, cpp_paths, cu_path, machine_architecture(), libs)
51+
+ build_dll_for_arch(args, dll_path, cpp_paths, cu_path, machine_architecture(), libs)

pkgs/development/python-modules/warp-lang/default.nix

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ let
3737
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else args.stdenv;
3838
stdenv = builtins.throw "Use effectiveStdenv instead of stdenv directly, as it may be replaced by cudaPackages.backendStdenv";
3939

40-
version = "1.7.2.post1";
40+
version = "1.8.0";
4141

4242
libmathdx = effectiveStdenv.mkDerivation (finalAttrs: {
4343
# NOTE: The version used should match the version Warp requires:
44-
# https://github.com/NVIDIA/warp/blob/4ad209076ce09668b18dedc74dce0d5cf8b9e409/deps/libmathdx-deps.packman.xml
44+
# https://github.com/NVIDIA/warp/blob/${version}/deps/libmathdx-deps.packman.xml
4545
pname = "libmathdx";
46-
version = "0.1.2";
46+
version = "0.2.1";
4747

4848
outputs = [
4949
"out"
@@ -59,9 +59,11 @@ let
5959
effectiveStdenv.hostPlatform.parsed.cpu.name
6060
finalAttrs.version
6161
];
62+
63+
# nix-hash --type sha256 --to-sri $(nix-prefetch-url "https://...")
6264
hashes = {
63-
aarch64-linux = "sha256-7HEXfzxPF62q/7pdZidj4eO09u588yxcpSu/bWot/9A=";
64-
x86_64-linux = "sha256-MImBFv+ooRSUqdL/YEe/bJIcVBnHMCk7SLS5eSeh0cQ=";
65+
aarch64-linux = "sha256-smB13xev2TG1xUx4+06KRgYEnPMczpjBOOX7uC1APbE=";
66+
x86_64-linux = "sha256-+3TbLuL5Y2flLRicQgPVLs8KZQBqNYJYJ8P3etgX7g0=";
6567
};
6668
in
6769
lib.mapNullable (
@@ -76,12 +78,11 @@ let
7678
dontConfigure = true;
7779
dontBuild = true;
7880

79-
# NOTE: The leading component is stripped because the 0.1.2 release is within the `libmathdx` directory.
8081
installPhase = ''
8182
runHook preInstall
8283
8384
mkdir -p "$out"
84-
tar -xzf "$src" --strip-components=1 -C "$out"
85+
tar -xzf "$src" -C "$out"
8586
8687
mkdir -p "$static"
8788
moveToOutput "lib/libmathdx_static.a" "$static"
@@ -138,7 +139,7 @@ buildPythonPackage {
138139
owner = "NVIDIA";
139140
repo = "warp";
140141
tag = "v${version}";
141-
hash = "sha256-cT0CrD71nNZnQMimGrmnSQl6RQx4MiUv2xBFPWNI/0s=";
142+
hash = "sha256-zCRB92acxOiIFGjfRh2Cr1qq8pbhm+Rd011quMP/D88=";
142143
};
143144

144145
patches =
@@ -161,16 +162,21 @@ buildPythonPackage {
161162

162163
postPatch =
163164
# Patch build_dll.py to use our gencode flags rather than NVIDIA's very broad defaults.
164-
# NOTE: After 1.7.2, patching will need to be updated like this:
165-
# https://github.com/ConnorBaker/cuda-packages/blob/2fc8ba8c37acee427a94cdd1def55c2ec701ad82/pkgs/development/python-modules/warp/default.nix#L56-L65
166165
lib.optionalString cudaSupport ''
167166
nixLog "patching $PWD/warp/build_dll.py to use our gencode flags"
168167
substituteInPlace "$PWD/warp/build_dll.py" \
169-
--replace-fail \
170-
'nvcc_opts = gencode_opts + [' \
171-
'nvcc_opts = [ ${
172-
lib.concatMapStringsSep ", " (gencodeString: ''"${gencodeString}"'') cudaPackages.flags.gencode
173-
}, '
168+
--replace-fail \
169+
'*gencode_opts,' \
170+
'${
171+
lib.concatMapStringsSep ", " (gencodeString: ''"${gencodeString}"'') cudaPackages.flags.gencode
172+
},' \
173+
--replace-fail \
174+
'*clang_arch_flags,' \
175+
'${
176+
lib.concatMapStringsSep ", " (
177+
realArch: ''"--cuda-gpu-arch=${realArch}"''
178+
) cudaPackages.flags.realArches
179+
},'
174180
''
175181
# Patch build_dll.py to use dynamic libraries rather than static ones.
176182
# NOTE: We do not patch the `nvptxcompiler_static` path because it is not available as a dynamic library.
@@ -193,11 +199,6 @@ buildPythonPackage {
193199
'-lmathdx_static' \
194200
'-lmathdx'
195201
''
196-
+ ''
197-
nixLog "patching $PWD/warp/build_dll.py to use our C++ compiler"
198-
substituteInPlace "$PWD/warp/build_dll.py" \
199-
--replace-fail "g++" "c++"
200-
''
201202
# Broken tests on aarch64. Since unittest doesn't support disabling a
202203
# single test, and pytest isn't compatible, we patch the test file directly
203204
# instead.
@@ -210,6 +211,14 @@ buildPythonPackage {
210211
'add_function_test(TestFem, "test_integrate_gradient", test_integrate_gradient, devices=devices)' \
211212
""
212213
''
214+
# AssertionError: 0.4082476496696472 != 0.40824246406555176 within 5 places
215+
+ lib.optionalString effectiveStdenv.hostPlatform.isDarwin ''
216+
nixLog "patching $PWD/warp/tests/test_fem.py to disable broken tests on darwin"
217+
substituteInPlace "$PWD/warp/tests/test_codegen.py" \
218+
--replace-fail \
219+
'places=5' \
220+
'places=4'
221+
''
213222
# These tests fail on CPU and CUDA.
214223
+ ''
215224
nixLog "patching $PWD/warp/tests/test_reload.py to disable broken tests"
@@ -261,7 +270,10 @@ buildPythonPackage {
261270
preBuild =
262271
let
263272
buildOptions =
264-
lib.optionals (!standaloneSupport) [
273+
lib.optionals effectiveStdenv.cc.isClang [
274+
"--clang_build_toolchain"
275+
]
276+
++ lib.optionals (!standaloneSupport) [
265277
"--no_standalone"
266278
]
267279
++ lib.optionals cudaSupport [
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/build_llvm.py b/build_llvm.py
2-
index 9d5a26a7..839909ad 100644
2+
index aee0a9f1..5e1c3557 100644
33
--- a/build_llvm.py
44
+++ b/build_llvm.py
5-
@@ -161,7 +161,6 @@ def build_from_source_for_arch(args, arch, llvm_source):
5+
@@ -171,7 +171,6 @@ def build_llvm_clang_from_source_for_arch(args, arch: str, llvm_source: str) ->
66
"-D", "LLVM_INCLUDE_TESTS=FALSE",
77
"-D", "LLVM_INCLUDE_TOOLS=TRUE", # Needed by Clang
88
"-D", "LLVM_INCLUDE_UTILS=FALSE",
@@ -11,15 +11,15 @@ index 9d5a26a7..839909ad 100644
1111
"-D", f"LLVM_HOST_TRIPLE={host_triple}",
1212
"-D", f"CMAKE_OSX_ARCHITECTURES={osx_architectures}",
1313
diff --git a/warp/build_dll.py b/warp/build_dll.py
14-
index 4d411e1b..4177725b 100644
14+
index 2218ff13..2354f69f 100644
1515
--- a/warp/build_dll.py
1616
+++ b/warp/build_dll.py
17-
@@ -321,7 +321,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
18-
else:
19-
version = "-fabi-version=13" # GCC 8.2+
20-
21-
- 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} '
22-
+ 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} '
23-
17+
@@ -417,7 +417,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
18+
else:
19+
version = ""
20+
21+
- 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} '
22+
+ 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} '
23+
2424
if mode == "debug":
2525
cpp_flags += "-O0 -g -D_DEBUG -DWP_ENABLE_DEBUG=1 -fkeep-inline-functions"

pkgs/development/python-modules/warp-lang/standalone-llvm.patch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/build_llvm.py b/build_llvm.py
2-
index 9d5a26a7..3663e9c9 100644
2+
index aee0a9f1..6b9806c9 100644
33
--- a/build_llvm.py
44
+++ b/build_llvm.py
5-
@@ -338,25 +338,19 @@ def build_warp_clang_for_arch(args, lib_name, arch):
5+
@@ -350,25 +350,19 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
66

77
clang_dll_path = os.path.join(build_path, f"bin/{lib_name}")
88

@@ -36,7 +36,7 @@ index 9d5a26a7..3663e9c9 100644
3636
else:
3737
libs = [f"-l{lib[3:-2]}" for lib in libs if os.path.splitext(lib)[1] == ".a"]
3838
if sys.platform == "darwin":
39-
@@ -364,7 +358,8 @@ def build_warp_clang_for_arch(args, lib_name, arch):
39+
@@ -376,7 +370,8 @@ def build_warp_clang_for_arch(args, lib_name: str, arch: str) -> None:
4040
else:
4141
libs.insert(0, "-Wl,--start-group")
4242
libs.append("-Wl,--end-group")
@@ -47,13 +47,13 @@ index 9d5a26a7..3663e9c9 100644
4747
libs.append("-ldl")
4848
if sys.platform != "darwin":
4949
diff --git a/warp/build_dll.py b/warp/build_dll.py
50-
index 4d411e1b..95fb7eaf 100644
50+
index 2218ff13..3fcf5796 100644
5151
--- a/warp/build_dll.py
5252
+++ b/warp/build_dll.py
53-
@@ -311,8 +311,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
54-
run_cmd(link_cmd)
53+
@@ -404,8 +404,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, arch, libs: Optional[
54+
cuda_compiler = "clang++" if getattr(args, "clang_build_toolchain", False) else "nvcc"
55+
cpp_compiler = "clang++" if getattr(args, "clang_build_toolchain", False) else "g++"
5556

56-
else:
5757
- cpp_includes = f' -I"{warp_home_path.parent}/external/llvm-project/out/install/{mode}-{arch}/include"'
5858
- cpp_includes += f' -I"{warp_home_path.parent}/_build/host-deps/llvm-project/release-{arch}/include"'
5959
+ cpp_includes = ' -I"@LLVM_DEV@/include"'

0 commit comments

Comments
 (0)