diff options
| author | ruki <[email protected]> | 2025-09-18 22:41:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-09-18 22:41:11 +0800 |
| commit | 7e3c48b59afbbb53a58951d81413cd438553ad05 (patch) | |
| tree | 6dac695956c1caa4a4f30b69f04e8ce75e670674 /xmake/modules/core/tools/gcc/has_flags.lua | |
| parent | 44812793dd6e8c9cae32bf8517d516709e91b3db (diff) | |
improve has_flags
Diffstat (limited to 'xmake/modules/core/tools/gcc/has_flags.lua')
| -rw-r--r-- | xmake/modules/core/tools/gcc/has_flags.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/gcc/has_flags.lua b/xmake/modules/core/tools/gcc/has_flags.lua index 731e5da2f..b56596e3e 100644 --- a/xmake/modules/core/tools/gcc/has_flags.lua +++ b/xmake/modules/core/tools/gcc/has_flags.lua @@ -21,6 +21,7 @@ -- imports import("core.cache.detectcache") import("core.language.language") +import("core.base.hashset") -- is linker? function _islinker(flags, opt) @@ -45,6 +46,14 @@ end -- attempt to check it from known flags 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({"-O0", "-O1", "-O2", "-O3", "-g"}) + _g.known_flags = known_flags + end + if known_flags:has(flag) then + return true + end if not islinker then if flag:startswith("-D") or flag:startswith("-U") or @@ -119,10 +128,10 @@ function main(flags, opt) -- attempt to check it from the argument list if not opt.tryrun then - if _check_from_arglist(flags, opt, islinker) then + if _check_from_knownargs(flags, opt, islinker) then return true end - if _check_from_knownargs(flags, opt, islinker) then + if _check_from_arglist(flags, opt, islinker) then return true end end |
