summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxq114 <[email protected]>2022-02-10 14:20:40 +0800
committerxq114 <[email protected]>2022-02-10 14:20:40 +0800
commit954315803ea21773b79e3cf7c7e734050cc7236f (patch)
tree65fb00bc641998a3cacb475e60f6a3d96d2d1aca
parent2f45c77d641d3d5afcfe62fa3a43d0935b9bf826 (diff)
fix nvcc not generating dependfiles on windows
-rw-r--r--xmake/modules/core/tools/nvcc.lua29
1 files changed, 28 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 0d862af96..254710ab3 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -286,6 +286,16 @@ function link(self, objectfiles, targetkind, targetfile, flags)
os.runv(program, argv, {envs = self:runenvs()})
end
+-- support `-MD -MF depfile.d`?
+function _has_flags_md_mf(self)
+ local has_md_mf = _g._HAS_MD_MF
+ if has_md_mf == nil then
+ has_md_mf = self:has_flags({"-MD", "-MF", os.nuldev()}, "cuflags", { flagskey = "-MD -MF" }) or false
+ _g._HAS_MD_MF = has_md_mf
+ end
+ return has_md_mf
+end
+
-- support `-MMD -MF depfile.d`? some old gcc does not support it at same time
function _has_flags_mmd_mf(self)
local has_mmd_mf = _g._HAS_MMD_MF
@@ -296,6 +306,16 @@ function _has_flags_mmd_mf(self)
return has_mmd_mf
end
+-- support `-M -o depfile.d`?
+function _has_flags_m(self)
+ local has_m = _g._HAS_M
+ if not has_md_mf and has_m == nil then
+ has_m = self:has_flags("-M", "cuflags", { flagskey = "-M" }) or false
+ _g._HAS_M = has_m
+ end
+ return has_m
+end
+
-- support `-MM -o depfile.d`?
function _has_flags_mm(self)
local has_mm = _g._HAS_MM
@@ -329,9 +349,16 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
if _has_flags_mmd_mf(self) then
compflags = table.join(compflags, "-MMD", "-MF", depfile)
elseif _has_flags_mm(self) then
- -- since -MD is not supported, run nvcc twice
+ -- since -MMD is not supported, run nvcc twice
local program, argv = compargv(self, sourcefile, depfile, table.join(flags, "-MM"))
os.runv(program, argv, {envs = self:runenvs()})
+ elseif _has_flags_md_mf(self) then
+ -- on windows only -MD and -M are supported
+ compflags = table.join(compflags, "-MD", "-MF", depfile)
+ elseif _has_flags_m(self) then
+ -- since -MD is not supported, run nvcc twice
+ local program, argv = compargv(self, sourcefile, depfile, table.join(flags, "-M"))
+ os.runv(program, argv, {envs = self:runenvs()})
end
end