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)