-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM bindings have become incorrect in places. #17795
Comments
Just curious, what's bindgen? Are there docs on how to use it? |
@ahmedcharles I've updated the description with a link to bindgen. |
I spoke about this with @eddyb on IRC today. This is especially pernicious, because we could be accidentally getting UB in corner cases. A tactic to close this bug:
Humans looking at it will probably be needed, given that bindgen isn't perfect. |
I took a look at this, starting with the rather naive: #!/usr/bin/env sh
set -eu
LLVM_CONFIG_PATH=$(find build -name llvm-config -type f | head -n1)
CXX_FLAGS=$($LLVM_CONFIG_PATH --cxxflags)
echo CXX_FLAGS: $CXX_FLAGS
RUST_BACKTRACE=1 bindgen $@ src/rustllvm/rustllvm.h -o src/librustc_llvm/ffi.rs -- $CXX_FLAGS which produces the output:
|
Using
|
Ah, renaming
|
If someone's interested in this (like me, originally), I'll save you some time: The above PR #46353 was rejected due to A) bindgen needing an unwanted dependency and B) the team preferring a validation of the bindings over re-generating the bindings automatically via bindgen. (This is understandable, as the hand-written bindings are way nicer than bindgens output)
The way I see it, the validation can't be reliably automated at the moment unless Edit: Actually, it might be possible. For example. libz-sys uses |
I think the bindings should probably move to |
Oh, I didn't know a crate like that already existed. I'll take a look, maybe it's possible to get ctest to work with it. |
ctest still fails at parsing even after moving ffi.rs to |
feat: Load sysroot library via cargo metadata See rust-lang#128534, fixes rust-lang/rust-analyzer#7637 Requires a toolchain from 176e545 2024-08-04 or later to work.
Because of x86/x86_64 specifics, certain LLVM functions that used to return
unsigned int
and now returnunsigned long long
continue to be usable, ending up in truncated return values.This is just one example of such incorrectness arising over time, there could be more.
Would be nice if we could use bindgen every LLVM upgrade to verify our bindings (or just generate new ones).
The text was updated successfully, but these errors were encountered: