Skip to content

Commit ddb472e

Browse files
committed
gcc: refactor the probe for available gcc flags
... so that we can easily probe for additional flags. No change in behavior intended with this commit. Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122623
1 parent 62de9a5 commit ddb472e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

csmock/plugins/gcc.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343

4444
SANITIZER_CAPTURE_DIR = "/builddir/gcc-sanitizer-capture"
4545

46+
# use the following flags only if they are supported by gcc in the chroot
47+
GCC_ANALYZER_NEW_FLAGS = [
48+
"-fdiagnostics-text-art-charset=none",
49+
]
50+
51+
4652
class PluginProps:
4753
def __init__(self):
4854
self.description = "Plugin capturing GCC warnings, optionally with customized compiler flags."
@@ -272,10 +278,13 @@ def csgcca_hook(results, mock):
272278
"disabling the tool" % analyzer_bin, ec=0)
273279
return 0
274280

275-
# use -fdiagnostics-text-art-charset=none if supported by gcc in the chroot
276-
flag = "-fdiagnostics-text-art-charset=none"
277-
if 0 == mock.exec_mockbuild_cmd(f"{cmd} {flag}"):
278-
props.env["CSGCCA_ADD_OPTS"] = flag
281+
# check for useful GCC flags that were introduced in newer GCC versions
282+
add_flags = [
283+
flag for flag in GCC_ANALYZER_NEW_FLAGS
284+
if 0 == mock.exec_mockbuild_cmd(f"{cmd} {flag}")
285+
]
286+
if add_flags:
287+
props.env["CSGCCA_ADD_OPTS"] = ":".join(add_flags)
279288

280289
if args.gcc_analyzer_bin:
281290
# create an executable shell script to wrap the custom gcc binary

0 commit comments

Comments
 (0)