-
Notifications
You must be signed in to change notification settings - Fork 707
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
Unnamed types have a name when switching to llvm >= 16.0.0
#2488
Comments
We don't have any logic conditioned to I suspect the reason for this breakage is that either mangling or some other naming mechanism changed in EDIT: I closed this by accident 😅. I got confused between tabs. |
Hey @pvdrz, thanks for responding. Let us keep this issue open for a couple of days, I will try to come up with a reproducible example (though not sure how that will help if you cannot check this on Windows). All I can say is that, e.g., our MacOs runner uses LLVM 16.0.0 with exactly the same setup, and it does not fail, which to me means that this issue might be Windows-specific. |
We've found one bug that is presumably the source of this issue. Unnamed items.
I've made a repo that shows this issue. Most crucial details are below, otherwise repo is at https://github.com/CGMossa/clang_bug. Details
Given a file // Named enum
typedef enum
{
STATUS_OK,
STATUS_ERROR
} Status;
// Unnamed enum
enum
{
LEVEL_LOW,
LEVEL_MEDIUM,
LEVEL_HIGH
};
// Named struct
typedef struct
{
int x;
int y;
} Coordinate;
// Unnamed struct
struct
{
float width;
float height;
} rectangle;
// Named union
typedef union
{
int intValue;
double doubleValue;
char charValue;
} Data;
// Unnamed union
union
{
short s;
long l;
} number; And use clang::{Clang, Index};
fn main() {
// println!("clang version: {}", clang::get_version());
let clang = Clang::new().unwrap();
let idx = Index::new(&clang, false, false);
// let tu = idx.parser(source).parse().unwrap();
let tu = idx.parser("src/unnamed_items.c").parse().unwrap();
// dbg!(&tu);
// dbg!(tu.get_entity());
dbg!(tu.get_entity().get_children());
for ele in tu.get_entity().get_children() {
if let Some(name) = ele.get_name() {
println!("name: {name}");
}
if let Some(display_name) = ele.get_display_name() {
println!("display_name: {display_name}");
}
}
} We see this issue between different llvm versions.
LLVM 15
LLVM 16
|
so what's happening is that LLVM 16 on windows is adding Edit: if that's the case, I think we can do a fix from the |
No problem. If you're on discord https://discord.gg/dKPbdpgN or here is fine. |
Just to clarify a bit, when using LLVM 15, |
--allowlist-*
on Windows when switching to llvm >= 16.0.0
llvm >= 16.0.0
Looks like this is not only affecting Windows - at least on Fedora Linux 38, we also started to get strange build failures for Rust projects that use bindgen since the upgrade to LLVM / Clang 16 ... For example, the
|
The plot thickens :p |
llvm >= 16.0.0
llvm >= 16.0.0
I bisected the new unnamed output to llvm/llvm-project@19e984e. |
cc-ing @KyleMayes. Do you know if |
No, From my experience attempting to write tests for |
llvm >= 16.0.0
llvm >= 16.0.0
Ok thank you all, I installed the latest version of LLVM on my machine and can definitely see an issue. I'll try to come up with a fix soon :) Edit: surprise! so the issues I saw when compiling bindgen with LLVM 17 are related to C++ namespaces and not this issue. So we have to keep looking for it. |
@decathorpe, I have some questions for you given that you're the only person that has reported this issue on Linux . I took a look at your header file on github and based on the error you showed I narrowed the problematic code to: https://github.com/kkos/oniguruma/blob/078f95efd45ef5e266b67307e6b3c5ffc3de38ab/src/oniguruma.h#L785-L794 So inspired by that, I ran typedef union {
long l;
int c;
struct {
char* start;
char* end;
} s;
void* p;
int tag;
} OnigValue; And couldn't reproduce the issue. Could you confirm that this is the |
Even though we not use We have this function called Lines 95 to 98 in a968109
The "easy" fix would be to slap a We would have to look which of the calls to spelling is the one reporting the name of the type first and I suspect I have the right one but I don't have any way to test it (see previous comment) |
Hmm, For @Ilia-Kosenkov using the |
For more details see rust-lang/rust-bindgen#2488
With clang LLVM 16 rust-bindgen 0.56.0 is too old, see rust-lang/rust-bindgen#2319 rust-lang/rust-bindgen#2312 rust-lang/rust-bindgen#2488 rust-lang/rust-bindgen#2339 rust-lang/rust-bindgen#2325
Sorry for not using the issue template, I have no minimal reproducible example right now.
Hi. We at extendr/libR-sys use
bindgen
to generate bindings for a set of headers provided by the R programming language. We have a complicated setup which creates bindings for all three mainstream OSes. On Windows, we rely on theMSYS2
and its version ofLLVM
.Recently our CI for Windows started failing with the following errors:
warning: unused option: --allowlist-function
followed by a collection of|
-separated entries of our allow listwarning: unused option: --allowlist-var
warning: unused option: --allowlist-type
The builder configuration is (approximately) the following:
While it might be messy, you can see that we have some patterns specified for allow lists, and we have identical allow lists on all three OSes, and the allow list has not been recently changed.
I was able to locally reproduce this error if I install
llvm 16.0.0
or higher (this time I am talking about native Windows version), but if I roll back tollvm 15.0.7
, it works as before. This, to me, suggests that there is some (breaking?) change in, perhaps, CLI API or elsewhere that affects us.I tried to scout
clang-sys
and this repo, but found no relevant issues. I am aware that this could be a problem inclang-sys
, but I have a very limited understanding ofllvm
infrastructure, so I decided to start my investigation from here.The text was updated successfully, but these errors were encountered: