Linux EFI development
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: rust-for-linux@vger.kernel.org
Cc: linux-efi@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH] rust: Omit visibility pragma when calling bindgen
Date: Mon, 23 Nov 2026 18:10:43 +0100	[thread overview]
Message-ID: <20261123171042.62348-2-ardb@kernel.org> (raw)

bindgen is used to create Rust FFI definitions from Linux kernel
headers, so that Rust code can call into C code.

bindgen is a generic tool that is typically used on C library headers in
user space, where hidden ELF symbols are never part of the public
library API, and therefore ignored.

The situation in the kernel is different: hidden visibility is used when
using PIC codegen, to force the compiler to omit GOT slots for
references to symbols with global linkage (and to allow the "i" inline
asm constraint to be used with global objects).

So withhold the #pragma when __BINDGEN__ is defined, so that bindgen
does not disregard the kernel's hidden symbols.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 include/linux/hidden.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/hidden.h b/include/linux/hidden.h
index 49a17b6b5962..e8d2844047d2 100644
--- a/include/linux/hidden.h
+++ b/include/linux/hidden.h
@@ -14,6 +14,11 @@
  * Fortunately, there is a way to inform the compiler that such symbol
  * references will be satisfied at link time rather than at load time, by
  * giving them 'hidden' visibility.
+ *
+ * Hidden symbols are ignored by bindgen, on the basis that they are never part
+ * of a public API, but this is not the case for the kernel.
  */
 
+#ifndef __BINDGEN__
 #pragma GCC visibility push(hidden)
+#endif
-- 
2.53.0


                 reply	other threads:[~2026-11-23 17:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261123171042.62348-2-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.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