diff options
| author | ruki <[email protected]> | 2025-12-18 23:20:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-18 23:20:30 +0800 |
| commit | 2ff05c59d4c3aa6b23b8d521d9173c0860109019 (patch) | |
| tree | 54c91c9642350220003ebaaddedbc2303add1cd7 | |
| parent | ae8719163477322bde3c934d73813b6b3aa3a50c (diff) | |
fix rpath for clang
| -rw-r--r-- | xmake/modules/core/tools/clang.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/private/utils/toolchain.lua | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 67af3da51..6b3098215 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -222,11 +222,11 @@ function nf_runtime(self, runtime, opt) } end end - local target = opt.target or opt -- llvm on windows still doesn't support autolinking of libc++ and compiler-rt builtins -- @see https://discourse.llvm.org/t/improve-autolinking-of-compiler-rt-and-libc-on-windows-with-lld-link/71392/10 - -- and need manual setting of libc++ headerdirectory + -- and need manual setting of libc++ headerdirectory -- @see https://github.com/llvm/llvm-project/issues/79647 + local target = opt.target or opt local llvm_dirs = toolchain_utils.get_llvm_dirs(self:toolchain()) -- we will set runtimes in android ndk toolchain if not self:is_plat("android") then @@ -274,10 +274,14 @@ function nf_runtime(self, runtime, opt) maps["c++_shared"] = table.join(maps["c++_shared"], nf_linkdir(self, llvm_dirs.cxxlibdir)) end - -- add rpath to avoid the user need to set DYLD_LIBRARY_PATH by hand - if target.is_shared and target:is_shared() and target.filename and self:is_plat("macosx", "iphoneos", "watchos") then - maps["c++_shared"] = table.join(maps["c++_shared"], "-install_name") - maps["c++_shared"] = table.join(maps["c++_shared"], "@rpath/" .. target:filename()) + -- add rpath to avoid the user need to set (DY)LD_LIBRARY_PATH by hand + if not self:is_plat("windows", "mingw") then + if llvm_dirs.libdir then + maps["c++_shared"] = table.join(maps["c++_shared"], nf_rpathdir(self, llvm_dirs.libdir)) + end + if llvm_dirs.cxxlibdir then + maps["c++_shared"] = table.join(maps["c++_shared"], nf_rpathdir(self, llvm_dirs.cxxlibdir)) + end end end if runtime:endswith("_static") and _has_static_libstdcxx(self) then diff --git a/xmake/modules/private/utils/toolchain.lua b/xmake/modules/private/utils/toolchain.lua index ffe383a5b..49af8193f 100644 --- a/xmake/modules/private/utils/toolchain.lua +++ b/xmake/modules/private/utils/toolchain.lua @@ -229,7 +229,7 @@ function get_llvm_compiler_rtinfo(toolchain) local resourcedir = get_llvm_resourcedir(toolchain) if resourcedir then local res_libdir = path.join(resourcedir, "lib") - -- when -DLLVM_ENABLE_TARGET_RUNTIME_DIR=OFF rtdir is windows/ and rtlink is clang_rt.builtins_<arch>.lib + -- when -DLLVM_ENABLE_TARGET_RUNTIME_DIR=OFF rtdir is windows/ and rtlink is clang_rt.builtins_<arch>.lib -- when ON rtdir is windows/<target-triple> and rtlink is clang_rt.builtins.lib local target_triple = get_llvm_target_triple(toolchain) local arch = target_triple and target_triple:split("-")[1] @@ -242,7 +242,7 @@ function get_llvm_compiler_rtinfo(toolchain) elseif toolchain:is_plat("macosx", "iphoneos", "watchos", "appletvos", "applexros") then plat = "darwin" end - + local tripletdir = target_triple and path.join(res_libdir, "windows", target_triple) tripletdir = os.isdir(tripletdir) or nil |
