From dcfcef424b2a501f7806409ef671dd2cc3c59f27 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 6 Feb 2026 06:08:25 -0500 Subject: [PATCH 1/5] wip --- setup.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 3051035..a9c15fa 100644 --- a/setup.py +++ b/setup.py @@ -20,9 +20,6 @@ def parse_library_names(libdir): # add system netcdf library library_names.extend(['netcdf']) - # move current library name to first - #current = [item for item in library_names if item.startswith('kintera')] - #other = [item for item in library_names if not item.startswith('kintera')] # 1) non-cuda libs first (consumers) kintera_non_cuda = [l for l in library_names if l.startswith("kintera") and "cuda" not in l] # 2) cuda libs last (providers) @@ -62,12 +59,12 @@ def parse_library_names(libdir): ] else: 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,--as-needed", + "-Wl,--no-as-needed", + "-lkintera_cuda_release", ] ext_module = cpp_extension.CppExtension( From 4424feb65503044e024e0f1e1897e7d9801a876a Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:12:41 -0500 Subject: [PATCH 2/5] wip --- setup.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index a9c15fa..c9f279a 100644 --- a/setup.py +++ b/setup.py @@ -58,14 +58,22 @@ def parse_library_names(libdir): "-Wl,-rpath,@loader_path/../pyharp/lib", ] else: + # ubuntu system has an aggressive linker that removes unused shared libs + # add cuda library explicitly if built with cuda + cuda_linker = [] + if 'kintera_cuda_release' in libraries: + libraries.remove('kintera_cuda_release') + cuda_linker = ["-Wl,--no-as-needed", + "-lkintera_cuda_release", + "-Wl,--as-needed"] + extra_link_args = [ "-Wl,-rpath,$ORIGIN/lib", "-Wl,-rpath,$ORIGIN/../torch/lib", "-Wl,-rpath,$ORIGIN/../pydisort/lib", - "-Wl,-rpath,$ORIGIN/../pyharp/lib", - "-Wl,--no-as-needed", - "-lkintera_cuda_release", - ] + "-Wl,-rpath,$ORIGIN/../pyharp/lib" + ] + extra_link_args += cuda_linker ext_module = cpp_extension.CppExtension( name='kintera.kintera', From 624f5a6c114245cafcb14ccb743895d3cb85d06e Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:29:41 -0500 Subject: [PATCH 3/5] wip --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index c9f279a..61f3481 100644 --- a/setup.py +++ b/setup.py @@ -60,12 +60,12 @@ def parse_library_names(libdir): else: # ubuntu system has an aggressive linker that removes unused shared libs # add cuda library explicitly if built with cuda - cuda_linker = [] - if 'kintera_cuda_release' in libraries: - libraries.remove('kintera_cuda_release') - cuda_linker = ["-Wl,--no-as-needed", - "-lkintera_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 23cc510ff4769ddbdf729e3e916aa6e8bf9e96a4 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:44:00 -0500 Subject: [PATCH 4/5] wip --- setup.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 61f3481..68c813b 100644 --- a/setup.py +++ b/setup.py @@ -60,12 +60,14 @@ def parse_library_names(libdir): else: # ubuntu system has an aggressive linker that removes unused shared libs # add cuda library explicitly if built with cuda - 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 9c9a2400042f21fa9eb6973aa9ac6ef734b24005 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Fri, 6 Feb 2026 06:50:38 -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 68c813b..526db00 100644 --- a/setup.py +++ b/setup.py @@ -65,9 +65,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",