From d4ff9a0835281c07305f2e3f5dd31786dab00361 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:25:28 -0500 Subject: [PATCH 1/5] wip --- setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e54e5c8..78ba775 100644 --- a/setup.py +++ b/setup.py @@ -64,15 +64,23 @@ def parse_library_names(libdir): "-Wl,-rpath,@loader_path/../kintera/lib", ] else: + # ubuntu system has an aggressive linker that removes unused shared libs + # add cuda library explicitly if built with cuda + cuda_linker = [] + if 'snap_cuda_release' in libraries: + libraries.remove('snap_cuda_release') + cuda_linker = ["-Wl,--no-as-needed", + "-lsnap_cuda_release", + "-Wl,--as-needed"] + extra_link_args = [ - "-Wl,--no-as-needed", "-Wl,-rpath,$ORIGIN/lib", "-Wl,-rpath,$ORIGIN/../torch/lib", "-Wl,-rpath,$ORIGIN/../pydisort/lib", "-Wl,-rpath,$ORIGIN/../pyharp/lib", "-Wl,-rpath,$ORIGIN/../kintera/lib", - "-Wl,--as-needed", ] + extra_link_args += cuda_linker ext_module = cpp_extension.CppExtension( name='snapy.snapy', From e07375acbb14b76237ab867d32ab1950899d926b Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:36:39 -0500 Subject: [PATCH 2/5] wip --- setup.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 78ba775..136a2d7 100644 --- a/setup.py +++ b/setup.py @@ -64,14 +64,12 @@ def parse_library_names(libdir): "-Wl,-rpath,@loader_path/../kintera/lib", ] else: - # ubuntu system has an aggressive linker that removes unused shared libs - # add cuda library explicitly if built with cuda - cuda_linker = [] - if 'snap_cuda_release' in libraries: - libraries.remove('snap_cuda_release') - cuda_linker = ["-Wl,--no-as-needed", - "-lsnap_cuda_release", - "-Wl,--as-needed"] + cuda_linker = ["-Wl,--no-as-needed"] + for libname in libraries: + if 'cuda' in libname: + libraries.remove(libname) + cuda_linker.append(f"-l{libname}") + cuda_linker.append("-Wl,--as-needed") extra_link_args = [ "-Wl,-rpath,$ORIGIN/lib", From 3e700045a4d20604e725849ba55ebf8ddb135a20 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:41:59 -0500 Subject: [PATCH 3/5] wip --- setup.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 136a2d7..79d1a9c 100644 --- a/setup.py +++ b/setup.py @@ -64,12 +64,17 @@ def parse_library_names(libdir): "-Wl,-rpath,@loader_path/../kintera/lib", ] else: - cuda_linker = ["-Wl,--no-as-needed"] - for libname in libraries: - if 'cuda' in libname: - libraries.remove(libname) - cuda_linker.append(f"-l{libname}") - cuda_linker.append("-Wl,--as-needed") + cuda_linker = [] + cuda_libraries = [lib for lib in libraries if "cuda" in lib] + + if cuda_libraries: + for lib in cuda_libraries: + libraries.remove(lib) + cuda_linker = ( + ["-Wl,--no-as-needed"] + + [f"-l{lib}" for lib in cuda_libraries] + + ["-Wl,--as-needed"] + ) extra_link_args = [ "-Wl,-rpath,$ORIGIN/lib", From 6ae07837c6117eb3f505ba2c15c0bcf574ac2894 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:44:19 -0500 Subject: [PATCH 4/5] wip --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 79d1a9c..ff6b011 100644 --- a/setup.py +++ b/setup.py @@ -70,11 +70,9 @@ def parse_library_names(libdir): if cuda_libraries: for lib in cuda_libraries: libraries.remove(lib) - cuda_linker = ( - ["-Wl,--no-as-needed"] + cuda_linker = ["-Wl,--no-as-needed"] + [f"-l{lib}" for lib in cuda_libraries] + ["-Wl,--as-needed"] - ) extra_link_args = [ "-Wl,-rpath,$ORIGIN/lib", From cb2670590fc71e47e3673cbb85c4e565b628c38e Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:50:46 -0500 Subject: [PATCH 5/5] wip --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ff6b011..a0ecd4d 100644 --- a/setup.py +++ b/setup.py @@ -70,9 +70,11 @@ def parse_library_names(libdir): if cuda_libraries: for lib in cuda_libraries: libraries.remove(lib) - cuda_linker = ["-Wl,--no-as-needed"] + cuda_linker = ( + ["-Wl,--no-as-needed"] + [f"-l{lib}" for lib in cuda_libraries] + ["-Wl,--as-needed"] + ) extra_link_args = [ "-Wl,-rpath,$ORIGIN/lib",