Skip to content

Commit

Permalink
support --sdk for --runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthapz committed Feb 4, 2024
1 parent a914429 commit b95ae65
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions xmake/modules/core/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ function nf_runtime(self, runtime, opt)
maps["c++_shared"] = "-stdlib=libc++"
maps["stdc++_static"] = "-stdlib=libstdc++"
maps["stdc++_shared"] = "-stdlib=libstdc++"
-- clang on windows fail to add libc++ includepath when using -stdlib=libc++ so we manually add it
-- @see https://github.com/llvm/llvm-project/issues/79647
if self:is_plat("windows") then
local llvm_rootdir = _get_llvm_rootdir(self)
if llvm_rootdir then
maps["c++_static"] = table.join(maps["c++_static"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1"))
maps["c++_shared"] = table.join(maps["c++_shared"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1"))
end
local llvm_rootdir
if get_config("sdk") then
-- if a sdk dir is defined, we should redirect include path to have the correct includes
llvm_rootdir = get_config("sdk")
elseif self:is_plat("windows") then
-- clang on windows fail to add libc++ includepath when using -stdlib=libc++ so we manually add it
-- @see https://github.com/llvm/llvm-project/issues/79647
llvm_rootdir = _get_llvm_rootdir(self)
end
if llvm_rootdir then
maps["c++_static"] = table.join(maps["c++_static"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1"))
maps["c++_shared"] = table.join(maps["c++_shared"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1"))
end
elseif kind == "ld" or kind == "sh" then
local target = opt.target
Expand All @@ -259,14 +263,18 @@ function nf_runtime(self, runtime, opt)
maps["c++_shared"] = "-stdlib=libc++"
maps["stdc++_static"] = "-stdlib=libstdc++"
maps["stdc++_shared"] = "-stdlib=libstdc++"
-- clang on windows fail to add libc++ librarypath when using -stdlib=libc++ so we manually add it
-- @see https://github.com/llvm/llvm-project/issues/79647
if self:is_plat("windows") then
local llvm_rootdir = _get_llvm_rootdir(self)
if llvm_rootdir then
maps["c++_static"] = table.join(maps["c++_static"], "-L" .. path.join(llvm_rootdir, "lib"))
maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. path.join(llvm_rootdir, "lib"))
end
local llvm_rootdir
if get_config("sdk") then
-- if a sdk dir is defined, we should redirect library path for linking the right libc++
llvm_rootdir = get_config("sdk")
elseif self:is_plat("windows") then
-- clang on windows fail to add libc++ librarypath when using -stdlib=libc++ so we manually add it
-- @see https://github.com/llvm/llvm-project/issues/79647
llvm_rootdir = _get_llvm_rootdir(self)
end
if llvm_rootdir then
maps["c++_static"] = table.join(maps["c++_static"], "-L" .. path.join(llvm_rootdir, "lib"))
maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. path.join(llvm_rootdir, "lib"))
end
if runtime:endswith("_static") and _has_static_libstdcxx(self) then
maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++")
Expand Down

0 comments on commit b95ae65

Please sign in to comment.