Skip to content

Looks for static musl despite -C target-feature=-crt-static #691

Closed
@vorner

Description

@vorner

Hello

I'm not entirely sure the issue belongs in this repository, but it is where the problem manifests. Also, it might be something I do incorrectly. I apologize if it is so.

I have an SDK for an OpenWRT device, and the system is musl-based. If I compile with the usual armv7-unknown-linux-musleabihf, the result works, but it bundles its own statically liked copy of musl, which is not nice on embedded. Therefore, I'm attempting to use xargo and my own target config to produce a dynamically linked binary. AFAIK the recently stabilized -C target-feature=-crt-static should allow me doing that. However, for reasons I'm unable to track down, I still get this error about static library c when compiling the libc crate:

error: could not find native static library `c`, perhaps an -L flag is missing?

I made a repository which reproduces the problem: https://github.com/vorner/xcompile. When the ./build script is run, it downloads the SDK (unfortunately, that's 425MBs of download and 1.5GB unpacked :-( ) and runs the failing build.

As far as I understand the parameters, the command line of rustc should be correct and ask for dynamic linking:

rustc --crate-name libc /home/vorner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/libc_shim/../../liblibc/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C metadata=920c148c4f0c8bc4 -C extra-filename=-920c148c4f0c8bc4 --out-dir /tmp/.private/vorner/xargo.07nyCJ4iQeip/target/arm-openwrt-linux-muslgnueabi/release/deps --target arm-openwrt-linux-muslgnueabi -L dependency=/tmp/.private/vorner/xargo.07nyCJ4iQeip/target/arm-openwrt-linux-muslgnueabi/release/deps -L dependency=/tmp/.private/vorner/xargo.07nyCJ4iQeip/target/release/deps --extern core=/tmp/.private/vorner/xargo.07nyCJ4iQeip/target/arm-openwrt-linux-muslgnueabi/release/deps/libcore-53a001eb41f8f158.rlib -Zincremental=/tmp/.private/vorner/xargo.07nyCJ4iQeip/target/arm-openwrt-linux-muslgnueabi/release/incremental -C target-feature=-crt-static --sysroot /home/vorner/.xargo -Z force-unstable-if-unmarked --cfg stdbuild

The rustc should be new enough, and the libc sources come from the same batch provided by rustup:

rustc 1.20.0-nightly (8d22af87d 2017-07-22)

I'd really like to track this down, but I have no idea where to look. I believe it is not related to this #685 and I don't think there's another place where to ask for dynamic crt.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions