Skip to content

Add some sort of -Clink-sdkroot=... flag? #146345

Open

Description

@madsmtm

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 #131477 (comment), 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 #131477). Such a flag might also be useful for e.g. cargo zigbuild (which provides the SDK internally).

Activity

  1. added
    A-linkageArea: linking into static, shared libraries and binaries
    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
    O-appleOperating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)
    E-needs-designThis issue needs exploration and design to see how and if we can fix/implement it
    on Sep 8, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 8, 2025
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 9, 2025
  4. madsmtm commented on Sep 27, 2025

    @madsmtm
    MemberAuthor

    Similarly, we might want to add -Cdeployment-target=... for controlling the values that we otherwise take from the MACOSX_DEPLOYMENT_TARGET/similar environment variables.

  5. nico commented on Feb 20, 2026

    @nico

    Another thing I just discovered: macOS system python3 gets really confused if SDKROOT is set. We (chromium) have to set SDKROOT at the moment (see linked discussion). If there was a flag, we could use that and sidestep that issue.

    % SDKROOT=$PWD/out/gn/sdk/xcode_links/MacOSX26.2.sdk python3
    python3: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Users/thakis/src/v8/v8/out/gn/sdk/xcode_links/MacOSX26.2.sdk -find python3 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
    xcode-select: Failed to locate 'python3', requesting installation of command line developer tools.
    
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

    A-linkageArea: linking into static, shared libraries and binariesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itO-appleOperating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions