summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-29 16:14:32 +0800
committerruki <[email protected]>2022-05-29 16:14:32 +0800
commit7c25991447b53c2826ff473f4b92924661dbfeb7 (patch)
tree8c3fd6dd9bddd7fd00f9267876967ed69613e65d
parent9704261b8dbd46acf6f9384e6f4a590c3651224e (diff)
improve gcc preprocessor
-rw-r--r--xmake/modules/core/tools/gcc.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index f154fb1ee..9651eab36 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -400,6 +400,12 @@ function _preprocess(program, argv, opt)
end
end
+ -- enable "-fdirectives-only"?
+ local fdirectives_only = _g.fdirectives_only
+ if fdirectives_only ~= false and is_gcc then
+ fdirectives_only = true
+ end
+
-- get flags and source file
local flags = {}
local cppflags = {}
@@ -417,6 +423,12 @@ function _preprocess(program, argv, opt)
return
end
+ -- we cannot enable "-fdirectives-only"
+ if fdirectives_only and (flag:startswith("-D__TIME__=") or
+ flag:startswith("-D__DATE__=") or flag:startswith("-D__TIMESTAMP__=")) then
+ fdirectives_only = false
+ end
+
-- get compiler flags
if flag == "-MMD" or (flag:startswith("-I") and #flag > 2) or flag:startswith("--sysroot=") then
skipped = 1
@@ -442,12 +454,6 @@ function _preprocess(program, argv, opt)
return
end
- -- enable "-fdirectives-only"?
- local fdirectives_only = _g.fdirectives_only
- if fdirectives_only ~= false and is_gcc then
- fdirectives_only = true
- end
-
-- disable linemarkers?
local linemarkers = _g.linemarkers
if linemarkers == nil then