From: Andrew Hamilton <adhamilt@gmail.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, Andrew Hamilton <adhamilt@gmail.com>
Subject: [PATCH] libgcrypt: Allow GRUB to Build With Clang
Date: Sat, 30 Aug 2025 22:32:39 -0500 [thread overview]
Message-ID: <20250831033239.340703-1-adhamilt@gmail.com> (raw)
Attempts to build GRUB with Clang were failing due to errors
such as:
error: redefinition of typedef 'gcry_md_hd_t' is a C11 feature
Correct this by adding a compiler pramga to disable the
Clang "typedef-redefinition" warnings. This required an update
to crypto.h and the import_gcry.py script to add the pragma
to libgcrypt-grub's types.h due to "u16" and similar types.
Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
---
include/grub/crypto.h | 9 +++++++++
util/import_gcry.py | 6 +++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/grub/crypto.h b/include/grub/crypto.h
index b0d7add1d..55e21de6f 100644
--- a/include/grub/crypto.h
+++ b/include/grub/crypto.h
@@ -245,6 +245,15 @@ typedef struct gcry_md_spec
struct gcry_md_spec *next;
} gcry_md_spec_t;
+/*
+ * Clang defaults to flagging type redefinitions as warnings.
+ * A few "forward declarations" in this file are needed due
+ * to inter-relationship complexities between GRUB and
+ * libgcrypt.
+ */
+#ifdef __clang__
+#pragma GCC diagnostic ignored "-Wtypedef-redefinition"
+#endif
typedef struct gcry_md_handle*gcry_md_hd_t;
struct gcry_mpi;
diff --git a/util/import_gcry.py b/util/import_gcry.py
index 086bde77c..1e23ee760 100644
--- a/util/import_gcry.py
+++ b/util/import_gcry.py
@@ -608,7 +608,11 @@ with codecs.open (os.path.join (cipher_dir_out, "crypto.lst"), "w", "utf-8") as
continue
with codecs.open (infile, "r", "utf-8") as f:
if src == "types.h":
- fw.write (f.read ().replace ("float f;", "").replace ("double g;", ""))
+ fw.write (f.read ().replace ("float f;", "").replace ("double g;", "") \
+ .replace("#ifndef HAVE_BYTE",
+ "#ifdef __clang__\n" \
+ "#pragma GCC diagnostic ignored \"-Wtypedef-redefinition\"\n#endif\n" \
+ "#ifndef HAVE_BYTE"))
continue
if src == "cipher-proto.h":
--
2.47.2
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2025-08-31 3:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-31 3:32 Andrew Hamilton [this message]
2025-09-02 13:24 ` [PATCH] libgcrypt: Allow GRUB to Build With Clang Daniel Kiper via Grub-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250831033239.340703-1-adhamilt@gmail.com \
--to=adhamilt@gmail.com \
--cc=daniel.kiper@oracle.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).