From 905455a7bf3d74db7d79d1e88dd27d7d000af67e Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 25 Nov 2024 22:57:59 +0800 Subject: fix cl/has_flags for msvc-wine --- xmake/modules/detect/tools/cl/has_flags.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- cgit v1.3.1