Skip to content

Commit 8169244

Browse files
leofangclaude
andcommitted
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) <noreply@anthropic.com>
1 parent f9539c3 commit 8169244

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cuda_core/build_hooks.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _determine_cuda_major_version() -> str:
9191
_extensions = None
9292

9393

94-
def _build_cuda_core():
94+
def _build_cuda_core(strip=False):
9595
# Customizing the build hooks is needed because we must defer cythonization until cuda-bindings,
9696
# now a required build-time dependency that's dynamically installed via the other hook below,
9797
# is installed. Otherwise, cimport any cuda.bindings modules would fail!
@@ -136,6 +136,9 @@ def get_sources(mod_name):
136136

137137
all_include_dirs = [os.path.join(_get_cuda_path(), "include")]
138138
extra_compile_args = []
139+
extra_link_args = []
140+
if strip and sys.platform == "linux":
141+
extra_link_args += ["-Wl,--strip-all"]
139142
if COMPILE_FOR_COVERAGE:
140143
# CYTHON_TRACE_NOGIL indicates to trace nogil functions. It is not
141144
# related to free-threading builds.
@@ -152,6 +155,7 @@ def get_sources(mod_name):
152155
+ all_include_dirs,
153156
language="c++",
154157
extra_compile_args=extra_compile_args,
158+
extra_link_args=extra_link_args,
155159
)
156160
for mod in module_names()
157161
)
@@ -254,7 +258,7 @@ def _add_cython_include_paths_to_pth(wheel_path: str) -> None:
254258

255259

256260
def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
257-
_build_cuda_core()
261+
_build_cuda_core(strip=False)
258262
wheel_name = _build_meta.build_editable(wheel_directory, config_settings, metadata_directory)
259263

260264
# Patch the .pth file to add Cython include paths
@@ -265,7 +269,7 @@ def build_editable(wheel_directory, config_settings=None, metadata_directory=Non
265269

266270

267271
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
268-
_build_cuda_core()
272+
_build_cuda_core(strip=True)
269273
return _build_meta.build_wheel(wheel_directory, config_settings, metadata_directory)
270274

271275

0 commit comments

Comments
 (0)