rust-lang / rust-lang/rust

A way to out-put building self-contained deps

Open
#147,065 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

Posted by @denizsokmen https://github.com/rust-lang/rust/pull/141375#issuecomment-3338693161:

Custom target issue is actually more related to Rust bootstrap forcefully cross-compiling crtbegin, crtend and llvm-libunwind for musl for self-contained linkage reasons: https://github.com/rust-lang/rust/blob/40ace17fc3891155bad26a50d60a9ab07b83bf8e/src/bootstrap/src/core/build_steps/compile.rs#L422 and https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/core/config/target_selection.rs#L96

I see no way to opt out of that, even though those binaries won't be used as they'll be fetched from the sysroot of that musl-based custom target. Is there a way to tell Rust bootstrap not to bother with preparing self-contained binaries?

Expected behaviour

A way to out-put crtbegin, crtend and llvm-libunwind build for custom musl target.

Actual behaviour

You'll need to patch code as described: https://github.com/rust-lang/rust/pull/141375#issuecomment-3338710930.

Possible solution

Probalby extend the target table in bootstrap.toml like target.self-contained = <bool>?

Bootstrap configuration (bootstrap.toml)
[target.my-custom-musl]
linker = "…"
musl-root = "…"
cc = "…"
cxx = "…"
cflags = "…"
cxxflags = "…"
rustflags= "…"
llvm-libunwind = "system"
HEAD

5b9007bfc358817cf066ee27c6b440440727d3a7

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

Start by reading src/bootstrap/src/core/build_steps/compile.rs around the crtbegin, crtend, and llvm-libunwind handling, then follow the target configuration in src/bootstrap/src/core/config/target_selection.rs. Review the custom target settings shown in bootstrap.toml and the referenced pull-request discussion. Done should provide a documented configuration path that avoids unnecessary self-contained builds for the custom musl target.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.