diff options
| author | ruki <[email protected]> | 2024-01-27 12:08:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-27 12:08:14 +0800 |
| commit | 97ebae3c85e8bb7cfef13b02415e4a5798b13234 (patch) | |
| tree | 6bde736062a7b2a3a68d1889205338315fc6a6fb | |
| parent | 39a5bd6cc85b676d1387770c6f0079103862b8ee (diff) | |
improve clang runtimes
| -rw-r--r-- | xmake/modules/core/tools/clang.lua | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 51a1de187..763a87f41 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -196,6 +196,7 @@ end -- @see https://github.com/xmake-io/xmake/issues/3546 function nf_runtime(self, runtime, opt) opt = opt or {} + local maps local kind = self:kind() if self:is_plat("windows") and runtime then if not _has_ms_runtime_lib(self) then @@ -204,7 +205,6 @@ function nf_runtime(self, runtime, opt) end return end - local maps if language.sourcekinds()[kind] then maps = { MT = "-fms-runtime-lib=static", @@ -212,14 +212,6 @@ function nf_runtime(self, runtime, opt) MD = "-fms-runtime-lib=dll", MDd = "-fms-runtime-lib=dll_dbg" } - if kind == "cxx" then - table.join2(maps, { - ["c++_static"] = "-stdlib=libc++", - ["c++_shared"] = "-stdlib=libc++", - ["stdc++_static"] = "-stdlib=libstdc++", - ["stdc++_shared"] = "-stdlib=libstdc++", - }) - end elseif kind == "ld" or kind == "sh" then maps = { MT = "-nostdlib", @@ -227,46 +219,29 @@ function nf_runtime(self, runtime, opt) MD = "-nostdlib", MDd = "-nostdlib" } - local target = opt.target - if target and target.sourcekinds and table.contains(table.wrap(target:sourcekinds()), "cxx") then - table.join2(maps, { - ["c++_static"] = "-stdlib=libc++", - ["c++_shared"] = "-stdlib=libc++", - ["stdc++_static"] = "-stdlib=libstdc++", - ["stdc++_shared"] = "-stdlib=libstdc++", - }) - if runtime:endswith("_static") and _has_static_libstdcxx(self) then - maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++") - maps["stdc++_static"] = table.join(maps["stdc++_static"], "-static-libstdc++") - end - end end - return maps and maps[runtime] - elseif not self:is_plat("android") then -- we will set runtimes in android ndk toolchain - local maps + end + if not self:is_plat("android") then -- we will set runtimes in android ndk toolchain + maps = maps or {} if kind == "cxx" then - maps = { - ["c++_static"] = "-stdlib=libc++", - ["c++_shared"] = "-stdlib=libc++", - ["stdc++_static"] = "-stdlib=libstdc++", - ["stdc++_shared"] = "-stdlib=libstdc++", - } + maps["c++_static"] = "-stdlib=libc++" + maps["c++_shared"] = "-stdlib=libc++" + maps["stdc++_static"] = "-stdlib=libstdc++" + maps["stdc++_shared"] = "-stdlib=libstdc++" elseif kind == "ld" or kind == "sh" then local target = opt.target if target and target.sourcekinds and table.contains(table.wrap(target:sourcekinds()), "cxx") then - maps = { - ["c++_static"] = "-stdlib=libc++", - ["c++_shared"] = "-stdlib=libc++", - ["stdc++_static"] = "-stdlib=libstdc++", - ["stdc++_shared"] = "-stdlib=libstdc++", - } + maps["c++_static"] = "-stdlib=libc++" + maps["c++_shared"] = "-stdlib=libc++" + maps["stdc++_static"] = "-stdlib=libstdc++" + maps["stdc++_shared"] = "-stdlib=libstdc++" if runtime:endswith("_static") and _has_static_libstdcxx(self) then maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++") maps["stdc++_static"] = table.join(maps["stdc++_static"], "-static-libstdc++") end end end - return maps and maps[runtime] end + return maps and maps[runtime] end |
