rust-lang / rust-lang/rust

Error Index Generator broken when cross-compiling rustc from source with the docs enabled

Open
#155,124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug needs-triage T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

When building Rust 1.93.0 and Rust 1.94.1 from source for the host and target x86_64-unknown-haiku from a Linux build (x86_64-unknown-linux-gnu), the error_index_generator tool is built for the target x86_64-unknown-haiku instead of the x86_64-unknown-linux-gnu target.

The last working version was Rust 1.89.0. I have not tried any intermediate builds yet. The #145007 change by @Kobzol is the change that may have broken the build.

Command used
./x.py -j 8 -v dist
Expected behaviour

In these cross-compiling cases, the build should use the build machine's compiler to build the tool. The tool should then be able to run on the build machine.

Actual behaviour

The bootstrap config tries to run the tool, which then segfaults. Attaching a debugger shows that it segfaults in the _start() function.

Bootstrap configuration (bootstrap.toml)
# Rust 1.83.0+
change-id = 131075

[llvm]
targets = "WebAssembly;X86"
experimental-targets = ""
static-libstdcpp = false
download-ci-llvm = false

[build]
host = ["x86_64-unknown-haiku"]
target = ["x86_64-unknown-haiku", "wasm32-unknown-unknown"]
extended = true

[install]
prefix = "/boot/system"

[rust]
channel = "stable"
lld = true
deny-warnings = false

[target.x86_64-unknown-haiku]
cc = "x86_64-unknown-haiku-gcc"
cxx = "x86_64-unknown-haiku-g++"
ar = "x86_64-unknown-haiku-ar"
linker = "x86_64-unknown-haiku-gcc"
rpath = false

[dist]
compression-formats = ["xz"]
Operating system

Ubuntu 25.04 on WSL2.

HEAD

e408947bfd200af42db322daf0fadfe7e26d3bd1

Additional context
Build Log Excerpt

Documenting error index (i686-unknown-haiku)
using sysroot /build/rust/build/x86_64-unknown-linux-gnu/stage1
running: LD_LIBRARY_PATH="/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib" "/build/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "--target" "i686-unknown-haiku" "--print=file-names" "--crate-type=proc-macro" "-" (failure_mode=Exit) (created at src/bootstrap/src/core/builder/mod.rs:1401:23, executed at src/bootstrap/src/core/build_steps/tool.rs:191:21)
Cache hit: "/build/rust/build/x86_64-unknown-linux-gnu/llvm/bin/llvm-config" "--libdir" (failure_mode=Exit)
Building stage2 error_index_generator (stage1:x86_64-unknown-linux-gnu -> stage2:i686-unknown-haiku)
running: cd "/build/rust" && env -u MAKEFLAGS -u MFLAGS AR_i686_unknown_haiku="i586-pc-haiku-ar-x86" CARGO_BUILD_BUILD_DIR="/build/rust/build/x86_64-unknown-linux-gnu/stage2-tools" CARGO_INCREMENTAL="0" CARGO_PROFILE_RELEASE_DEBUG="0" CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="false" CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS="false" CARGO_PROFILE_RELEASE_STRIP="false" CARGO_TARGET_DIR="/build/rust/build/x86_64-unknown-linux-gnu/stage2-tools" CARGO_TARGET_I686_UNKNOWN_HAIKU_LINKER="i586-pc-haiku-gcc-x86" CC_i686_unknown_haiku="i586-pc-haiku-gcc-x86" CFG_COMPILER_BUILD_TRIPLE="x86_64-unknown-linux-gnu" CFG_COMPILER_HOST_TRIPLE="i686-unknown-haiku" CFG_RELEASE="1.94.1" CFG_RELEASE_CHANNEL="stable" CFG_RELEASE_NUM="1.94.1" CFG_VERSION="1.94.1 (e408947bf 2026-03-25)" CFG_VER_DATE="2026-03-25" CFG_VER_HASH="e408947bfd200af42db322daf0fadfe7e26d3bd1" CFLAGS_i686_unknown_haiku="" CXXFLAGS_i686_unknown_haiku="" CXX_i686_unknown_haiku="i586-pc-haiku-g++-x86" DOC_RUST_LANG_ORG_CHANNEL="https://doc.rust-lang.org/1.94.1" FORCE_ON_BROKEN_PIPE_KILL="-Zon-broken-pipe=kill" LIBC_CHECK_CFG="1" LZMA_API_STATIC="1" RANLIB_i686_unknown_haiku="i586-pc-haiku-ar-x86 s" REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" RUSTBUILD_NATIVE_DIR="/build/rust/build/i686-unknown-haiku/native" RUSTC="/build/rust/build/bootstrap/debug/rustc" RUSTC_BOOTSTRAP="1" RUSTC_BREAK_ON_ICE="1" RUSTC_ERROR_METADATA_DST="/build/rust/build/tmp/extended-error-metadata" RUSTC_HOST_FLAGS="--check-cfg=cfg(bootstrap)" RUSTC_INSTALL_BINDIR="bin" RUSTC_LIBDIR="/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_LINK_STD_INTO_RUSTC_DRIVER="1" RUSTC_LINT_FLAGS="-Wrust_2018_idioms -Wunused_lifetimes" RUSTC_REAL="/build/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT="/build/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT_LIBDIR="/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_STAGE="1" RUSTC_SYSROOT="/build/rust/build/x86_64-unknown-linux-gnu/stage1" RUSTC_TLS_MODEL_INITIAL_EXEC="1" RUSTC_VERBOSE="1" RUSTC_WRAPPER="/build/rust/build/bootstrap/debug/rustc" RUSTDOC="/build/rust/build/bootstrap/debug/rustdoc" RUSTDOCFLAGS="--cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zannotate-moves -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(rust_analyzer) -Wrustdoc::invalid_codeblock_attributes --crate-version 1.94.1\t(e408947bf\t2026-03-25) -Clinker=i586-pc-haiku-gcc-x86" RUSTDOC_LIBDIR="/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTDOC_REAL="/path/to/nowhere/rustdoc/not/required" RUSTFLAGS="--cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zannotate-moves -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(rust_analyzer) -Zdual-proc-macros -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/build/rust/build/x86_64-unknown-linux-gnu/llvm/lib\n -Alinker-messages -Zunstable-options" RUST_TEST_THREADS="8" SYSROOT="/build/rust/build/x86_64-unknown-linux-gnu/stage1" __CARGO_DEFAULT_LIB_METADATA="stabletool-rustc1.94.1" "/build/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "-Zwarnings" "--target" "i686-unknown-haiku" "-Zdual-proc-macros" "-Zbinary-dep-depinfo" "-j" "8" "-Zroot-dir=/build/rust" "--release" "--manifest-path" "/build/rust/src/tools/error_index_generator/Cargo.toml" "--message-format" "json-render-diagnostics" (failure_mode=Exit)
    Finished `release` profile [optimized] target(s) in 0.29s
