On Fri, Apr 18, 2025 at 9:44 PM Ben Wolsieffer ben.wolsieffer@hefring.com wrote:
FDPIC is only relevant with no-MMU targets, and then only for userspace. When configured for the arm-*-uclinuxfdpiceabi target, GCC enables FDPIC by default to facilitate compiling userspace programs. FDPIC is never used for the kernel, and we pass -mno-fdpic when building the kernel to override the default and make sure FDPIC is disabled.
Therefore, it is perfectly safe to omit that flag for kernel builds with Clang.
Thanks a lot for the details!
To clarify, this is for GCC kernel builds: skipping the flag is done for libclang under GCC builds (because `bindgen` always uses libclang, and `bindgen` is used by Rust to understand C headers).
So GCC will get the flag for the C side of the kernel builds, but libclang will not get the flag because Clang doesn't recognize it. Thus, if Clang vs. GCC differ in how they compute the layout of some type, then we would have an issue "mixing" them.
As you can imagine, GCC kernel builds with Rust enabled are a hack due to that, and it would be ideal to get `bindgen` to somehow be able to understand C headers as GCC does:
https://github.com/rust-lang/rust-bindgen/issues/1949
Cheers, Miguel