summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-08 16:01:27 +0800
committerruki <[email protected]>2021-05-08 16:07:12 +0800
commitcab3fb99fdc5a4a9fd97437cf4ed8a232a12ebc9 (patch)
treef731b841ee1825620b73d410dd138f1580b8fe93
parent76d737fcc850ba14de9ca18cdb49c7bfbf3e6620 (diff)
improve nvcc
-rw-r--r--xmake/modules/core/tools/nvcc.lua6
-rw-r--r--xmake/toolchains/cuda/xmake.lua11
2 files changed, 15 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 011599e8a..df4a6b7f4 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -317,12 +317,14 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
compflags = table.join(compflags, "-MMD", "-MF", depfile)
elseif _has_flags_mm(self) then
-- since -MD is not supported, run nvcc twice
- os.runv(compargv(self, sourcefile, depfile, table.join(flags, "-MM")))
+ local program, argv = compargv(self, sourcefile, depfile, table.join(flags, "-MM"))
+ os.runv(program, argv, {envs = self:runenvs()})
end
end
-- do compile
- local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, compflags))
+ local program, argv = compargv(self, sourcefile, objectfile, compflags)
+ local outdata, errdata = os.iorunv(program, argv, {envs = self:runenvs()})
return (outdata or "") .. (errdata or "")
end,
catch
diff --git a/xmake/toolchains/cuda/xmake.lua b/xmake/toolchains/cuda/xmake.lua
index f7bd54cd0..ca25dcb74 100644
--- a/xmake/toolchains/cuda/xmake.lua
+++ b/xmake/toolchains/cuda/xmake.lua
@@ -30,3 +30,14 @@ toolchain("cuda")
set_toolset("culd", "nvcc")
set_toolset("cu-ccbin", "$(env CXX)", "$(env CC)", "clang", "gcc")
+ -- bind msvc environments, because nvcc will call cl.exe
+ on_load(function (toolchain)
+ if toolchain:is_plat("windows") then
+ import("core.tool.toolchain", {alias = "core_toolchain"})
+ local msvc = core_toolchain.load("msvc", {plat = toolchain:plat(), arch = toolchain:arch()})
+ for name, values in pairs(msvc:runenvs()) do
+ toolchain:add("runenvs", name, values)
+ end
+ end
+ end)
+