Skip to content

Unable to build rust compiler on Alpine Linux #88221

@zdiff

Description

@zdiff

I am unable to successfully run python3 ./x.py build on Alpine Linux.

I am able to replicate this issue with Docker:

Code

FROM alpine:3.14.1

RUN apk add --no-cache \
    curl \
    cmake \
    g++ \
    gcc \
    git \
    musl-dev \
    ninja \
    python3

RUN git clone --branch 1.54.0 --single-branch https://github.com/rust-lang/rust.git \
    && cd rust \
    && export RUST_BACKTRACE=full \
    && cp config.toml.example config.toml \
    && python3 ./x.py build \
    --build x86_64-unknown-linux-musl \
    --host x86_64-unknown-linux-musl \
    --target x86_64-unknown-linux-musl \
    --jobs "$(nproc)" \
    && python3 ./x.py install

Error output

Backtrace

#10 6075.2 [21/2758] Linking CXX static library lib/libDynamicLibraryLib.a
#10 6075.3 [22/2758] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/PipSqueak.cpp.o
#10 6075.5 [23/2758] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/SecondLib.dir/PipSqueak.cpp.o
#10 6076.0 [24/2758] Linking CXX shared library unittests/Support/DynamicLibrary/PipSqueak.so
#10 6076.0 ninja: job failed: : && /usr/bin/c++ -fPIC -ffunction-sections -fdata-sections -fPIC -m64 -static -static -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -static -Wl,-z,defs -shared -Wl,-soname,PipSqueak.so -o unittests/Support/DynamicLibrary/PipSqueak.so unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/PipSqueak.cpp.o   && :
#10 6076.0 /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
#10 6076.0 /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/crtend.o: relocation R_X86_64_32 against `.ctors' can not be used when making a shared object; recompile with -fPIC
#10 6076.0 collect2: error: ld returned 1 exit status
#10 6079.8 ninja: subcommand failed
#10 6079.8 thread 'main' panicked at '
#10 6079.8 command did not execute successfully, got: exit status: 1
#10 6079.8
#10 6079.8 build script failed, must exit now', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:885:5
#10 6079.8 stack backtrace:
#10 6079.8    0:     0x7f34cbe09910 - std::backtrace_rs::backtrace::libunwind::trace::h0a4d1a6a1f3ee78c
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
#10 6079.8    1:     0x7f34cbe09910 - std::backtrace_rs::backtrace::trace_unsynchronized::hcdb6d770f7c6c0ff
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
#10 6079.8    2:     0x7f34cbe09910 - std::sys_common::backtrace::_print_fmt::hb2af22fcd043cfe5
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:67:5
#10 6079.8    3:     0x7f34cbe09910 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h57b30a04a298ca27
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:46:22
#10 6079.8    4:     0x7f34cbe4919f - core::fmt::write::he63f052d36578df1
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/fmt/mod.rs:1094:17
#10 6079.8    5:     0x7f34cbe05265 - std::io::Write::write_fmt::h47207eae3917b098
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/io/mod.rs:1584:15
#10 6079.8    6:     0x7f34cbe0c72b - std::sys_common::backtrace::_print::hdf7108607dc68362
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:49:5
#10 6079.8    7:     0x7f34cbe0c72b - std::sys_common::backtrace::print::hfe981af40ce65146
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:36:9
#10 6079.8    8:     0x7f34cbe0c72b - std::panicking::default_hook::{{closure}}::h6efb08a9f2e165c0
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:208:50
#10 6079.8    9:     0x7f34cbe0c1fd - std::panicking::default_hook::h75e6490e71569f7b
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:225:9
#10 6079.8   10:     0x7f34cbe0cd3d - std::panicking::rust_panic_with_hook::h44acaf836583bf77
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:591:17
#10 6079.8   11:     0x7f34cbe0c8d7 - std::panicking::begin_panic_handler::{{closure}}::hfcb95b1a4c3fd433
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:497:13
#10 6079.8   12:     0x7f34cbe09dcc - std::sys_common::backtrace::__rust_end_short_backtrace::hca28f1118834420f
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:141:18
#10 6079.8   13:     0x7f34cbe0c839 - rust_begin_unwind
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
#10 6079.8   14:     0x7f34cb36fa1b - std::panicking::begin_panic_fmt::hf5bc7901981ac7fe
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:435:5
#10 6079.8   15:     0x7f34cba2b733 - cmake::fail::hf296fa405cb394b4
#10 6079.8                                at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:885:5
#10 6079.8   16:     0x7f34cba2b092 - cmake::run::h88059d955c2375e9
#10 6079.8                                at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:863:9
#10 6079.8   17:     0x7f34cba276e4 - cmake::Config::build::h99d8218a8f001753
#10 6079.8                                at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:769:9
#10 6079.8   18:     0x7f34cb99a776 - <bootstrap::native::Llvm as bootstrap::builder::Step>::run::h47b4dfec8e3a16a1
#10 6079.8                                at /rust/src/bootstrap/native.rs:329:9
#10 6079.8   19:     0x7f34cb8bdbfb - bootstrap::builder::Builder::ensure::haf220c2c89358adf
#10 6079.8                                at /rust/src/bootstrap/builder.rs:1543:23
#10 6079.8   20:     0x7f34cb94713b - bootstrap::compile::rustc_cargo_env::hfe54cfc2f4d956e9
#10 6079.8                                at /rust/src/bootstrap/compile.rs:678:27
#10 6079.8   21:     0x7f34cb946ac6 - bootstrap::compile::rustc_cargo::hc580c94ea34cdde6
#10 6079.8                                at /rust/src/bootstrap/compile.rs:630:5
#10 6079.8   22:     0x7f34cb945c41 - <bootstrap::compile::Rustc as bootstrap::builder::Step>::run::h7c720f3640642d78
#10 6079.8                                at /rust/src/bootstrap/compile.rs:566:9
#10 6079.8   23:     0x7f34cb8d6cb0 - bootstrap::builder::Builder::ensure::hc6f3a702b2ac2754
#10 6079.8                                at /rust/src/bootstrap/builder.rs:1543:23
#10 6079.8   24:     0x7f34cb94c10c - <bootstrap::compile::Assemble as bootstrap::builder::Step>::run::h7b1f8359d408ed22
#10 6079.8                                at /rust/src/bootstrap/compile.rs:1049:9
#10 6079.8   25:     0x7f34cb8cb2cd - bootstrap::builder::Builder::ensure::hbce1b308644fbfaa
#10 6079.8                                at /rust/src/bootstrap/builder.rs:1543:23
#10 6079.8   26:     0x7f34cb8031a4 - bootstrap::builder::Builder::compiler::h0a8359c18511b15a
#10 6079.8                                at /rust/src/bootstrap/builder.rs:598:9
#10 6079.8   27:     0x7f34cb93f5c5 - <bootstrap::compile::Std as bootstrap::builder::Step>::make_run::hea8b94428a77b12b
#10 6079.8                                at /rust/src/bootstrap/compile.rs:52:23
#10 6079.8   28:     0x7f34cb7fe8f5 - bootstrap::builder::StepDescription::maybe_run::h7643e880946d6c33
#10 6079.8                                at /rust/src/bootstrap/builder.rs:179:13
#10 6079.8   29:     0x7f34cb7feef9 - bootstrap::builder::StepDescription::run::h13ccca526d9cfe61
#10 6079.8                                at /rust/src/bootstrap/builder.rs:200:25
#10 6079.8   30:     0x7f34cb80311a - bootstrap::builder::Builder::run_step_descriptions::h4ab99147b4a87324
#10 6079.8                                at /rust/src/bootstrap/builder.rs:590:9
#10 6079.8   31:     0x7f34cb802e36 - bootstrap::builder::Builder::execute_cli::h9bddc754ffc19093
#10 6079.8                                at /rust/src/bootstrap/builder.rs:570:9
#10 6079.8   32:     0x7f34cb635c95 - bootstrap::Build::build::h0b49d6da1a9a676c
#10 6079.8                                at /rust/src/bootstrap/lib.rs:515:13
#10 6079.8   33:     0x7f34cb37160c - bootstrap::main::h29b3520c5b355070
#10 6079.8                                at /rust/src/bootstrap/bin/main.rs:33:5
#10 6079.8   34:     0x7f34cb37103b - core::ops::function::FnOnce::call_once::h8dd0e42e8704b2f9
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/ops/function.rs:227:5
#10 6079.8   35:     0x7f34cb37119e - std::sys_common::backtrace::__rust_begin_short_backtrace::h17549f5dfca6758a
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:125:18
#10 6079.8   36:     0x7f34cb372c81 - std::rt::lang_start::{{closure}}::h08807f1189aa3a49
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/rt.rs:49:18
#10 6079.8   37:     0x7f34cbe0d1a9 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h71b3f349d044965d
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/ops/function.rs:259:13
#10 6079.8   38:     0x7f34cbe0d1a9 - std::panicking::try::do_call::hc02ebce4ba4c6173
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:379:40
#10 6079.8   39:     0x7f34cbe0d1a9 - std::panicking::try::h294110da45001535
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:343:19
#10 6079.8   40:     0x7f34cbe0d1a9 - std::panic::catch_unwind::h852663fafb9931f9
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panic.rs:431:14
#10 6079.8   41:     0x7f34cbe0d1a9 - std::rt::lang_start_internal::ha79cb227b2786b9a
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/rt.rs:34:21
#10 6079.8   42:     0x7f34cb372c60 - std::rt::lang_start::hed27703ec1706012
#10 6079.8                                at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/rt.rs:48:5
#10 6079.8   43:     0x7f34cb371c6c - main
#10 6079.8      finished in 17.596 seconds
#10 6079.8 failed to run: /rust/build/bootstrap/debug/bootstrap build --build x86_64-unknown-linux-musl --host x86_64-unknown-linux-musl --target x86_64-unknown-linux-musl --jobs 12
#10 6079.8 Build completed unsuccessfully in 1:22:15
#10 ERROR: executor failed running [/bin/sh -c git clone --branch "${rust_version}" --single-branch https://github.com/rust-lang/rust.git     && cd rust     && export RUST_BACKTRACE=full     && cp config.toml.example config.toml     && python3 ./x.py build     --build x86_64-unknown-linux-musl     --host x86_64-unknown-linux-musl     --target x86_64-unknown-linux-musl     --jobs "$(nproc)"     && python3 ./x.py install]: exit code: 1
------
 > [6/6] RUN git clone --branch "1.54.0" --single-branch https://github.com/rust-lang/rust.git     && cd rust     && export RUST_BACKTRACE=full     && cp config.toml.example config.toml     && python3 ./x.py build     --build x86_64-unknown-linux-musl     --host x86_64-unknown-linux-musl     --target x86_64-unknown-linux-musl     --jobs "$(nproc)"     && python3 ./x.py install:
------
executor failed running [/bin/sh -c git clone --branch "${rust_version}" --single-branch https://github.com/rust-lang/rust.git     && cd rust     && export RUST_BACKTRACE=full     && cp config.toml.example config.toml     && python3 ./x.py build     --build x86_64-unknown-linux-musl     --host x86_64-unknown-linux-musl     --target x86_64-unknown-linux-musl     --jobs "$(nproc)"     && python3 ./x.py install]: exit code: 1
make: *** [Makefile:9: build-rust] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.O-muslTarget: The musl libcT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions