From ddb472e1248d63f3894e28205f2dadbe7c2696d7 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 28 Jan 2026 18:05:15 +0100 Subject: [PATCH 1/2] 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 --- csmock/plugins/gcc.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/csmock/plugins/gcc.py b/csmock/plugins/gcc.py index 41bfed7..b49ba43 100644 --- a/csmock/plugins/gcc.py +++ b/csmock/plugins/gcc.py @@ -43,6 +43,12 @@ SANITIZER_CAPTURE_DIR = "/builddir/gcc-sanitizer-capture" +# use the following flags only if they are supported by gcc in the chroot +GCC_ANALYZER_NEW_FLAGS = [ + "-fdiagnostics-text-art-charset=none", +] + + class PluginProps: def __init__(self): self.description = "Plugin capturing GCC warnings, optionally with customized compiler flags." @@ -272,10 +278,13 @@ def csgcca_hook(results, mock): "disabling the tool" % analyzer_bin, ec=0) return 0 - # use -fdiagnostics-text-art-charset=none if supported by gcc in the chroot - flag = "-fdiagnostics-text-art-charset=none" - if 0 == mock.exec_mockbuild_cmd(f"{cmd} {flag}"): - props.env["CSGCCA_ADD_OPTS"] = flag + # check for useful GCC flags that were introduced in newer GCC versions + add_flags = [ + flag for flag in GCC_ANALYZER_NEW_FLAGS + if 0 == mock.exec_mockbuild_cmd(f"{cmd} {flag}") + ] + if add_flags: + props.env["CSGCCA_ADD_OPTS"] = ":".join(add_flags) if args.gcc_analyzer_bin: # create an executable shell script to wrap the custom gcc binary From 41af877d4fa9d0f8cf0b4561918b931513808fbe Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 28 Jan 2026 18:05:15 +0100 Subject: [PATCH 2/2] gcc: use `-fanalyzer-assume-nothrow` with `--gcc-analyze` ... if the option is supported by gcc in the chroot. Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122623 --- csmock/plugins/gcc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/csmock/plugins/gcc.py b/csmock/plugins/gcc.py index b49ba43..b9bf9b2 100644 --- a/csmock/plugins/gcc.py +++ b/csmock/plugins/gcc.py @@ -45,6 +45,7 @@ # use the following flags only if they are supported by gcc in the chroot GCC_ANALYZER_NEW_FLAGS = [ + "-fanalyzer-assume-nothrow", "-fdiagnostics-text-art-charset=none", ]