summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-26 00:52:26 +0800
committerruki <[email protected]>2026-03-26 00:52:26 +0800
commitc24e4bcd8d8fb444d08fb317f839b830a9a633ef (patch)
tree653539504ed69feea46368518e8e76b23535f880
parentc6a54f8a734efdb7df32251e97bb24e9129a28a9 (diff)
improve has_flags again
-rw-r--r--xmake/modules/core/tools/cl/check_knownargs.lua15
-rw-r--r--xmake/modules/core/tools/gcc/has_flags.lua23
2 files changed, 22 insertions, 16 deletions
diff --git a/xmake/modules/core/tools/cl/check_knownargs.lua b/xmake/modules/core/tools/cl/check_knownargs.lua
index b42fe5e22..32b9ab03e 100644
--- a/xmake/modules/core/tools/cl/check_knownargs.lua
+++ b/xmake/modules/core/tools/cl/check_knownargs.lua
@@ -44,18 +44,9 @@ function main(flags)
if known_flags:has(flag) then
return true
end
- -- check flags with known prefixes that always accept values (all MSVC versions)
- if flag:startswith("-D") or
- flag:startswith("-U") or
- flag:startswith("-I") or
- flag:startswith("-Fo") or
- flag:startswith("-Fe") or
- flag:startswith("-Fd") or
- flag:startswith("-Fi") or
- flag:startswith("-Fp") or
- flag:startswith("-FI") or
- flag:startswith("-wd") or
- flag:startswith("-we") or
+ -- check flags with known prefixes (all MSVC versions)
+ if flag:startswith("-wd") or -- e.g. /wd4251
+ flag:startswith("-we") or -- e.g. /we4062
flag:startswith("-wo") then
return true
end
diff --git a/xmake/modules/core/tools/gcc/has_flags.lua b/xmake/modules/core/tools/gcc/has_flags.lua
index 5539fc0f4..d4db0461f 100644
--- a/xmake/modules/core/tools/gcc/has_flags.lua
+++ b/xmake/modules/core/tools/gcc/has_flags.lua
@@ -50,16 +50,31 @@ function _check_from_knownargs(flags, opt, islinker)
local flag = flags[1]
local known_flags = _g.known_flags
if known_flags == nil then
- known_flags = hashset.from({"-O", "-O0", "-O1", "-O2", "-O3", "-Os", "-g"})
+ known_flags = hashset.from({
+ "-O", "-O0", "-O1", "-O2", "-O3", "-Os",
+ "-g", "-g0", "-g1", "-g2", "-g3",
+ "-c", "-S", "-E", "-v",
+ "-pipe", "-pthread", "-shared", "-static",
+ "-fPIC", "-fPIE", "-fpic", "-fpie",
+ "-fno-exceptions", "-fexceptions",
+ "-fno-rtti", "-frtti",
+ "-fomit-frame-pointer", "-fno-omit-frame-pointer",
+ "-ffunction-sections", "-fdata-sections",
+ "-fno-strict-aliasing", "-fstrict-aliasing",
+ "-fstack-protector", "-fno-stack-protector",
+ "-fno-common",
+ "-MMD", "-MD", "-MP",
+ "-Wall", "-Wextra", "-Werror", "-pedantic",
+ "-w"
+ })
_g.known_flags = known_flags
end
if known_flags:has(flag) then
return true
end
+ -- check flags with known prefixes
if not islinker then
- if flag:startswith("-D") or
- flag:startswith("-U") or
- flag:startswith("-I") then
+ if flag:startswith("-Wno-") then -- -Wno-xxx is always silently accepted
return true
end
end