brson / wasm-opt-rs

Rust bindings for Binaryen's wasm-opt
Apache License 2.0
61 stars 10 forks source link

Allow downloading static library for platforms where one is available #161

Open RReverser opened 10 months ago

RReverser commented 10 months ago

As the docs mention, building Binaryen from source takes a long time to build, prohibitively so in some projects.

On the other hand, Binaryen already provides a static library inside the lib directory of its official prebuilt releases.

Assuming it contains all the same APIs used by this crate, would it be possible to add an opt-in feature that would download & link those static libraries in build.rs instead of building everything from source at least on supported platforms? Given that both source code and prebuilt releases come from the same Github it should be no more dangerous in terms of trusting 3rd-party code than what's happening implicitly right now anyway.

brson commented 9 months ago

Reusing the official binaries is a clever idea. It sounds possible and I can't think of any reason it couldn't work in common cases.

The main complication I can think of are related to conditional compilation of the LLVM passes - sometimes we compile without them, and in that case couldn't use the pre-built binaries.

Thanks for the idea.

RReverser commented 9 months ago

Thanks for the idea.

Heh no worries.

It would certainly help us, as for now we have to ask users to install correct wasm-opt binaries for their platform as we don't want to add expensive C++ compilation to our build, but with this change we could just use wasm-opt-rs and have it do that for us on all platforms we care about.

clearloop commented 9 months ago

perhaps provide a new feature builded, which will search the static library on OS

RReverser commented 9 months ago

which will search the static library on OS

It's not really the same though as automated download of the correct static library by Cargo / build.rs itself, as it still puts the onus for cross-platform shenanigans on the user.

clearloop commented 9 months ago

which will search the static library on OS

It's not really the same though as automated download of the correct static library by Cargo / build.rs itself, as it still puts the onus for cross-platform shenanigans on the user.

indeed, haha sry, I'm about to open an issue about it but saw this issue, so I just commented without reading the content in detail