summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/gcc
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-20 22:12:04 +0800
committerruki <[email protected]>2022-08-20 22:12:04 +0800
commit32fa15ce715e20617c01a1cfb02babd50a92e293 (patch)
treecefaf3f99f4d2a1b97c17511da9685fcc4a253ba /xmake/modules/detect/tools/gcc
parentdb90d109c6ccf2545e8a3ae186ddfea1c99be61f (diff)
add has_flags for armclang
Diffstat (limited to 'xmake/modules/detect/tools/gcc')
-rw-r--r--xmake/modules/detect/tools/gcc/has_flags.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua
index b8e63423a..8f019a36a 100644
--- a/xmake/modules/detect/tools/gcc/has_flags.lua
+++ b/xmake/modules/detect/tools/gcc/has_flags.lua
@@ -73,6 +73,21 @@ function _get_extension(opt)
return (opt.program:endswith("++") or opt.flagkind == "cxxflags") and ".cpp" or (table.wrap(language.sourcekinds()[opt.toolkind or "cc"])[1] or ".c")
end
+-- has `-S` flag?
+function _has_flag_S(opt)
+ local has_flag_S = _g.has_flag_S
+ if has_flag_S == nil then
+ if opt.program:find("armclang", 1, true) then
+ -- it is disallowed in ARM compiler
+ has_flag_S = false
+ else
+ has_flag_S = true
+ end
+ _g.has_flag_S = has_flag_S
+ end
+ return has_flag_S
+end
+
-- try running to check flags
function _check_try_running(flags, opt, islinker)
@@ -83,13 +98,18 @@ function _check_try_running(flags, opt, islinker)
end
-- check flags for linker
+ local tmpfile = os.tmpfile()
if islinker then
- return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile), opt)
+ return _try_running(opt.program, table.join(flags, "-o", tmpfile, sourcefile), opt)
end
-- check flags for compiler
-- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage
- return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile), opt)
+ local extraflags = {}
+ if _has_flag_S(opt) then
+ table.insert(extraflags, "-S")
+ end
+ return _try_running(opt.program, table.join(flags, extraflags, "-o", tmpfile, sourcefile), opt)
end
-- has_flags(flags)?