From 81692444ecbca6455adf6443adb136533f99f782 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Wed, 8 Apr 2026 17:38:51 +0000 Subject: [PATCH] Strip debug symbols from cuda-core Linux wheels Add -Wl,--strip-all to extra_link_args for wheel builds on Linux, matching the existing behavior in cuda_bindings/build_hooks.py. Without stripping, the 0.7.0 Linux wheel is ~30 MB (103 MB extracted) because every .so ships with debug_info. After stripping, extracted size drops from 103 MB to ~11 MB, bringing the wheel in line with the ~4-5 MB Windows wheels. Closes #1881 Co-Authored-By: Claude Opus 4.6 (1M context) --- cuda_core/build_hooks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cuda_core/build_hooks.py b/cuda_core/build_hooks.py index b368b02759..48e58a178e 100644 --- a/cuda_core/build_hooks.py +++ b/cuda_core/build_hooks.py @@ -91,7 +91,7 @@ def _determine_cuda_major_version() -> str: _extensions = None -def _build_cuda_core(): +def _build_cuda_core(strip=False): # Customizing the build hooks is needed because we must defer cythonization until cuda-bindings, # now a required build-time dependency that's dynamically installed via the other hook below, # is installed. Otherwise, cimport any cuda.bindings modules would fail! @@ -136,6 +136,9 @@ def get_sources(mod_name): all_include_dirs = [os.path.join(_get_cuda_path(), "include")] extra_compile_args = [] + extra_link_args = [] + if strip and sys.platform == "linux": + extra_link_args += ["-Wl,--strip-all"] if COMPILE_FOR_COVERAGE: # CYTHON_TRACE_NOGIL indicates to trace nogil functions. It is not # related to free-threading builds. @@ -152,6 +155,7 @@ def get_sources(mod_name): + all_include_dirs, language="c++", extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, ) for mod in module_names() ) @@ -254,7 +258,7 @@ def _add_cython_include_paths_to_pth(wheel_path: str) -> None: def build_editable(wheel_directory, config_settings=None, metadata_directory=None): - _build_cuda_core() + _build_cuda_core(strip=False) wheel_name = _build_meta.build_editable(wheel_directory, config_settings, metadata_directory) # Patch the .pth file to add Cython include paths @@ -265,7 +269,7 @@ def build_editable(wheel_directory, config_settings=None, metadata_directory=Non def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): - _build_cuda_core() + _build_cuda_core(strip=True) return _build_meta.build_wheel(wheel_directory, config_settings, metadata_directory)