From: Christian Weisgerber Subject: [llvm22] devel/*/gdb build fix To: ports@openbsd.org Date: Wed, 20 May 2026 12:06:35 +0200 devel/riscv32-esp-elf/gdb devel/xtensa-esp32-elf/gdb devel/xtensa-esp32s2-elf/gdb devel/xtensa-esp32s3-elf/gdb devel/xtensa-lx106-elf/binutils Those all fail with the same error: gdb/gdbsupport/enum-flags.h:87:34: error: non-type template argument is not a constant expression 87 | integer_for_size(T (-1) < T (0))>::type | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ llvm22 belatedly turned this into a hard error, because "casting integers to enums outside of the valid range of the enum is UB". https://github.com/llvm/llvm-project/issues/59036 gdb upstream rewrote that code extensively: https://sourceware.org/git/?p=binutils-gdb.git;a=history;f=gdbsupport/enum-flags.h;h=6dc602bd0b9db16b1b3629dc8881ca93437d3a5a;hb=HEAD Instead I found this plausible-looking solution: typedef typename - integer_for_size(T (-1) < T (0))>::type + integer_for_size::lowest() < 0)>::type type; Anybody who actually knows C++? OK? devel/*/gdb: unbreak build with llvm22 and revert prior workaround LLVM 22 has changed -Wenum-constexpr-conversion into a hard error. Revert the workaround introduced for LLVM 16 and replace old idiom that is undefined behavior. M devel/riscv32-esp-elf/gdb/Makefile | 1+ 0- M devel/riscv32-esp-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h | 3+ 14- D devel/riscv32-esp-elf/gdb/patches/patch-include_diagnostics_h | 0+ 33- M devel/xtensa-esp32-elf/gdb/Makefile | 1+ 1- M devel/xtensa-esp32-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h | 3+ 13- D devel/xtensa-esp32-elf/gdb/patches/patch-include_diagnostics_h | 0+ 32- M devel/xtensa-esp32s2-elf/gdb/Makefile | 1+ 1- M devel/xtensa-esp32s2-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h | 3+ 13- D devel/xtensa-esp32s2-elf/gdb/patches/patch-include_diagnostics_h | 0+ 32- M devel/xtensa-esp32s3-elf/gdb/Makefile | 1+ 1- M devel/xtensa-esp32s3-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h | 3+ 13- D devel/xtensa-esp32s3-elf/gdb/patches/patch-include_diagnostics_h | 0+ 32- M devel/xtensa-lx106-elf/binutils/Makefile | 1+ 1- M devel/xtensa-lx106-elf/binutils/patches/patch-gdb_common_enum-flags_h | 3+ 13- D devel/xtensa-lx106-elf/binutils/patches/patch-include_diagnostics_h | 0+ 32- 15 files changed, 20 insertions(+), 231 deletions(-) commit - fc0a1cf5e26d7b745bb803ab264027ee89fd8df2 commit + 89eafba83ce511a32b69fa520963820e4cab86e7 blob - 31e61a51f35ff5c3659e641f7f95c3382def7155 blob + 93771b9ad0062f1c62a3bde6d36d0de7aeb2200d --- devel/riscv32-esp-elf/gdb/Makefile +++ devel/riscv32-esp-elf/gdb/Makefile @@ -2,6 +2,7 @@ COMMENT = gdb for ${CONFIG} cross-development VERSION = 2.35.1.2021.2 PKGNAME = ${CONFIG}-gdb-${VERSION} +REVISION = 0 GH_ACCOUNT = espressif GH_PROJECT = binutils-gdb blob - 3f981d279716915c3d883249d12b759b6e967fa8 blob + 8a154d935d86e172895e03e11dfc5acd26c408a4 --- devel/riscv32-esp-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h +++ devel/riscv32-esp-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h @@ -1,23 +1,12 @@ - -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - Index: gdb/gdbsupport/enum-flags.h --- gdb/gdbsupport/enum-flags.h.orig +++ gdb/gdbsupport/enum-flags.h -@@ -81,9 +81,12 @@ template<> struct integer_for_size<8, 1> { typedef int - template +@@ -82,7 +82,7 @@ template struct enum_underlying_type { -+ DIAGNOSTIC_PUSH -+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type +- integer_for_size(T (-1) < T (0))>::type ++ integer_for_size::lowest() < 0)>::type type; -+ DIAGNOSTIC_POP }; - template blob - f6db6633a990dab2ca32a5a37736c53e77048a27 (mode 644) blob + /dev/null --- devel/riscv32-esp-elf/gdb/patches/patch-include_diagnostics_h +++ /dev/null @@ -1,33 +0,0 @@ - -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - -Index: include/diagnostics.h ---- include/diagnostics.h.orig -+++ include/diagnostics.h -@@ -63,6 +63,11 @@ - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ - DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") - -+# if __has_warning ("-Wenum-constexpr-conversion") -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ -+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") -+# endif -+ - #elif defined (__GNUC__) /* GCC */ - - # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ -@@ -102,6 +107,10 @@ - - #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL -+#endif -+ -+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION - #endif - - #endif /* DIAGNOSTICS_H */ blob - 7c055f2818a2efac475c03850a029aba1e727d2e blob + 7bc41be920afb8b487d5ecbd7c5a909d125d9fdc --- devel/xtensa-esp32-elf/gdb/Makefile +++ devel/xtensa-esp32-elf/gdb/Makefile @@ -2,7 +2,7 @@ COMMENT = gdb for ${CONFIG} cross-development VERSION = 2.35.1.2021.2 PKGNAME = ${CONFIG}-gdb-${VERSION} -REVISION = 1 +REVISION = 2 GH_ACCOUNT = espressif GH_PROJECT = binutils-gdb blob - 8d699ad955a9f986eed6d9b01ef5001fcd8dd744 blob + 8a154d935d86e172895e03e11dfc5acd26c408a4 --- devel/xtensa-esp32-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h +++ devel/xtensa-esp32-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h @@ -1,22 +1,12 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - Index: gdb/gdbsupport/enum-flags.h --- gdb/gdbsupport/enum-flags.h.orig +++ gdb/gdbsupport/enum-flags.h -@@ -81,9 +81,12 @@ template<> struct integer_for_size<8, 1> { typedef int - template +@@ -82,7 +82,7 @@ template struct enum_underlying_type { -+ DIAGNOSTIC_PUSH -+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type +- integer_for_size(T (-1) < T (0))>::type ++ integer_for_size::lowest() < 0)>::type type; -+ DIAGNOSTIC_POP }; - template blob - 8c4b0d46e7bc95fb99299d7b18ffd1a9eba9fdea (mode 644) blob + /dev/null --- devel/xtensa-esp32-elf/gdb/patches/patch-include_diagnostics_h +++ /dev/null @@ -1,32 +0,0 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - -Index: include/diagnostics.h ---- include/diagnostics.h.orig -+++ include/diagnostics.h -@@ -63,6 +63,11 @@ - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ - DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") - -+# if __has_warning ("-Wenum-constexpr-conversion") -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ -+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") -+# endif -+ - #elif defined (__GNUC__) /* GCC */ - - # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ -@@ -102,6 +107,10 @@ - - #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL -+#endif -+ -+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION - #endif - - #endif /* DIAGNOSTICS_H */ blob - a2bc179f1a22c91ad8896c6819c331e3d96a285e blob + 7c055f2818a2efac475c03850a029aba1e727d2e --- devel/xtensa-esp32s2-elf/gdb/Makefile +++ devel/xtensa-esp32s2-elf/gdb/Makefile @@ -2,7 +2,7 @@ COMMENT = gdb for ${CONFIG} cross-development VERSION = 2.35.1.2021.2 PKGNAME = ${CONFIG}-gdb-${VERSION} -REVISION = 0 +REVISION = 1 GH_ACCOUNT = espressif GH_PROJECT = binutils-gdb blob - 8d699ad955a9f986eed6d9b01ef5001fcd8dd744 blob + 8a154d935d86e172895e03e11dfc5acd26c408a4 --- devel/xtensa-esp32s2-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h +++ devel/xtensa-esp32s2-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h @@ -1,22 +1,12 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - Index: gdb/gdbsupport/enum-flags.h --- gdb/gdbsupport/enum-flags.h.orig +++ gdb/gdbsupport/enum-flags.h -@@ -81,9 +81,12 @@ template<> struct integer_for_size<8, 1> { typedef int - template +@@ -82,7 +82,7 @@ template struct enum_underlying_type { -+ DIAGNOSTIC_PUSH -+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type +- integer_for_size(T (-1) < T (0))>::type ++ integer_for_size::lowest() < 0)>::type type; -+ DIAGNOSTIC_POP }; - template blob - 8c4b0d46e7bc95fb99299d7b18ffd1a9eba9fdea (mode 644) blob + /dev/null --- devel/xtensa-esp32s2-elf/gdb/patches/patch-include_diagnostics_h +++ /dev/null @@ -1,32 +0,0 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - -Index: include/diagnostics.h ---- include/diagnostics.h.orig -+++ include/diagnostics.h -@@ -63,6 +63,11 @@ - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ - DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") - -+# if __has_warning ("-Wenum-constexpr-conversion") -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ -+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") -+# endif -+ - #elif defined (__GNUC__) /* GCC */ - - # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ -@@ -102,6 +107,10 @@ - - #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL -+#endif -+ -+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION - #endif - - #endif /* DIAGNOSTICS_H */ blob - a2bc179f1a22c91ad8896c6819c331e3d96a285e blob + 7c055f2818a2efac475c03850a029aba1e727d2e --- devel/xtensa-esp32s3-elf/gdb/Makefile +++ devel/xtensa-esp32s3-elf/gdb/Makefile @@ -2,7 +2,7 @@ COMMENT = gdb for ${CONFIG} cross-development VERSION = 2.35.1.2021.2 PKGNAME = ${CONFIG}-gdb-${VERSION} -REVISION = 0 +REVISION = 1 GH_ACCOUNT = espressif GH_PROJECT = binutils-gdb blob - 8d699ad955a9f986eed6d9b01ef5001fcd8dd744 blob + 8a154d935d86e172895e03e11dfc5acd26c408a4 --- devel/xtensa-esp32s3-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h +++ devel/xtensa-esp32s3-elf/gdb/patches/patch-gdb_gdbsupport_enum-flags_h @@ -1,22 +1,12 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - Index: gdb/gdbsupport/enum-flags.h --- gdb/gdbsupport/enum-flags.h.orig +++ gdb/gdbsupport/enum-flags.h -@@ -81,9 +81,12 @@ template<> struct integer_for_size<8, 1> { typedef int - template +@@ -82,7 +82,7 @@ template struct enum_underlying_type { -+ DIAGNOSTIC_PUSH -+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type +- integer_for_size(T (-1) < T (0))>::type ++ integer_for_size::lowest() < 0)>::type type; -+ DIAGNOSTIC_POP }; - template blob - 8c4b0d46e7bc95fb99299d7b18ffd1a9eba9fdea (mode 644) blob + /dev/null --- devel/xtensa-esp32s3-elf/gdb/patches/patch-include_diagnostics_h +++ /dev/null @@ -1,32 +0,0 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - -Index: include/diagnostics.h ---- include/diagnostics.h.orig -+++ include/diagnostics.h -@@ -63,6 +63,11 @@ - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ - DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") - -+# if __has_warning ("-Wenum-constexpr-conversion") -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ -+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") -+# endif -+ - #elif defined (__GNUC__) /* GCC */ - - # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ -@@ -102,6 +107,10 @@ - - #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL -+#endif -+ -+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION - #endif - - #endif /* DIAGNOSTICS_H */ blob - 38088026951cf934adc8e854df110b24ac29fcfa blob + dc46213287e5bcfc745042f5e8ba4bc87f512238 --- devel/xtensa-lx106-elf/binutils/Makefile +++ devel/xtensa-lx106-elf/binutils/Makefile @@ -5,7 +5,7 @@ COMMENT = binutils for ${CONFIG} cross-development VERSION = 2.32 DISTNAME = binutils-${VERSION} PKGNAME = ${CONFIG}-binutils-${VERSION} -REVISION = 1 +REVISION = 2 GH_ACCOUNT = bminor GH_PROJECT = binutils-gdb blob - 21ded931692cd932e669c11e144939d7283f2eea blob + 97c1064e28c101ca733095fbb57c4751e5e7d6ab --- devel/xtensa-lx106-elf/binutils/patches/patch-gdb_common_enum-flags_h +++ devel/xtensa-lx106-elf/binutils/patches/patch-gdb_common_enum-flags_h @@ -1,22 +1,12 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - Index: gdb/common/enum-flags.h --- gdb/common/enum-flags.h.orig +++ gdb/common/enum-flags.h -@@ -81,9 +81,12 @@ template<> struct integer_for_size<8, 1> { typedef int - template +@@ -82,7 +82,7 @@ template struct enum_underlying_type { -+ DIAGNOSTIC_PUSH -+ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type +- integer_for_size(T (-1) < T (0))>::type ++ integer_for_size::lowest() < 0)>::type type; -+ DIAGNOSTIC_POP }; - template blob - 8c4b0d46e7bc95fb99299d7b18ffd1a9eba9fdea (mode 644) blob + /dev/null --- devel/xtensa-lx106-elf/binutils/patches/patch-include_diagnostics_h +++ /dev/null @@ -1,32 +0,0 @@ -From ae61525fcf456ab395d55c45492a106d1275873a Mon Sep 17 00:00:00 2001 -From: Simon Marchi -Date: Thu, 23 Feb 2023 12:35:40 -0500 -Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in - enum-flags.h - -Index: include/diagnostics.h ---- include/diagnostics.h.orig -+++ include/diagnostics.h -@@ -63,6 +63,11 @@ - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ - DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") - -+# if __has_warning ("-Wenum-constexpr-conversion") -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ -+ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") -+# endif -+ - #elif defined (__GNUC__) /* GCC */ - - # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ -@@ -102,6 +107,10 @@ - - #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL - # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL -+#endif -+ -+#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION -+# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION - #endif - - #endif /* DIAGNOSTICS_H */ -- Christian "naddy" Weisgerber naddy@mips.inka.de