rust-lang / rust-lang/rust

Add some sort of `-Clink-sdkroot=...` flag?

Open
#146,345 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage C-feature-request E-needs-design O-apple T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

rustc uses the SDKROOT environment variable to figure out details about the SDK to pass onward to the linker (linker stubs and the SDK version). If this flag is not set, or is set for the wrong platform, we fall back to invoking xcrun --sdk $platform --show-sdk-path.

It might be beneficial to add a commandline flag to allow passing this information as well? This has been requested by Chromium in https://github.com/rust-lang/rust/pull/131477#issuecomment-3267289223, see that for motivation.

Alternatively / additionally, we could add a flag to completely opt out of passing SDK information to the linker, such as -Clinker-features=-sdkroot (partially reverting to the state before https://github.com/rust-lang/rust/pull/131477). Such a flag might also be useful for e.g. cargo zigbuild (which provides the SDK internally).

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 rustc's handling of SDKROOT, the wrong-platform fallback through xcrun, and the linker flags described in the issue and referenced pull request. Clarify whether the intended result is an SDK-root flag, an opt-out linker feature, or both; done means the selected behavior is specified for the linker and the cargo zigbuild use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.