curl-rust icon indicating copy to clipboard operation
curl-rust copied to clipboard

Compiling with musl?

Open fosskers opened this issue 3 years ago • 5 comments

Hi there, with a up-to-date stable and x86-86-unknown-linux-musl target, I seem unable to compile this library (as a dependency of curl and isahc). With:

cargo build --release --target x86_64-unknown-linux-musl

I get many messages of the form:

cargo:warning=In file included from /usr/include/bits/endian.h:35,
cargo:warning=                 from /usr/include/endian.h:24,
cargo:warning=                 from /usr/include/sys/types.h:176,
cargo:warning=                 from curl/include/curl/system.h:430,
cargo:warning=                 from curl/include/curl/curl.h:38,
cargo:warning=                 from curl/lib/curl_setup.h:157,
cargo:warning=                 from curl/lib/asyn-thread.c:23:
cargo:warning=/usr/include/bits/endianness.h:9: warning: "__BYTE_ORDER" redefined
cargo:warning=    9 | #define __BYTE_ORDER __LITTLE_ENDIAN
cargo:warning=      |

Followed by a complaint about musl-gcc exiting with an error code. I have the latest curl system packages installed on my machine, so I'm not sure what the issue is. Any thoughts? Thank you.

fosskers avatar Aug 06 '20 02:08 fosskers

This looks like your C compiler may not be configured correctly? The error there is in a system header?

alexcrichton avatar Aug 06 '20 14:08 alexcrichton

Here's the full text of the error: https://pastebin.com/KaSCNje8

Hard to say if anything is misconfigured, since I certainly haven't touched any such settings myself. I have gcc, clang, glibc, and musl all installed in harmony (i.e. their package definitions don't explicitly reject the others).

I did have to add the following myself to my environment, after compilation here failed at an earlier stage:

set -x PKG_CONFIG_ALLOW_CROSS 1

fosskers avatar Aug 06 '20 15:08 fosskers

Sorry I don't really know myself. I'm not familiar with how you're installing your musl compiler and what could possibly go wrong.

alexcrichton avatar Aug 06 '20 15:08 alexcrichton

They're all just system packages installed through the package manager :( Oh well, thanks for your help.

fosskers avatar Aug 06 '20 15:08 fosskers

I'm not able to reproduce this error. It might help to know what Linux distribution you are using. I can build for musl just fine in my Linux environments (with the caveat of picking an SSL backend). Or, I don't get the error you are seeing anyway. I also verified that curl-rust can be built with musl in a totally clean Docker build environment like this:

$ docker run -it --rm rust
$ apt update
$ apt install -y musl-tools
$ rustup target add x86_64-unknown-linux-musl
$ git clone https://github.com/alexcrichton/curl-rust
$ cd curl-rust
$ cargo build --release --target x86_64-unknown-linux-musl --no-default-features
# -> builds successfully with no SSL
$ cargo build --release --target x86_64-unknown-linux-musl --features static-ssl
# -> builds successfully with a bundled OpenSSL provided by openssl-sys crate

Building curl for musl shouldn't be hard, its building OpenSSL for musl that can be tricky. I'm curious where you're getting a musl-compatible OpenSSL build from, though your error message isn't even coming from there so I'm not sure what's wrong.

sagebind avatar Mar 06 '21 21:03 sagebind