From f2a026dc9eb1b6738058261326190f3c53ee4f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Mon, 10 Aug 2026 18:25:32 +0200 Subject: [PATCH] fix: reach glm via -I flags instead of include_dirs to avoid hipify mutation The ROCm branch of get_extensions() built an include_dirs list that never contained the vendored gsplat/cuda/csrc/third_party/glm submodule path at all (unlike the CUDA branch, which already includes it), so every cxx and hipcc invocation failed with "glm/gtc/type_ptr.hpp: No such file or directory". Simply adding glm to include_dirs is not enough: CUDAExtension() forwards its include_dirs kwarg into torch.utils.hipify.hipify_python.hipify(header_include_dirs=include_dirs), which walks every header reachable from those directories and rewrites CUDA-specific tokens in place (e.g. __CUDACC__ -> __HIPCC__). Doing that to glm's own glm/simd/platform.h flips its "#elif defined(__HIPCC__)" branch on before reaching its real "#elif defined(__HIP__)" branch, so glm concludes it's being compiled by an unversioned CUDA compiler and aborts with "GLM requires CUDA 7.0 or higher" / "GLM_COMPILER undefined", cascading into "no matching function" errors on every glm::mat/vec call in the HIP kernels. Fix: leave glm out of include_dirs (so hipify never touches it) and instead pass its path as an explicit -I flag on both extra_compile_args["cxx"] (plain .cpp path) and hipcc_flags, which is aliased into extra_compile_args["nvcc"] (.hip path via hipcc). Both compile paths now resolve glm's real, unmutated headers. Verified: full pip install run no longer produces any "glm/gtc/type_ptr.hpp: No such file" or "GLM requires CUDA" errors on gfx1151 (confirmed via git -C gsplat/cuda/csrc/third_party/glm diff showing zero mutation after a build). --- setup.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/setup.py b/setup.py index 16f3821..5d2b1b4 100644 --- a/setup.py +++ b/setup.py @@ -223,6 +223,9 @@ def get_extensions(): # Its still nvcc flags that are used for HIP compilation extra_compile_args["nvcc"] = hipcc_flags current_dir = pathlib.Path(__file__).parent.resolve() + glm_include_path = osp.join( + current_dir, "gsplat", "cuda", "csrc", "third_party", "glm" + ) include_dirs = [ osp.join(current_dir, "gsplat", "cuda", "include"), @@ -232,6 +235,31 @@ def get_extensions(): f"/opt/rocm/include", ] + # Deliberately NOT adding glm_include_path to include_dirs above. + # torch.utils.cpp_extension.CUDAExtension() forwards its + # include_dirs kwarg straight into hipify_python.hipify(..., + # header_include_dirs=include_dirs), which then walks and + # *rewrites* every header found under those directories (e.g. + # __CUDACC__ -> __HIPCC__). Doing that to the vendored glm + # submodule corrupts glm's own compiler-detection macros in + # glm/simd/platform.h: it flips the "#elif defined(__HIPCC__)" + # branch on (true under hipcc) *before* glm's real "#elif + # defined(__HIP__)" branch is reached, so glm thinks it's being + # compiled by CUDA-with-no-CUDACC-version and aborts with + # "GLM requires CUDA 7.0 or higher" / GLM_COMPILER undefined, + # which cascades into "no matching function" errors for every + # glm::mat/vec op. Confirmed via `git -C third_party/glm diff` + # after a build showing exactly that mutation. + # + # Instead, reach glm only through explicit -I flags on the + # compile-arg lists, which are never passed to hipify's + # header_include_dirs scan and only reach the actual compiler + # invocation. This is done for both the cxx path (plain .cpp + # sources) and the nvcc/hipcc path (.hip sources) so glm resolves + # for both compilers without also being mutated. + extra_compile_args["cxx"] += [f"-I{glm_include_path}"] + hipcc_flags += [f"-I{glm_include_path}"] + extension = CUDAExtension( # Make sure this matches your package structure "gsplat.csrc", # This changes the extension module name to be more standard