Skip to content

rust-1.91.0_beta produces a broken rustc-stage1 on custom musl target #146930

Closed

Description

@stefson

hello everyone,

I'm building rust for a custom musl target and was about to test the 1.91.0_beta, but the build process fails due to seemingly missing libs:

running: RUSTC_BOOTSTRAP="1" "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin/rustc" "--print=target-spec-json-schema" "-Zunstable-options" (failure_mode=Exit) (created at src/bootstrap/src/core/build_steps/dist.rs:628:21, executed at src/bootstrap/src/core/build_steps/dist.rs:632:24)
Command `RUSTC_BOOTSTRAP="1" "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin/rustc" "--print=target-spec-json-schema" "-Zunstable-options" (failure_mode=Exit)` failed with exit code 127
Created at: src/bootstrap/src/core/build_steps/dist.rs:628:21
Executed at: src/bootstrap/src/core/build_steps/dist.rs:632:24

--- STDOUT vvv


--- STDERR vvv
Error loading shared library librustc_driver-25f52a4f3a321d15.so: No such file or directory (needed by /var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin/rustc)
Error relocating /var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin/rustc: _ZN3std2rt19lang_start_internal17hda59b061fa42e575E: symbol not found
Error relocating /var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin/rustc: _RNvCs6FONwEGrKIA_17rustc_driver_impl4main: symbol not found

Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/./x.py", line 53, in <module>
    bootstrap.main()
    ~~~~~~~~~~~~~~^^
  File "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/src/bootstrap/bootstrap.py", line 1389, in main
    bootstrap(args)
    ~~~~~~~~~^^^^^^
  File "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/src/bootstrap/bootstrap.py", line 1364, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
    ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/src/bootstrap/bootstrap.py", line 237, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/build/bootstrap/debug/bootstrap install -v --config=/var/tmp/portage/dev-lang/rust-1.91.0_beta/work/rustc-beta-src/bootstrap.toml -j1

this is my bootstrap.toml config file:

[llvm]
download-ci-llvm = false
optimize = true
release-debuginfo = false
assertions = false
ninja = true
targets = "ARM"
experimental-targets = ""
link-shared = false
[build]
build = "armv7a-unknown-linux-musleabihf"
host = ["armv7a-unknown-linux-musleabihf"]
target = ["armv7a-unknown-linux-musleabihf"]
cargo = "/usr/lib/rust/1.90.0/bin/cargo"
rustc = "/usr/lib/rust/1.90.0/bin/rustc"
docs = false
compiler-docs = false
submodules = false
python = "python3.13"
locked-deps = true
extended = true
tools = ["cargo","rustdoc"]
verbose = 2
sanitizers = false
cargo-native-static = false
[install]
prefix = "/usr/lib/rust/1.91.0_beta"
sysconfdir = "etc"
docdir = "share/doc/rust"
bindir = "bin"
libdir = "lib"
mandir = "share/man"
[rust]
# https://github.com/rust-lang/rust/issues/54872
codegen-units-std = 1
optimize = true
debug = false
debug-assertions = false
debuginfo-level-rustc = 0
backtrace = true
incremental = false
default-linker = "armv7a-unknown-linux-musleabihf-gcc"
channel = "stable"
rpath = false
verbose-tests = true
optimize-tests = true
codegen-tests = true
dist-src = false
# https://github.com/rust-lang/rust/issues/117885
remap-debuginfo = true
lld = false
# try to get rid of llvm-tools-preview
llvm-tools = false
backtrace-on-ice = true
jemalloc = false
# See https://github.com/rust-lang/rust/issues/121124
lto = "off"
[dist]
vendor = false
src-tarball = false
compression-formats = ["xz"]
[target.armv7a-unknown-linux-musleabihf]
cc = "armv7a-unknown-linux-musleabihf-gcc"
cxx = "armv7a-unknown-linux-musleabihf-g++"
linker = "armv7a-unknown-linux-musleabihf-gcc"
ar = "armv7a-unknown-linux-musleabihf-ar"
crt-static = false

the file in question is def. present in the build dir:

./armv7a-unknown-linux-musleabihf/stage1-rustc/armv7a-unknown-linux-musleabihf/release/deps/librustc_driver-25f52a4f3a321d15.so
./armv7a-unknown-linux-musleabihf/stage1/lib/librustc_driver-25f52a4f3a321d15.so
./armv7a-unknown-linux-musleabihf/stage0-sysroot/lib/rustlib/armv7a-unknown-linux-musleabihf/lib/librustc_driver-25f52a4f3a321d15.so

from folder ../rustc-beta-src/build/armv7a-unknown-linux-musleabihf/stage1/bin
I execute ./rustc gives me:

        /lib/ld-musl-armhf.so.1 (0xf791e000)
Error loading shared library librustc_driver-25f52a4f3a321d15.so: No such file or directory (needed by rustc)
        libgcc_s.so.1 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libgcc_s.so.1 (0xf790f000)
        libc.so => /lib/ld-musl-armhf.so.1 (0xf791e000)
