summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-29 22:40:23 +0800
committerruki <[email protected]>2024-11-29 22:40:23 +0800
commitaedfd1c46c942392fbfefb1750f2cd3bde6d1e6c (patch)
tree0c653be9d19b8e3875b3513dc14f7c32d7aa33fa /xmake/modules/core/tools/gcc.lua
parent41d59e7004aecf871a30828ff3a54beeabcee041 (diff)
suppress unknown flags
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 821bd9910..08f898c8e 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -630,6 +630,19 @@ function _has_color_diagnostics(self)
return colors_diagnostics
end
+-- has gnu-line-marker flag?
+function _has_gnu_line_marker_flag(self)
+ local gnu_line_marker = _g._HAS_GNU_LINE_MARKER
+ if gnu_line_marker == nil then
+ if self:has_flags({"-Wno-gnu-line-marker", "-Werror"}, "cxflags") then
+ gnu_line_marker = true
+ end
+ gnu_line_marker = gnu_line_marker or false
+ _g._HAS_GNU_LINE_MARKER = gnu_line_marker
+ end
+ return gnu_line_marker
+end
+
-- get preprocess file path
function _get_cppfile(sourcefile, objectfile)
return path.join(path.directory(objectfile), "__cpp_" .. path.basename(objectfile) .. path.extension(sourcefile))
@@ -758,7 +771,7 @@ function _preprocess(program, argv, opt)
-- suppress -Wgnu-line-marker warnings
-- @see https://github.com/xmake-io/xmake/issues/5737
- if is_gcc or is_clang then
+ if (is_gcc or is_clang) and _has_gnu_line_marker_flag(tool) then
table.insert(flags, "-Wno-gnu-line-marker")
end