From 7c0e758572c735180d0ddcf56e53aaa0b8470894 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Wed, 13 May 2026 10:47:05 +0100 Subject: [PATCH 1/2] Disable -O3 for GCC 15 We found out that -O3 was leading to garbage values in tricky interpolation kernels with GCC 15 on both Ubuntu 26.04 and Arch. This will allow us to support Ubuntu 26.04. --- pyop2/compilation.py | 75 ++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/pyop2/compilation.py b/pyop2/compilation.py index f37599382b..947820fa44 100644 --- a/pyop2/compilation.py +++ b/pyop2/compilation.py @@ -278,33 +278,35 @@ def ld(self): return self._ld @property - def cflags(self): - cflags = self._cflags + self._extra_compiler_flags + self.bugfix_cflags - if self._debug: - cflags += self._debugflags - else: - cflags += self._optflags - cflags += tuple(shlex.split(configuration["cflags"])) - return cflags + def cflags(self) -> tuple[str, ...]: + return ( + *self._cflags, + *(self._debugflags if self._debug else self._optflags), + *self.bugfix_cflags, + *self._extra_compiler_flags, + *shlex.split(configuration["cflags"]), + ) @property - def cxxflags(self): - cxxflags = self._cxxflags + self._extra_compiler_flags + self.bugfix_cflags - if self._debug: - cxxflags += self._debugflags - else: - cxxflags += self._optflags - cxxflags += tuple(shlex.split(configuration["cxxflags"])) - return cxxflags + def cxxflags(self) -> tuple[str, ...]: + return ( + *self._cxxflags, + *(self._debugflags if self._debug else self._optflags), + *self.bugfix_cflags, + *self._extra_compiler_flags, + *shlex.split(configuration["cxxflags"]), + ) @property - def ldflags(self): - ldflags = self._ldflags + self._extra_linker_flags - ldflags += tuple(shlex.split(configuration["ldflags"])) - return ldflags + def ldflags(self) -> tuple[str, ...]: + return ( + *self._ldflags, + *self._extra_linker_flags, + *shlex.split(configuration["ldflags"]), + ) @property - def bugfix_cflags(self): + def bugfix_cflags(self) -> tuple[str, ...]: return () @@ -348,30 +350,15 @@ class LinuxGnuCompiler(Compiler): _debugflags = ("-O0", "-g") @property - def bugfix_cflags(self): + def bugfix_cflags(self) -> tuple[str, ...]: """Flags to work around bugs in compilers.""" - ver = self._version - cflags = () - if Version("4.8.0") <= ver < Version("4.9.0"): - # GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61068 - cflags = ("-fno-ivopts",) - if Version("5.0") <= ver <= Version("5.4.0"): - cflags = ("-fno-tree-loop-vectorize",) - if Version("6.0.0") <= ver < Version("6.5.0"): - # GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79920 - cflags = ("-fno-tree-loop-vectorize",) - if Version("7.1.0") <= ver < Version("7.1.2"): - # GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81633 - cflags = ("-fno-tree-loop-vectorize",) - if Version("7.3") <= ver <= Version("7.5"): - # GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90055 - # See also https://github.com/firedrakeproject/firedrake/issues/1442 - # And https://github.com/firedrakeproject/firedrake/issues/1717 - # Bug also on skylake with the vectoriser in this - # combination (disappears without - # -fno-tree-loop-vectorize!) - cflags = ("-fno-tree-loop-vectorize", "-mno-avx512f") - return cflags + cflags = [] + if not self._debug and self._version >= Version("15"): + # Disable '-O3' for GCC versions >=15 because it causes issues with + # complex interpolation kernels + # TODO: revisit this in later GCC releases to see if the issue is fixed + cflags.append("-O2") + return tuple(cflags) class LinuxClangCompiler(Compiler): From 0cf0ed202c0afb94d9edd8d94075f73842abcdf7 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Wed, 13 May 2026 11:29:13 +0100 Subject: [PATCH 2/2] Add ref to issue about max version --- pyop2/compilation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyop2/compilation.py b/pyop2/compilation.py index 947820fa44..4b0aa5f6cc 100644 --- a/pyop2/compilation.py +++ b/pyop2/compilation.py @@ -356,7 +356,9 @@ def bugfix_cflags(self) -> tuple[str, ...]: if not self._debug and self._version >= Version("15"): # Disable '-O3' for GCC versions >=15 because it causes issues with # complex interpolation kernels - # TODO: revisit this in later GCC releases to see if the issue is fixed + # TODO: revisit this in later GCC releases to see if we can set a + # maximum version constraint + # (see https://github.com/firedrakeproject/firedrake/issues/5107) cflags.append("-O2") return tuple(cflags)