summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-24 23:41:32 +0800
committerruki <[email protected]>2020-05-24 23:41:32 +0800
commit0a6ba03d46c4b2bb969221de5680da9378f12e9b (patch)
tree212b52b4e14a58470153f6f473f638d5c06ee62b
parentfb2ba113ca1534249b0872002af0f133becd7e51 (diff)
fix nvcc for depfiles
-rw-r--r--tests/projects/cuda/console/inc/helper_cuda.h1
-rw-r--r--xmake/modules/core/tools/nvcc.lua19
2 files changed, 11 insertions, 9 deletions
diff --git a/tests/projects/cuda/console/inc/helper_cuda.h b/tests/projects/cuda/console/inc/helper_cuda.h
index 75e3eb242..7c5f9f5e8 100644
--- a/tests/projects/cuda/console/inc/helper_cuda.h
+++ b/tests/projects/cuda/console/inc/helper_cuda.h
@@ -27,6 +27,7 @@
#define EXIT_WAIVED 2
#endif
+//#error
// Note, it is required that your SDK sample to include the proper header files, please
// refer the CUDA examples for examples of the needed CUDA headers, which may change depending
// on which CUDA functions are used.
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index be951c2a9..cd38d4c04 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -283,19 +283,20 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
try
{
function ()
- -- support `-M -MF depfile.d`?
- if depfile and _g._HAS_M_MF == nil then
- _g._HAS_M_MF = self:has_flags({"-M", "-MF", os.nuldev()}, "cuflags", { flagskey = "-M -MF" }) or false
+
+ -- support `-MMD -MF depfile.d`? some old gcc does not support it at same time
+ if depfile and _g._HAS_MMD_MF == nil then
+ _g._HAS_MMD_MF = self:has_flags({"-MMD", "-MF", os.nuldev()}, "cxflags", { flagskey = "-MMD -MF" }) or false
end
-- generate includes file
- if depfile and _g._HAS_M_MF then
- -- since -MD is not supported, run nvcc twice
- local compflags = table.join(flags, "-M", "-MF", depfile)
- os.runv(_compargv1(self, sourcefile, objectfile, compflags))
+ local compflags = flags
+ if depfile and _g._HAS_MMD_MF then
+ compflags = table.join(compflags, "-MMD", "-MF", depfile)
end
- local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
+ -- do compile
+ local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, compflags))
return (outdata or "") .. (errdata or "")
end,
catch
@@ -337,7 +338,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
-- generate the dependent includes
if depfile and os.isfile(depfile) then
- if dependinfo and self:kind() ~= "as" then
+ if dependinfo then
-- nvcc uses gcc-style depfiles
dependinfo.depfiles_gcc = io.readfile(depfile, {continuation = "\\"})
end