Replies: 4 comments
-
we don't support prebuilt libraries on crates.io. any change to this policy will have to go through the RFC process.
we usually decide this on a case-by-case basis in the team meeting and grant exceptions for cases where there are no viable alternatives.
since this is primarily about pre-built libraries and less about the size increase this will likely need a wider discussion in an RFC.
I personally don't know enough about clang to decide what the best alternative would be. |
Beta Was this translation helpful? Give feedback.
-
rustc already contains a libllvm, is that not enough? Anyway this sounds like either
|
Beta Was this translation helpful? Give feedback.
-
Thanks for starting a discussion about this @madsmtm.
I don't really know of a way to reduce the size further beyond what I've already done in llvmup/toolchains, which really only amounts to selecting the minimum viable set of components and compiling for
I actually think the install process might not be so bad in this sense. The way I had intended this to work is the component tarballs are streamed through a download, checksum, unpack pipeline asynchronously and simultaneously. In my limited testing it shouldn't be take more than a couple minutes for a full toolchain install ( Of course, that's still not "fast", but I think the more difficult issue is the fact that downloading artifacts in Aside from security concerns, there's also no way to provide feedback to the user that the download is happening, since even
This could be interesting. I suspect the current size limit would still be hit in most cases but it could certainly reduce the maximum size by quite a lot, at the cost of additional complexity in producing the builds.
One thing to note is that, although initial compile times would be quite long, subsequent builds can be very fast by using That might make building from source more acceptable, but still leaves the size limit issue, since the LLVM source tree is 122MB.
If this could be made to work somehow it would almost seem like the ideal solution in the long run. The potential breakage from updating issue is probably unavoidable (without a huge maintenance overhead) since the LLVM C++ APIs don't have a stable interface. That would probably mean that a range of |
Beta Was this translation helpful? Give feedback.
-
Generally, no. The Sometimes these are described as libTooling, although in our case we actually potentially need access to the full set libraries, which requires a proper LLVM component distribution, as described in the There is reason to advocate for more general access to these libraries in any case, since the ability to interface with MLIR, ClangIR, and other LLVM ecosystem components would be useful. |
Beta Was this translation helpful? Give feedback.
-
Greetings! @silvanshade and I are discussing prebuilding Clang/LLVM libraries in madsmtm/objc2#345, and I have a few questions about that for the crates.io team.
Motivation
There exists several tools in the ecosystem that uses libclang, usually to do some sort of C/C++ to Rust transformation. Prominent examples include
bindgen
,autocxx
and my own tool for generatingicrate
.This is nice because
libclang
can be installed fairly easily on most operating systems, and the API is quite stable, even between major versions. It is, sadly, also limited in the kind of semantic analysis you can do, since there are many C/C++ quirks and attributes that are not exposed in its API.So instead of using
libclang
, another option would be to use Clang/LLVM libraries directly. This unfortunately forces downstream users of your crate to somehow get/build a compatible version of Clang/LLVM libraries outside of Cargo, which is difficult and annoying for users, and has issues with reproducibility. This is the approach taken byc2rust
andrustc
itself (although the bootstrap script mitigates it by providing prebuilt libraries (example url)).Proposed solution
To make it easier to use Clang/LLVM libraries directly from Rust, I propose developing a crate that helps ensure that the desired Clang/LLVM libraries is available (potentially integrated with the existing
llvm-sys
crate). This crate will bundle the required sources in the crate itself (a quick test says this will be around ~30MB).These sadly take a long time to compile, so to mitigate that issue, the crate will supply prebuilt libraries for common target platforms (of course, user configurable, I'm aware of the
serde_derive
suddenly shipping a binary debacle a while ago).These will also be uploaded to crates.io, and the correct libraries will be chosen by Cargo in a similar manner as is done for
windows-sys
. The size of the LLVM libraries are ~150MB, Clang libraries ~85MB and maybe also Clang binaries ~30MB (all after being compressed by Cargo). We would need one crate per supported target, so probably a few GB in total. @silvanshade may be able to answer if these can be mader smaller.The current upload size limit is 10MiB, which the proposed crates would clearly hit.
Questions
What is your policy on prebuilt libraries on crates.io?
What is your policy on increasing this size limit for a crate?
What about for something like this, which is important for
bindgen
(an official Rust project), and has the potential to vastly improving Rust's user story on interacting with C/C++/Objective-C?I can see that storing several GBs of data in total is troublesome, but is there another number you would be more comfortable with? (If it helps, we would be limiting ourselves (barring critical bugs) to releasing only major versions of Clang/LLVM, to reduce the strain on crates.io's servers).
If this is not acceptable, which alternative would the crates.io team recommend that we do instead? (Either from the list below, or other alternatives).
Alternatives
rustup
component.bindgen
as arustup
component.bindgen v1.0
.Prior art
Previously discussed in rust-lang/rust-bindgen#918.
The
openssl
crate has an option to build OpenSLL from sources, which are distributed via.openssl-src
. The download size for that is ~8MB.Beta Was this translation helpful? Give feedback.
All reactions