fix(zephyr-sys): bindgen stddef.h not found error#133
Open
ttwards wants to merge 1 commit into
Open
Conversation
Fix bindgen build failure caused by missing system headers by: - Pass CC environment variable from CMake to cargo build/doc commands - Dynamically detect GCC toolchain path and version from CC variable - Add GCC include directory to clang arguments for bindgen - Create dummy arm_acle.h header to avoid ARM ACLE parsing errors The root cause was that bindgen couldn't find stddef.h and other GCC builtin headers because: 1. CC variable was not passed to cargo, preventing toolchain detection 2. GCC include path was not provided to clang 3. ARM ACLE headers caused constant expression errors in bindgen Tested on: qemu_cortex_m3, Zephyr SDK 0.17.2 Signed-off-by: ttwards <xuwenxi0517@gmail.com>
1 task
| .output().ok() | ||
| .and_then(|o| String::from_utf8(o.stdout).ok()) | ||
| .map(|v| v.trim().to_string()) | ||
| .unwrap_or("12.2.0".to_string()); |
Contributor
There was a problem hiding this comment.
Why are we defaulting to 12.2.0?
d3zd3z
requested changes
Oct 23, 2025
| let wrapper_path = PathBuf::from(env::var("WRAPPER_FILE").unwrap()); | ||
|
|
||
| // Get GCC toolchain info to find stddef.h | ||
| let cc = env::var("CC").unwrap_or_default(); |
Collaborator
There was a problem hiding this comment.
So, I don't think it is the right thing, ever to use the gcc compiler-specific header files with the clang compiler. Clang will have it's own version of these headers. Some platforms will have clang try to figure this out, but that doesn't happen everywhere, and I'm guessing you're running into that.
It's a little weird to try to figure out the clang headers, but it ends up being something like:
RESOURCE_DIR=$(${LIBCLANG_PATH}/../bin/clang --print-resource-dir)
Then the arguments to the clang invocation need to include: nostdinc (which I think must already be the case), and then -isystem $RESOURCE_DIR/include. This should get the versions of these headers that make sense with the clang compiler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix bindgen build failure caused by missing system headers by:
The root cause was that bindgen couldn't find stddef.h and other GCC builtin headers because:
Tested on: qemu_cortex_m3, Zephyr SDK 0.17.2