Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

reqwest can not cross build for target x86_64-unknown-linux-musl with tokio library #11

Closed
ikey4u opened this issue Feb 26, 2022 · 8 comments · Fixed by #12
Closed

reqwest can not cross build for target x86_64-unknown-linux-musl with tokio library #11

ikey4u opened this issue Feb 26, 2022 · 8 comments · Fixed by #12

Comments

@ikey4u
Copy link

ikey4u commented Feb 26, 2022

This a minimal example to reproduce the problem.

  • Cargo.toml

    [package]
    name = "reqwest-demo"
    version = "0.1.0"
    edition = "2021"
    
    [dependencies]
    reqwest = { version = "0.11.9", features = ["json", "multipart", "native-tls-vendored"] }
    tokio = { version = "1.0", features = [ "full" ] }
    
  • main.rs

    #[tokio::main]
    async fn main() {
        let response = reqwest::Client::new()
            .post("http://www.baidu.com")
            .form(&[("one", "1")])
            .send()
            .await
            .expect("send");
        println!("Response status {}", response.status());
    }
    

Notice that reqwest enables feature native-tls-vendored to let us build tls library source using zig.

To build the example, using command below

cargo-zigbuild zigbuild --target x86_64-unknown-linux-musl

The generated error is here

ld.lld: error: undefined symbol: _$LT$libc..unix..linux_like..linux..musl..sigaction$u20$as$u20$core..clone..Clone$GT$::clone::h5d005990411f7b3b
      >>> referenced by lib.rs:196 (~/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/signal-hook-registry-1.4.0/src/lib.rs:196)
      >>>               signal_hook_registry-bdc7223cbb468750.signal_hook_registry.c6e8fee1-cgu.3.rcgu.o:(_$LT$signal_hook_registry..Prev$u20$as$u20$core..clone..Clone$GT$::clone::h3790061594f1b072)

And line 196 is here

@messense
Copy link
Member

@messense
Copy link
Member

@ikey4u Are you using Rust 1.59.0, please try #12.

@ikey4u
Copy link
Author

ikey4u commented Feb 26, 2022

@messense yes, I use rust 1.59.0, and the build passed using the pr #12

@messense
Copy link
Member

@ikey4u Thanks for confirming, I've also verified that the built artifact runs fine.

@ikey4u
Copy link
Author

ikey4u commented Feb 26, 2022

@messense Unfortunately, I test patch #12 with Rust 1.58.0, it does not work. The error is the same.

@messense
Copy link
Member

That's unfortunate but this project is so young that I'm not aiming for supporting old Rust versions.

@ikey4u
Copy link
Author

ikey4u commented Feb 26, 2022

its does not matter, but you can specify the minimal supported rust version on homepage.

@messense
Copy link
Member

For future reference, this issue is caused by upstream Rust distributes libc.a in self-contained for musl and wasi since Rust 1.59.0 (I think the code is in 1.58.0 but isn't really used since it requires a libc 0.2.107 and later).

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

Successfully merging a pull request may close this issue.

2 participants