running: LD_LIBRARY_PATH="/build/rust/build/i686-unknown-haiku/stage2/lib/rustlib/i686-unknown-haiku/lib:/build/rust/build/i686-unknown-haiku/stage2/lib" "/build/rust/build/x86_64-unknown-linux-gnu/stage2-tools-bin/error_index_generator" "html" "/build/rust/build/i686-unknown-haiku/doc" "1.94.1" (failure_mode=Exit) (created at src/bootstrap/src/core/build_steps/tool.rs:570:23, executed at src/bootstrap/src/core/build_steps/doc.rs:1258:14)
Command `LD_LIBRARY_PATH="/build/rust/build/i686-unknown-haiku/stage2/lib/rustlib/i686-unknown-haiku/lib:/build/rust/build/i686-unknown-haiku/stage2/lib" "/build/rust/build/x86_64-unknown-linux-gnu/stage2-tools-bin/error_index_generator" "html" "/build/rust/build/i686-unknown-haiku/doc" "1.94.1" (failure_mode=Exit)` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:570:23
Executed at: src/bootstrap/src/core/build_steps/doc.rs:1258:14

Traceback (most recent call last):
  File "/build/rust/./x.py", line 53, in <module>
    bootstrap.main()
  File "/build/rust/src/bootstrap/bootstrap.py", line 1410, in main
    bootstrap(args)
  File "/build/rust/src/bootstrap/bootstrap.py", line 1370, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
  File "/build/rust/src/bootstrap/bootstrap.py", line 237, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /build/rust/build/bootstrap/debug/bootstrap -j 8 -v dist

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the error_index_generator build and execution through src/bootstrap/src/core/build_steps/tool.rs and src/bootstrap/src/core/build_steps/doc.rs, using src/tools/error_index_generator/Cargo.toml and the reported x.py dist command as entry points. Verify why the tool is built for the cross target instead of the build machine, then confirm that documentation generation runs successfully during this cross-compilation scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.