Skip to content

Commit

Permalink
Add $CONDA_PREFIX/targets/x86_64-linux/lib to LD search path
Browse files Browse the repository at this point in the history
Co-authored-by: Silvio Traversaro <silvio.traversaro@iit.it>
  • Loading branch information
flferretti and traversaro committed Jan 7, 2025
1 parent 78a071a commit 8a46f09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions recipe/01-find_g++_env.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@ index ec440ec1..d750366e 100644
@@ -207,6 +207,9 @@ if platform.system() == "Windows":
print("Warp build error: Could not find MSVC compiler")
sys.exit(1)

+else:
+ args.host_compiler = find_host_compiler()
+

# return platform specific shared library name
def lib_name(name):
diff --git a/warp/build_dll.py b/warp/build_dll.py
index e4bc782f..1599721b 100644
--- a/warp/build_dll.py
+++ b/warp/build_dll.py
@@ -109,7 +109,7 @@ def find_host_compiler():

else:
# try and find g++
- return run_cmd("which g++").decode()
+ return run_cmd("echo $CXX").decode().strip() if run_cmd("echo $CXX") != b"\xA0" else run_cmd("which g++").decode().strip()


def get_cuda_toolkit_version(cuda_home):
@@ -335,7 +335,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
cpp_out = cpp_path + ".o"
ld_inputs.append(quote(cpp_out))

- build_cmd = f'g++ {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
+ build_cmd = f'{args.host_compiler} {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"'
run_cmd(build_cmd)

if cu_path:
@@ -367,7 +367,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None

with ScopedTimer("link", active=args.verbose):
origin = "@loader_path" if (sys.platform == "darwin") else "$ORIGIN"
- link_cmd = f"g++ {version} -shared -Wl,-rpath,'{origin}' {opt_no_undefined} {opt_exclude_libs} -o '{dll_path}' {' '.join(ld_inputs + libs)}"
+ link_cmd = f"{args.host_compiler} {version} -shared -Wl,-rpath,'{origin}' {opt_no_undefined} {opt_exclude_libs} -o '{dll_path}' {' '.join(ld_inputs + libs)}"
+ link_cmd = f"{args.host_compiler} {version} -shared -Wl,-rpath,'{origin}' {os.environ.get("LD_EXTRA_FLAGS")} {opt_no_undefined} {opt_exclude_libs} -o '{dll_path}' {' '.join(ld_inputs + libs)}"
run_cmd(link_cmd)

# Strip symbols to reduce the binary size
3 changes: 3 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ if [[ "${cuda_compiler_version:-None}" != "None" ]]; then
export CUDA_TOOLKIT_INCLUDE_DIR="${PREFIX}/targets/x86_64-linux"
export CUDA_INSTALL_PATH=$(which nvcc | awk -F'/bin/nvcc' '{print $1}')
fi
if [[ "$target_platform" == linux-* ]]; then
LD_EXTRA_FLAGS="$LD_EXTRA_FLAGS -L$CONDA_PREFIX/targets/x86_64-linux/lib"
fi
fi

${PYTHON} build_lib.py ${ARGS:-}
Expand Down

0 comments on commit 8a46f09

Please sign in to comment.