summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-05-29 00:42:45 +0800
committerruki <[email protected]>2025-05-29 00:42:45 +0800
commitc5b5179e065a546a273861b4f2d6b43d1cbbbc5d (patch)
tree7c1f64ee7a223d654cb6716c014ea2739e328113
parentd671c2d18649bf0592b785bfe4b26d9114fe671b (diff)
fix depfile for cosmocc #6505
-rw-r--r--xmake/modules/core/tools/gcc.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 073529e87..977e44bac 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -61,13 +61,25 @@ function _get_implibfile(self, targetkind, targetfile, opt)
end
end
+-- is cosmocc?
+function _is_cosmocc(self)
+ local is_cosmocc = _g._IS_COSMOCC
+ if is_cosmocc == nil then
+ if self:name():startswith("cosmoc") then
+ is_cosmocc = true
+ end
+ _g._IS_COSMOCC = is_cosmocc or false
+ end
+ return is_cosmocc
+end
+
-- get `-MMD -MF depfile.d` flags, some old gcc does not support it at same time
function _get_depfile_flags(self)
local depfile_flags = _g._DEPFILE_FLAGS
if depfile_flags == nil then
local nuldev = os.nuldev()
- if self:name():startswith("cosmoc") then
- nuldev = os.tmpfile()
+ if _is_cosmocc(self) then
+ nuldev = path.unix(os.tmpfile())
end
if self:has_flags({"-MMD", "-MF", nuldev}, "cxflags", { flagskey = "-MMD -MF" }) then
depfile_flags = {"-MMD", "-MF"}
@@ -967,6 +979,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
-- generate includes file
local compflags = flags
if depfile then
+ if _is_cosmocc(self) then
+ depfile = path.unix(depfile)
+ end
local depfile_flags = _get_depfile_flags(self)
if depfile_flags then
compflags = table.join(compflags, depfile_flags, depfile)