Correct Build Failures with GCC-15 and CLANG
cover Correct Build Failures with GCC-15 and CLANG
1. Correct GRUB build with GCC >= 15 due to new GNULIB compile warning detected by GCC.
Pull in gnulib fix to allow base64.c to compile using GCC 15 or newer.
Pulled from: GNULIB commit 25df6dc4253480a343dde3376ce6fd99c316a532
GCC 15 adds a new compiler warning "-Wunterminated-string-initialization" that will trigger what is considered a false-positive in base64.c as this array is not treated as a string but an array of characters so the lack of NULL string terminator is expected.
GCC team has added ability to flag such instances of arrays that the compiler may think are strings as "nonstring" arrays to avoid this
warning: _attribute_((nonstring)). Reference this GCC discussion for more details:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178
Tested that the compile now succeeds using current mainline development GCC, build still works with GCC 12.2.0, and build still works with CLANG 14.0.6.
2. Correct GRUB build with CLANG due to a regression in grub-protect.c
util/grub-protect: Correct uninit 'err' Variable
In function protect_tpm2_export_tpm2key, the 'err' variable is uninitialized in the normal (error free) path, so ensure this defaults to GRUB_ERR_NONE.
This causes the GRUB build to fail with clang (observed with clang-14).
Andrew Hamilton (2):
gnulib: Add patch to allow GRUB w/GCC-15 compile util/grub-protect: Correct uninit 'err' Variable
bootstrap.conf | 1 + grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch | 11 +++++++++++ util/grub-protect.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch
Signature · 7 lines
2.39.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/2 gnulib: Add patch to allow GRUB w/GCC-15 compile
Pull in gnulib fix to allow base64.c to compile using GCC 15 or newer.
Pulled from: GNULIB commit 25df6dc4253480a343dde3376ce6fd99c316a532
GCC 15 adds a new compiler warning "-Wunterminated-string-initialization" that will trigger what is considered a false-positive in base64.c as this array is not treated as a string but an array of characters so the lack of NULL string terminator is expected.
GCC team has added ability to flag such instances of arrays that the compiler may think are strings as "nonstring" arrays to avoid this
warning: _attribute_((nonstring)).
--- bootstrap.conf | 1 + grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch
bootstrap.conf +1 -0
@@ -85,6 +85,7 @@ bootstrap_post_import_hook () { # changes to gnulib and update the hash above when they've merged. Do not # add new patches here. patch -d grub-core/lib/gnulib -p2 < grub-core/lib/gnulib-patches/fix-width.patch + patch -d grub-core/lib/gnulib -p2 < grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch for patchname in \ 0001-Support-POTFILES-shell \
grub-core/lib/gnulib-patches/gcc-15-compile-fix.patch new file +11 -0
@@ -0,0 +1,11 @@ +--- a/lib/base64.c ++++ b/lib/base64.c +@@ -61,7 +61,7 @@ + return ch; + } + +-static const char b64c[64] = ++static const char b64c[64] _GL_ATTRIBUTE_NONSTRING = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + /* Base64 encode IN array of size INLEN into OUT array. OUT needs
Signature · 7 lines
2.39.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 util/grub-protect: Correct uninit 'err' Variable
In reply to Andrew HamiltonIn function protect_tpm2_export_tpm2key, the 'err' variable is uninitialized in the normal (error free) path, so ensure this defaults to GRUB_ERR_NONE.
This causes the GRUB build to fail with clang (observed with clang-14).
--- util/grub-protect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/grub-protect.c +1 -1
@@ -703,7 +703,7 @@ protect_tpm2_export_tpm2key (const protect_args_t *args, tpm2_sealed_key_t *sealstruct grub_tpm2_buffer priv_buf;int i;int ret; -grub_err_t err; +grub_err_t err =GRUB_ERR_NONE ;if (der_buf ==NULL )return GRUB_ERR_BAD_ARGUMENT ;
Signature · 7 lines
2.39.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel