summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/modules/detect/tools/cl/has_flags.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/xmake/modules/detect/tools/cl/has_flags.lua b/xmake/modules/detect/tools/cl/has_flags.lua
index aced6332d..8bce7a83e 100644
--- a/xmake/modules/detect/tools/cl/has_flags.lua
+++ b/xmake/modules/detect/tools/cl/has_flags.lua
@@ -74,8 +74,17 @@ function _check_try_running(flags, opt)
local errors = nil
return try { function ()
local tmpdir = os.tmpdir()
- local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. os.nuldev(), sourcefile),
+ local nuldev = os.nuldev()
+ local tmpfile
+ if not is_host("windows") then
+ tmpfile = os.tmpfile()
+ nuldev = tmpfile
+ end
+ local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. nuldev, sourcefile),
{envs = opt.envs, curdir = tmpdir}) -- we need to switch to tmpdir to avoid generating some tmp files, e.g. /Zi -> vc140.pdb
+ if tmpfile then
+ os.tryrm(tmpfile)
+ end
if errs and #errs:trim() > 0 then
return false, errs
end