-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[compiler-rt] allow removing libc dependency on Android #152394
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
i worry a bit about the proximity of "allow removing" and "make it easy for the actual Android llvm build to fuck up and accidentally ship with all the __isOSVersionAtLeast() stuff broken". i guess i don't really understand the upside to this, and the downside for the actual shipping configuration worries me. if this is useful, should it be a separate opt-in option? |
+pirama for his thoughts. |
This is important feedback and why PRs get reviewed. :) We could put The upside is that we have an initial compiler-rt without a dependency to libc, which is useful for building Bionic libc. The includes could also be put behind the baremetal build flag instead of checking for headers. Why do the non-Android Linux includes test for |
as the main bionic maintainer for the last 10+ years, this is the bit i don't get --- bionic builds just fine :-) (but this is also why i added pirama, because he owns the "building llvm" side of android, and he might be familiar with whatever llvm bootstrapping problem (?) you're talking about...) |
Oops.. Bionic does use Just as a side note: Doesn't |
efriedma-quic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upside is that we have an initial compiler-rt without a dependency to libc, which is useful for building Bionic libc.
as the main bionic maintainer for the last 10+ years, this is the bit i don't get --- bionic builds just fine :-)
To build a cross-compile toolchain from scratch, you usually install libc headers, then build compiler-rt.builtins, then build the complete libc, then build whatever else you need.
The NixOS developers weren't aware of this, or didn't like it, so they came up with a different way to build libc. First, build a subset of compiler-rt.builtins with COMPILER_RT_BAREMETAL_BUILD. Then build libc. Then build compiler-rt.builtins.
I don't think we want to endorse using builtins built with COMPILER_RT_BAREMETAL_BUILD on a non-baremetal platform; it has other side-effects that are potentially problematic.
We could maybe consider adding a new dedicated CMake flag for this purpose... but the NixOS approach doesn't really seem like an improvement over just doing what everyone else does.
|
We've written up #127227 for the more general issue of trying to keep things acyclic. What exactly are you worried about going wrong with a bare-metal build in a non-bare platform? Yes, I could imagine there being something that uses a privileged instruction or whatever. Conversely, I also imagine when doing the headers trick an accidental infinite recursion, where a built-in that uses libc gets injected by the compiler into libc. It's not obviously clear to me which of these bad things more likely. If a new flag is the approach that is the most likely to be accepted, some way to get to the intersection of the freestanding and hosted built-ins sets (only ones that would appear in both), then I think we would be happy to contribute that. |
For example, in compiler-rt/lib/builtins/cpu_model/aarch64.c, for baremetal targets, we skip resolving CPU features. So we might break CPU feature detection if you use the library in the wrong place. If you want a compiler-rt subset, you need to completely exclude that file.
If there's a distinct flag for it, and the resulting library has a different name from the regular compiler-rt.builtins.a, I think I'm fine with it. |
|
Great! That example makes sense to me --- I agree the right thing to do with the flag is indeed to drop that builtin entirely. Anything that would use it will instead gets a link error. This, we'll know when building libc against such a builtins library that we neither make dubious assumptions about CPU features, nor reenter libc in dubious ways.
I am OK making the upstream build system do that if you prefer, but just so you know, we would probably keep the same name in Nixpkgs. We already use |
#127227
NixOS/nixpkgs#431477