Skip to content

Publishing self-contained static executable (with bundled libclang.a) #2767

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
ianks opened this issue Feb 23, 2024 · 3 comments
Open

Publishing self-contained static executable (with bundled libclang.a) #2767

ianks opened this issue Feb 23, 2024 · 3 comments

Comments

@ianks
Copy link

ianks commented Feb 23, 2024

One of the biggest pain points about using bindgen is installing libclang. It's a massive dependency to manage, and adds pain to the development and deployment of Rust apps. It would be nice if you could just run bindgen-cli-installer.sh and be done with it, whether you're compiling in CI or on a laptop.

The downside is that the generated executable is pretty massive (85M on arm64-darwin, compared to 5.4M now).

There's already support for statically linking libclang.a, so I think this is mostly a matter of automating the release process. I have a hacky proof-of-concept here for reference.

I'd be happy to work on making this happen if others would find it useful.

@HadrienG2
Copy link

HadrienG2 commented Apr 6, 2024

Another possible (complementary) strategy is to use the pre-built binaries provided by LLVM contributors for various hardware + OS combinations.

They contain way more than we need, but extracting the (self-contained) libclang.so from them is not terribly difficult. So it should be possible to have a scheduled CI job that periodically scans the LLVM releases, extracts the libclang, and attaches it to the bindgen github release.

Of course, given that people are easily scared by binaries for reasons I have never fully understood (unless you claim that you or anyone else actually understands everything that the LLVM source code does, there is no meaningful security difference between building LLVM from source and using a pre-built binary from my perspective), the use of binaries should be optional.

@ianks
Copy link
Author

ianks commented Dec 12, 2024

@HadrienG2 I like this idea a lot. For rb-sys, libclang is by far the biggest headache in the toolchain and the thing wastes the most collective developer hours. Where I work, it's caused the biggest impediment to Rust adoption out of everything in the ecosystem. For such a seemingly small thing, the implications are big.

IMO, using pre-built binaries from LLVM should be the default with the goal of removing as much toil as possible.

@Kriskras99
Copy link
Contributor

Maybe Rustup can distribute libclang.so via the llvm-tools(-preview) component?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants