Skip to content

Commit

Permalink
improve clang runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 27, 2024
1 parent 39a5bd6 commit 97ebae3
Showing 1 changed file with 13 additions and 38 deletions.
51 changes: 13 additions & 38 deletions xmake/modules/core/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -204,69 +205,43 @@ function nf_runtime(self, runtime, opt)
end
return
end
local maps
if language.sourcekinds()[kind] then
maps = {
MT = "-fms-runtime-lib=static",
MTd = "-fms-runtime-lib=static_dbg",
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",
MTd = "-nostdlib",
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

0 comments on commit 97ebae3

Please sign in to comment.