From 32fa15ce715e20617c01a1cfb02babd50a92e293 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 20 Aug 2022 22:12:04 +0800 Subject: add has_flags for armclang --- xmake/modules/detect/tools/gcc/has_flags.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'xmake/modules/detect/tools/gcc/has_flags.lua') 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)? -- cgit v1.3.1