-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
The March LLVM rebranch turned on ODR checking for C, broke compiling Foundation for Android #64321
Comments
@vsapsai, I see that you work on these ODR issues a lot in clang. This error was around in clang before the rebranch but wasn't triggered until now: is it possible it was inadvertently enabled for Swift at some point? |
Looked into this further, the issue appears to be two definitions of Both should be identical but use different typedefs for This may make sense for user libraries, but causes problems like this for the rats nests' of C library headers. If I was able to use that latter feature to work around the problem on my Android CI today, by including This isn't sustainable though, as any random C module may include one or the other and then cause these clashes again. I think this should be loosened back to the way it was, ie compare the underlying types not the typedefs in a definition. @vsapsai, @avl-llvm, @JDevlieghere, let me know what you think. |
If a field has a different type name in different module, clang considered it as an ODR violation in C++ since 2017. My change is to bring the same kind of checking to C and Objective-C. The guard I have to admit ODR is C++ thing and I don't know what C requires for using the same name for different [even if interchangeable] entities. |
Thanks for the explanation and links, @vsapsai. I am not sure if this is the right approach for C, as it won't be a problem if there aren't multiple definitions with different typedefs, but maybe C sometimes requires this workaround. If this is the only multiply-defined C struct in Bionic, maybe this can be worked around. I see that your pull made it into the just-released clang 16: I will ask the Android NDK devs what they think, as they will have to update the NDK to use this clang soon. |
A fix has been merged in Bionic trunk, hopefully it will be the only one needed. Leaving this open until that makes it into a released Android NDK and no more problems are seen. |
NDK 26 with the linked fix doesn't show any other problems like this, so closing. |
Description
My daily Android CI started failing when building Foundation for the trunk SDK since the rebranch last week:
This seems like an incorrect error, as it knows the underlying type is always
long
but has now started complaining about the intermediate Ctypedef
names used.There have been no changes in libdispatch and nothing relevant in Foundation in the meantime, so the problem is clearly in the compiler or more specifically, the underlying libclang code it calls. I don't see anything relevant that changed in
lib/ClangImporter/
between the March 2 and March 6 snapshots, so most likely something in LLVM changed with the rebranch that is now affecting the Swift compiler, as this is an LLVM error message.Steps to reproduce
Build CoreFoundation for Android, either using my CI shown or natively in the Termux app.
Expected behavior
Foundation builds as always.
Environment
Additional context
The build still works for Android x86_64, probably because only the x86_64
asm/signal.h
includeslinux/time.h
, so the same header definition is used for both these corelibs on Android x86_64.@shahmishal, anyone else reporting a similar issue since the rebranch?
@compnerd, @hyp, @egorzhdan, let me know if one of you knows what's going on here.
The text was updated successfully, but these errors were encountered: