Skip to content

Archiver for musl is not ar when in Docker image for a different architecture #1399

Open
@samestep

Description

When I use cc natively on Linux or macOS, cc::Build::get_archiver always returns ar when I'm building for either x86 musl or ARM musl. However, when I try to do the same build in a rust Docker image, and the --platform is not my native platform, it sometimes attempts other names for the archiver program (like musl-ar or aarch64-linux-musl-ar) which cause the build to fail.

This forces me to set a TARGET_AR variable in my Dockerfile if I depend on crates like wasmtime that transitively depend on crates like zstd-sys; see this Stack Overflow question for such an example, which is itself boiled down from gradbench/gradbench#233 that was my real use case.

See this GitHub repository which includes a full code example to reproduce the issue. As also written in that README.md, here are the different values I see returned by cc::Build::get_archiver in various contexts:

  • ARM macOS
    • native: "ar"
    • native targeting x86 musl: "ar"
    • native targeting ARM musl: "ar"
    • Docker targeting x86 musl: "musl-ar"
    • Docker targeting ARM musl: "ar"
  • x86 Linux
    • native: "ar"
    • native targeting x86 musl: "ar"
    • native targeting ARM musl: "ar"
    • Docker targeting x86 musl: "ar"
    • Docker targeting ARM musl: "aarch64-linux-musl-ar"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions