mgrachev / update-informer

Update informer for CLI/GUI applications written in Rust 🦀
MIT License
209 stars 8 forks source link

Does not build for target `x86_64-unknown-linux-musl` when using `reqwest` #110

Closed dyc3 closed 1 year ago

dyc3 commented 1 year ago

Building for the target x86_64-unknown-linux-musl does not work by default.

cross build --target=x86_64-unknown-linux-musl --no-default-features --features reqwest

Workaround: disable the reqwest feature.

mgrachev commented 1 year ago

@dyc3 👋 Thank you for your feedback!

Please tell me more about your problem and its solution. It's not entirely clear from PR how this solves your problem. Can you also attach build commands and errors?

dyc3 commented 1 year ago

Sorry about the sparse details. Ultimately, my problem is that I need to build a portable binary for my project, and compiling for x86_64-unknown-linux-musl helps do that because it doesn't dynamically link glibc, instead it statically links musl.

By default, reqwest (well, technically hyper) uses the openssl crate, which requires dynamically linking to the system library, which is a no-go for a portable binary.

Running cross build --target=x86_64-unknown-linux-musl --no-default-features --features reqwest (cross instead of cargo makes it easier to cross compile, otherwise you have to deal with a bunch of C toolchain stuff)

Truncated Output:

...
--- stderr
  Package openssl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `openssl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'openssl' found

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
...

reqwest has an escape hatch for this (the rustls-tls feature), where it can use the rustls crate for TLS instead of openssl. The PR simply activates this feature on reqwest, but only when building for x86_64-unknown-linux-musl.

mgrachev commented 1 year ago

Now I understand, thank you!