summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-03 21:01:49 +0800
committerruki <[email protected]>2025-12-03 21:01:49 +0800
commit9c78a7642714f89dab6077eb9ecbc683e5551967 (patch)
tree59e774aa0452a51f5efa1ed25b930f43ff7c5458 /xmake/modules/core/tools/gcc.lua
parent13eda469fbca1407d7948191f2a7f04949ba392e (diff)
improve syntax check
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 4a920a233..c1a98b752 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -73,6 +73,11 @@ function _is_cosmocc(self)
return is_cosmocc
end
+-- is syntax check enabled?
+function _is_syntax_check()
+ return memcache.get("syntax_check", "enabled") or false
+end
+
-- get `-MMD -MF depfile.d` flags, some old gcc does not support it at same time
function _get_depfile_flags(self)
local depfile_flags = _g._DEPFILE_FLAGS
@@ -965,6 +970,7 @@ end
-- make the compile arguments list
function compargv(self, sourcefile, objectfile, flags, opt)
+ opt = opt or {}
-- is precompiled header or module files? remove the force includes.
local extension = path.extension(sourcefile)
@@ -974,6 +980,12 @@ function compargv(self, sourcefile, objectfile, flags, opt)
flags = _translate_flags_for_mpp(self, flags)
end
+ -- if syntax-only, add -fsyntax-only and skip -c and -o
+ if _is_syntax_check() then
+ table.insert(flags, "-fsyntax-only")
+ return self:program(), table.join(flags, sourcefile)
+ end
+
local argv = table.join("-c", flags, "-o", objectfile, sourcefile)
return self:program(), argv
end