From f96f1495bc777cbae06daf4e719d049ee242b4d4 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Fri, 1 May 2026 01:57:20 +0000 Subject: [PATCH] cuda.core: add C++17 standard flag and use -O2 optimization Pass -std=c++17 (Linux) / /std:c++17 (Windows) for all builds, and use -O2 instead of -O3 for non-debug Linux builds. Partially addresses #1882. Co-Authored-By: Claude Opus 4.6 (1M context) --- cuda_core/build_hooks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cuda_core/build_hooks.py b/cuda_core/build_hooks.py index 16d393344b8..812c5a76a1d 100644 --- a/cuda_core/build_hooks.py +++ b/cuda_core/build_hooks.py @@ -167,15 +167,17 @@ def get_sources(mod_name): extra_link_args = [] extra_cythonize_kwargs = {} if sys.platform == "win32": + extra_compile_args += ["/std:c++17"] if debug: raise RuntimeError("Debuggable builds are not supported on Windows.") else: + extra_compile_args += ["-std=c++17"] if debug: extra_cythonize_kwargs["gdb_debug"] = True extra_compile_args += ["-g", "-O0"] extra_compile_args += ["-D _GLIBCXX_ASSERTIONS"] else: - extra_compile_args += ["-O3"] + extra_compile_args += ["-O2"] extra_link_args += ["-Wl,--strip-all"] if COMPILE_FOR_COVERAGE: # CYTHON_TRACE_NOGIL indicates to trace nogil functions. It is not