Skip to content

Can't build stdlib for mips-unknown-linux-musl without libunwind #61367

@skade

Description

@skade

I'm trying rebuild stdlib for the OpenWRT malta SDK (available here: https://downloads.openwrt.org/releases/18.06.2/targets/malta/be/openwrt-sdk-18.06.2-malta-be_gcc-7.3.0_musl.Linux-x86_64.tar.xz).

The SDK ships with libgcc_s.so, but without libunwind.a, leading to a linker error when building unwind. I'd like to run with panic=abort, so I don't need unwinding.

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

mips is special-cased in libunwind here: https://github.com/rust-lang/rust/blob/master/src/libunwind/lib.rs#L28-L31

I tried passing target-feature=-crt-static and using a custom target target:

  "crt-static-default": false,
  "crt-static-respected": true,
  "dynamic-linking": true,

Both don't work.

Steps to reproduce:

  • Unzip the SDK
  • Make sure openwrt-sdk-18.06.2-malta-be_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/bin/ is in PATH
  • Set the linker:
[target.mips-openwrt-linux-musl]
linker = "mips-openwrt-linux-gcc"
  • Use Xargo to rebuild stdlib

Building and running a binary works when modifying the code above to just link gcc_s:

#[cfg(target_env = "musl")]
#[link(name = "gcc_s")]
extern {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-MIPSTarget: MIPS processorsO-muslTarget: The musl libcT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions