summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-16 23:41:48 +0800
committerruki <[email protected]>2023-02-16 23:41:48 +0800
commita7dea61c3953b96ef3335f0cac64b7bc2634bc03 (patch)
treec0c4ee0f743f938de475faba83653cc32626d0a3
parent44053082b5aa4765d9b6a10322a1ad8fc253a762 (diff)
improve stdlib for clang
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua20
1 files changed, 17 insertions, 3 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 71127da77..6c538373b 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -234,7 +234,6 @@ function _build_modulefile(target, sourcefile, opt)
local bmiflags
if opt.provide then
bmifile = opt.provide.bmifile
-
if moduleoutputflag then
compileflags = table.join("-x", "c++-module", moduleoutputflag .. bmifile, requiresflags)
else
@@ -244,6 +243,16 @@ function _build_modulefile(target, sourcefile, opt)
compileflags = {"-x", "c++"}
end
+ -- we can also enable libc++ when building modules
+ --
+ -- @see https://github.com/xmake-io/xmake/issues/3373
+ if target:data("cxx.modules.use_libc++") then
+ if bmiflags then
+ table.insert(bmiflags, "-stdlib=libc++")
+ end
+ table.insert(compileflags, "-stdlib=libc++")
+ end
+
if bmiflags then
vprint(compinst:compcmd(sourcefile, bmifile, {compflags = bmiflags, rawargs = true}))
end
@@ -307,8 +316,13 @@ function generate_dependencies(target, sourcebatch, opt)
local clangscandeps = _get_clang_scan_deps(target)
local compinst = target:compiler("cxx")
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
- local flags = table.join({"--format=p1689", "--", compinst:program(), "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile)}, compflags)
-
+ local flags = table.join("--format=p1689", "--",
+ compinst:program(), "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile),
+ compflags)
+ -- we can also enable libc++ when scaning deps
+ if target:data("cxx.modules.use_libc++") then
+ table.insert(flags, "-stdlib=libc++")
+ end
vprint(table.concat(table.join(clangscandeps, flags), " "))
local outdata, errdata = os.iorunv(clangscandeps, flags)
assert(errdata, errdata)