Error relocating rustc: _ZN3std2rt19lang_start_internal17hda59b061fa42e575E: symbol not found
Error relocating rustc: _RNvCs6FONwEGrKIA_17rustc_driver_impl4main: symbol not found

my git-commit-hash is b34cfaf51ab461e8aeb742c40ca790a4e5feefe1 ; 1.91.0_beta bootstrapped via 1.90.0

Additional context

the full build log can be found here: build.log.gz

Activity

  1. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    C-bugCategory: This is a bug.
    on Sep 23, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 23, 2025
  3. Kobzol commented on Sep 23, 2025

    @Kobzol
    Member

    The problem is not missing libs, but the fact that the library cannot be loaded due to some missing symbols. No idea what could be causing that though, probably something in the custom target spec doesn't work.

  4. stefson commented on Sep 23, 2025

    @stefson
    Author

    I believe the symbols are there, the rustc binary just doesn't look at the correct spot:

    executed from ../build/armv7a-unknown-linux-musleabihf/stage1/bin: LD_LIBRARY_PATH=../lib/ ./rustc -vV

    rustc 1.91.0 (b34cfaf51 2025-09-19) (built from a source tarball)
    binary: rustc
    commit-hash: b34cfaf51ab461e8aeb742c40ca790a4e5feefe1
    commit-date: 2025-09-19
    host: armv7a-unknown-linux-musleabihf
    release: 1.91.0
    LLVM version: 21.1.1
    
  5. Kobzol commented on Sep 23, 2025

    @Kobzol
    Member

    I see. Could you please run ldd on the rustc binary?

  6. stefson commented on Sep 23, 2025

    @stefson
    Author

    sure, here is ldd of stage1-rustc:

    
            /lib/ld-musl-armhf.so.1 (0xf7a42000)
    Error loading shared library librustc_driver-25f52a4f3a321d15.so: No such file or directory (needed by rustc)
            libgcc_s.so.1 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libgcc_s.so.1 (0xf7a33000)
            libc.so => /lib/ld-musl-armhf.so.1 (0xf7a42000)
    Error relocating rustc: _ZN3std2rt19lang_start_internal17hda59b061fa42e575E: symbol not found
    Error relocating rustc: _RNvCs6FONwEGrKIA_17rustc_driver_impl4main: symbol not found
    

    I played around a bit, don't know if its legal to add LD_PRELOAD before pointing with ldd on a binary, but I did it anyway:

    LD_LIBRARY_PATH=../lib/ ldd rustc

            /lib/ld-musl-armhf.so.1 (0xf7cb7000)
            librustc_driver-25f52a4f3a321d15.so => ../lib//librustc_driver-25f52a4f3a321d15.so (0xf05a7000)
            libgcc_s.so.1 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libgcc_s.so.1 (0xf059b000)
            libc.so => /lib/ld-musl-armhf.so.1 (0xf7cb7000)
            libz.so.1 => /usr/lib/libz.so.1 (0xf0586000)
            libstdc++.so.6 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libstdc++.so.6 (0xf036a000)
    

    and I see a potential illegal double // in the lib path 🧐

  7. Kobzol commented on Sep 23, 2025

    @Kobzol
    Member

    Umm, that's a bit weird output, normally when I run ldd and the library is not found, it either prints the path under which it wants to find it, or it just output something like "not found". Due to how the path looks when you specify the LD_LIBRARY_PATH, I wonder if the "real" path is something like /librustc_driver-..., which is clearly not correct. What does LD_LIBRARY_PATH=../lib ldd rustc output?

  8. stefson commented on Sep 23, 2025

    @stefson
    Author

    ah I'm sorry, with ../lib its now the correct output:

            /lib/ld-musl-armhf.so.1 (0xf7ef8000)
            librustc_driver-25f52a4f3a321d15.so => ../lib/librustc_driver-25f52a4f3a321d15.so (0xf07e8000)
            libgcc_s.so.1 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libgcc_s.so.1 (0xf07dc000)
            libc.so => /lib/ld-musl-armhf.so.1 (0xf7ef8000)
            libz.so.1 => /usr/lib/libz.so.1 (0xf07c7000)
            libstdc++.so.6 => /usr/lib/gcc/armv7a-unknown-linux-musleabihf/14/libstdc++.so.6 (0xf05ab000)
    
  9. mati865 commented on Sep 24, 2025

    @mati865
    Member

    Just confirming, double // in the path is fine, it's just cosmetic.

    Given this is a build with rpath = false, perhaps bootstrap should set the library path?

  10. Kobzol commented on Sep 25, 2025

    @Kobzol
    Member

    Hmm, right, rpath should really be enabled.

  11. stefson commented on Oct 3, 2025

    @stefson
    Author

    if I enable rpath = true for rust-1.90.0, it won't compile
    if I enable rpath = true for rust-1.91.0, it will compile and install, but it won't be able to locate librustc_driver-c1aa1ccb99129417.so at runtime, leading to a broken rust binary.

    maybe it's a confusion about stage1 and stage2 rustc during install?

  12. stefson commented on Oct 18, 2025

    @stefson
    Author

    fixed via #147571

  13. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-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