Skip to content

fix(ld64.lld): route version mismatch warnings to linker_info on macOS#159666

Open
r3v5 wants to merge 1 commit into
rust-lang:mainfrom
r3v5:fix-llvm-ld64-lld-linker-stderr-warnings
Open

fix(ld64.lld): route version mismatch warnings to linker_info on macOS#159666
r3v5 wants to merge 1 commit into
rust-lang:mainfrom
r3v5:fix-llvm-ld64-lld-linker-stderr-warnings

Conversation

@r3v5

@r3v5 r3v5 commented Jul 21, 2026

Copy link
Copy Markdown

View all comments

r? jyn514

Fixes #159227

Issue: .o objects (e.g. precompiled stdlib .rlib files, C libraries compiled via cc-rs) receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0)

That’s why hundreds of warning logs appear such as warning: linker stderr: rust-lld: /path/file.rlib(file.o) has version 26.4.1, which is newer than target minimum of 11.0.0. These warnings were already filtered for ld64 and ld_prime but not for lld (see #136113).

Root cause: I believe that the current function is_macos_ld() in compiler/rustc_codegen_ssa/src/back/link.rs handles the case when we use native macOS linker so the entire filtering chain in linker output is skipped when using ld64.lld. Relevant code:

fn is_macos_ld(sess: &Session) -> bool {
    let (_, flavor) = linker_and_flavor(sess);
    sess.target.is_like_darwin && matches!(flavor, LinkerFlavor::Darwin(_, Lld::No))

}

So, Lld::No means using native macOS linker, so when lld is used via Lld::Yes, the match fails and the function returns false hence all warnings come from stderr to linker_messages which are visible.

My proposed solution: modify filtering such that it runs for lld too and add a new specific ld64.lld warning pattern routing warnings to linker_info to make them invisible by default.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 21, 2026
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @petrochenkov (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 17 candidates

@r3v5

r3v5 commented Jul 21, 2026

Copy link
Copy Markdown
Author

r? jyn514

@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to jyn514: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

1 similar comment
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to jyn514: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@theemathas

Copy link
Copy Markdown
Contributor

r? @jyn514

@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to jyn514: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@jyn514 jyn514 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense, i missed this when i added the lint silencing originally.

the code seems fine to me :) one comment about the test.

View changes since this review

Comment thread tests/run-make/macos-lld-version-warning/fake-linker.rs Outdated
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2026
@r3v5
r3v5 force-pushed the fix-llvm-ld64-lld-linker-stderr-warnings branch from cb63076 to 3705b3e Compare July 22, 2026 15:31
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@r3v5
r3v5 requested a review from jyn514 July 22, 2026 15:33

@jyn514 jyn514 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me. the bug itself is a clear oversight from when i added this lint, the fix is simple, the test uses a real LLD run to make sure the warning matches.

there's one thing in the PR description that doesn't look quite right:

Issue: When use ld64.lld linker, dependencies (e.g. C libraries) inside .o objects receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

this is not specific to LLD, it would happen with any linker. the thing that causes this is actually flags passed by cc-rs when used in a build.rs; see #136113:

However, this does not match the default behavior for clang, which defaults to the selected SDK versions; unless changed otherwise, a C program built with clang uses the macOS host version as deployment target. The cc-rs crate also defaults to this behavior.

please update the PR description. other than that everything looks good to me.

View changes since this review

@r3v5

r3v5 commented Jul 23, 2026

Copy link
Copy Markdown
Author

this looks good to me. the bug itself is a clear oversight from when i added this lint, the fix is simple, the test uses a real LLD run to make sure the warning matches.

there's one thing in the PR description that doesn't look quite right:

Issue: When use ld64.lld linker, dependencies (e.g. C libraries) inside .o objects receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

this is not specific to LLD, it would happen with any linker. the thing that causes this is actually flags passed by cc-rs when used in a build.rs; see #136113:

However, this does not match the default behavior for clang, which defaults to the selected SDK versions; unless changed otherwise, a C program built with clang uses the macOS host version as deployment target. The cc-rs crate also defaults to this behavior.

please update the PR description. other than that everything looks good to me.

View changes since this review

I have updated PR description, thanks!

@r3v5
r3v5 requested a review from jyn514 July 23, 2026 15:02
@jyn514

jyn514 commented Jul 23, 2026

Copy link
Copy Markdown
Member

the CI failure looks like just a flake.

@petrochenkov i'm happy with this PR, would you mind taking a look?

@rustbot ready

(@r3v5 note that you can also run rustbot ready yourself, that lets the reviewer know that this is waiting on them.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 23, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after squashing commits.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2026
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@r3v5
r3v5 force-pushed the fix-llvm-ld64-lld-linker-stderr-warnings branch from 3705b3e to 5ad773b Compare July 23, 2026 16:00
@r3v5

r3v5 commented Jul 23, 2026

Copy link
Copy Markdown
Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 23, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5ad773b has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…rr-warnings, r=petrochenkov

fix(ld64.lld): route version mismatch warnings to linker_info on macOS

r? jyn514

Fixes rust-lang#159227

**Issue:** .o objects (e.g. precompiled stdlib .rlib files, C libraries compiled via cc-rs) receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

[`(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0)`](https://github.com/rust-lang/rust/blob/f65b272fc92b1e7527dea4a224430a249ab25c2d/compiler/rustc_target/src/spec/base/apple/mod.rs#L332)

 That’s why hundreds of warning logs appear such as warning: `linker stderr: rust-lld: /path/file.rlib(file.o) has version 26.4.1, which is newer than target minimum of 11.0.0`. These warnings were already filtered for ld64 and ld_prime but not for lld (see rust-lang#136113).

**Root cause:** I believe that the current function `is_macos_ld()` in [compiler/rustc_codegen_ssa/src/back/link.rs](https://github.com/rust-lang/rust/blob/730a6b5dce9477b819de0ba79d6e7945e1248e3d/compiler/rustc_codegen_ssa/src/back/link.rs#L874) handles the case when we use native macOS linker so the entire filtering chain in linker output is skipped when using ld64.lld. Relevant code:

```
fn is_macos_ld(sess: &Session) -> bool {
    let (_, flavor) = linker_and_flavor(sess);
    sess.target.is_like_darwin && matches!(flavor, LinkerFlavor::Darwin(_, Lld::No))

}
```
So, `Lld::No` means using native macOS linker, so when lld is used via `Lld::Yes`, the match fails and the function returns `false` hence all warnings come from stderr to linker_messages which are visible.

**My proposed solution:** modify filtering such that it runs for lld too and add a new specific ld64.lld warning pattern routing warnings to linker_info to make them invisible by default.
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…rr-warnings, r=petrochenkov

fix(ld64.lld): route version mismatch warnings to linker_info on macOS

r? jyn514

Fixes rust-lang#159227

**Issue:** .o objects (e.g. precompiled stdlib .rlib files, C libraries compiled via cc-rs) receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

[`(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0)`](https://github.com/rust-lang/rust/blob/f65b272fc92b1e7527dea4a224430a249ab25c2d/compiler/rustc_target/src/spec/base/apple/mod.rs#L332)

 That’s why hundreds of warning logs appear such as warning: `linker stderr: rust-lld: /path/file.rlib(file.o) has version 26.4.1, which is newer than target minimum of 11.0.0`. These warnings were already filtered for ld64 and ld_prime but not for lld (see rust-lang#136113).

**Root cause:** I believe that the current function `is_macos_ld()` in [compiler/rustc_codegen_ssa/src/back/link.rs](https://github.com/rust-lang/rust/blob/730a6b5dce9477b819de0ba79d6e7945e1248e3d/compiler/rustc_codegen_ssa/src/back/link.rs#L874) handles the case when we use native macOS linker so the entire filtering chain in linker output is skipped when using ld64.lld. Relevant code:

```
fn is_macos_ld(sess: &Session) -> bool {
    let (_, flavor) = linker_and_flavor(sess);
    sess.target.is_like_darwin && matches!(flavor, LinkerFlavor::Darwin(_, Lld::No))

}
```
So, `Lld::No` means using native macOS linker, so when lld is used via `Lld::Yes`, the match fails and the function returns `false` hence all warnings come from stderr to linker_messages which are visible.

**My proposed solution:** modify filtering such that it runs for lld too and add a new specific ld64.lld warning pattern routing warnings to linker_info to make them invisible by default.
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 24, 2026
…rr-warnings, r=petrochenkov

fix(ld64.lld): route version mismatch warnings to linker_info on macOS

r? jyn514

Fixes rust-lang#159227

**Issue:** .o objects (e.g. precompiled stdlib .rlib files, C libraries compiled via cc-rs) receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

[`(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0)`](https://github.com/rust-lang/rust/blob/f65b272fc92b1e7527dea4a224430a249ab25c2d/compiler/rustc_target/src/spec/base/apple/mod.rs#L332)

 That’s why hundreds of warning logs appear such as warning: `linker stderr: rust-lld: /path/file.rlib(file.o) has version 26.4.1, which is newer than target minimum of 11.0.0`. These warnings were already filtered for ld64 and ld_prime but not for lld (see rust-lang#136113).

**Root cause:** I believe that the current function `is_macos_ld()` in [compiler/rustc_codegen_ssa/src/back/link.rs](https://github.com/rust-lang/rust/blob/730a6b5dce9477b819de0ba79d6e7945e1248e3d/compiler/rustc_codegen_ssa/src/back/link.rs#L874) handles the case when we use native macOS linker so the entire filtering chain in linker output is skipped when using ld64.lld. Relevant code:

```
fn is_macos_ld(sess: &Session) -> bool {
    let (_, flavor) = linker_and_flavor(sess);
    sess.target.is_like_darwin && matches!(flavor, LinkerFlavor::Darwin(_, Lld::No))

}
```
So, `Lld::No` means using native macOS linker, so when lld is used via `Lld::Yes`, the match fails and the function returns `false` hence all warnings come from stderr to linker_messages which are visible.

**My proposed solution:** modify filtering such that it runs for lld too and add a new specific ld64.lld warning pattern routing warnings to linker_info to make them invisible by default.
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 24, 2026
…rr-warnings, r=petrochenkov

fix(ld64.lld): route version mismatch warnings to linker_info on macOS

r? jyn514

Fixes rust-lang#159227

**Issue:** .o objects (e.g. precompiled stdlib .rlib files, C libraries compiled via cc-rs) receive MacOS version of the machine they were compiled on and that version is much higher than Rust's default deployment target for aarch64-apple-darwin which is macOS 11.0.0.

[`(Os::MacOs, crate::spec::Arch::AArch64, _) => (11, 0, 0)`](https://github.com/rust-lang/rust/blob/f65b272fc92b1e7527dea4a224430a249ab25c2d/compiler/rustc_target/src/spec/base/apple/mod.rs#L332)

 That’s why hundreds of warning logs appear such as warning: `linker stderr: rust-lld: /path/file.rlib(file.o) has version 26.4.1, which is newer than target minimum of 11.0.0`. These warnings were already filtered for ld64 and ld_prime but not for lld (see rust-lang#136113).

**Root cause:** I believe that the current function `is_macos_ld()` in [compiler/rustc_codegen_ssa/src/back/link.rs](https://github.com/rust-lang/rust/blob/730a6b5dce9477b819de0ba79d6e7945e1248e3d/compiler/rustc_codegen_ssa/src/back/link.rs#L874) handles the case when we use native macOS linker so the entire filtering chain in linker output is skipped when using ld64.lld. Relevant code:

```
fn is_macos_ld(sess: &Session) -> bool {
    let (_, flavor) = linker_and_flavor(sess);
    sess.target.is_like_darwin && matches!(flavor, LinkerFlavor::Darwin(_, Lld::No))

}
```
So, `Lld::No` means using native macOS linker, so when lld is used via `Lld::Yes`, the match fails and the function returns `false` hence all warnings come from stderr to linker_messages which are visible.

**My proposed solution:** modify filtering such that it runs for lld too and add a new specific ld64.lld warning pattern routing warnings to linker_info to make them invisible by default.
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 12 pull requests

Successful merges:

 - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159271 (str: add ASCII fast path to word_to_titlecase)
 - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
@jhpratt

jhpratt commented Jul 24, 2026

Copy link
Copy Markdown
Member

@bors r- #159807 (comment)

---- [run-make] tests/run-make/macos-deployment-target-warning stdout ----

error: rmake recipe failed to complete
status: exit status: 1
command: cd "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" && env -u RUSTFLAGS -u __STD_REMAP_DEBUGINFO_ENABLED AR="ar" BUILD_ROOT="/Users/runner/work/rust/rust/build/aarch64-apple-darwin" CC="cc" CC_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=11" CXX="c++" CXX_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=11 -stdlib=libc++" DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" HOST_RUSTC_DYLIB_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib" LD_LIB_PATH_ENVVAR="DYLD_LIBRARY_PATH" LLVM_BIN_DIR="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils abi aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgputargetmca amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cas cfguard cgdata codegen codegentypes core coroutines coverage csky cskyasmparser cskycodegen cskydesc cskydisassembler cskyinfo debuginfobtf debuginfocodeview debuginfodwarf debuginfodwarflowlevel debuginfogsym debuginfologicalview debuginfomsf debuginfopdb demangle dlltooldriver dtlto dwarfcfichecker dwarflinker dwarflinkerclassic dwarflinkerparallel dwp engine executionengine extensions filecheck frontendatomic frontenddirective frontenddriver frontendhlsl frontendoffloading frontendopenacc frontendopenmp fuzzercli fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo hipstdpar instcombine instrumentation interfacestub interpreter ipo irprinter irreader jitlink libdriver lineeditor linker loongarch loongarchasmparser loongarchcodegen loongarchdesc loongarchdisassembler loongarchinfo lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts objcopy object objectyaml option orcdebugging orcjit orcshared orctargetprocess passes plugins powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvtargetmca runtimedyld sandboxir scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support supportlsp symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target targetparser telemetry textapi textapibinaryreader transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsdriver windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xray xtensa xtensaasmparser xtensacodegen xtensadesc xtensadisassembler xtensainfo" LLVM_FILECHECK="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/build/bin/FileCheck" NODE="/opt/homebrew/bin/node" PYTHON="/opt/homebrew/opt/python@3.14/bin/python3.14" RUSTC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" RUSTDOC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustdoc" SOURCE_ROOT="/Users/runner/work/rust/rust" TARGET="aarch64-apple-darwin" TARGET_EXE_DYLIB_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" __BOOTSTRAP_JOBS="3" __RMAKE_VERBOSE_SUBPROCESS_OUTPUT="1" __RUSTC_DEBUG_ASSERTIONS_ENABLED="1" __STD_DEBUG_ASSERTIONS_ENABLED="1" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake"
stdout: none
--- stderr -------------------------------
"cc" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=11" "-c" "-mmacosx-version-min=15.5" "-o" "foo.o" "foo.c"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



"/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/bin/llvm-ar" "rcus" "libfoo.a" "foo.o"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lstatic=foo" "-Clink-arg=-mmacosx-version-min=11.2" "main.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===
warning: ld: warning: object file (/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/libfoo.a[2](foo.o)) was built for newer 'macOS' version (15.5) than being linked (11.2)
         
  |
note: the lint level is defined here
 --> main.rs:1:9
  |
---




"cc" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=11" "-shared" "-mmacosx-version-min=15.5" "-o" "libbar.dylib" "foo.c"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lbar" "-Clink-arg=-mmacosx-version-min=11.2" "main_dylib.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===
warning: ld: warning: building for macOS-11.2, but linking with dylib 'libbar.dylib' which was built for newer version 15.5
         
  |
note: the lint level is defined here
 --> main_dylib.rs:1:9
  |
---



command failed at line 70
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lstatic=foo" "-Clink-arg=-mmacosx-version-min=11.2" "-Clink-arg=-fuse-ld=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/ld64.lld" "main.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 1`
=== STDOUT ===



=== STDERR ===
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/rustcEbqyX5/symbols.o" "<2 object files omitted>" "-lfoo" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-o" "main" "-Wl,-dead_strip" "-nodefaultlibs" "-mmacosx-version-min=11.2" "-fuse-ld=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/ld64.lld"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: clang: error: invalid linker name in argument '-fuse-ld=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/ld64.lld'
          

error: aborting due to 1 previous error
------------------------------------------

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 24, 2026
@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

Broaden `is_macos_ld` to `is_macos_linker` by matching `Darwin(..)`
instead of `Darwin(_, Lld::No)`, so the linker output filtering also
runs when lld is used. Add lld-specific version mismatch pattern to
`deployment_mismatch` closure, routing these warnings to `linker_info`
(default Allow) instead of `linker_messages` (default Warn).

Add a real-lld sub-test to `macos-deployment-target-warning` that
exercises the `ld64.lld` path via `-fuse-ld=`, verifying lld warnings
are normalized and routed to `linker_info`.

Signed-off-by: Ian Miller <milleryan2003@gmail.com>
@r3v5
r3v5 force-pushed the fix-llvm-ld64-lld-linker-stderr-warnings branch from 5ad773b to ebec21d Compare July 24, 2026 12:20
@r3v5

r3v5 commented Jul 24, 2026

Copy link
Copy Markdown
Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 24, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try jobs=aarch64-apple

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
…, r=<try>

fix(ld64.lld): route version mismatch warnings to linker_info on macOS


try-job: aarch64-apple
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2026
@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 806738b failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-apple failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [run-make] tests/run-make/macos-deployment-target-warning stdout ----

error: rmake recipe failed to complete
status: exit status: 1
command: cd "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" && env -u RUSTFLAGS -u __STD_REMAP_DEBUGINFO_ENABLED AR="ar" BUILD_ROOT="/Users/runner/work/rust/rust/build/aarch64-apple-darwin" CC="cc" CC_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=11" CXX="c++" CXX_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=11 -stdlib=libc++" DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" HOST_RUSTC_DYLIB_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib" LD_LIB_PATH_ENVVAR="DYLD_LIBRARY_PATH" LLVM_BIN_DIR="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils abi aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgputargetmca amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cas cfguard cgdata codegen codegentypes core coroutines coverage csky cskyasmparser cskycodegen cskydesc cskydisassembler cskyinfo debuginfobtf debuginfocodeview debuginfodwarf debuginfodwarflowlevel debuginfogsym debuginfologicalview debuginfomsf debuginfopdb demangle dlltooldriver dtlto dwarfcfichecker dwarflinker dwarflinkerclassic dwarflinkerparallel dwp engine executionengine extensions filecheck frontendatomic frontenddirective frontenddriver frontendhlsl frontendoffloading frontendopenacc frontendopenmp fuzzercli fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo hipstdpar instcombine instrumentation interfacestub interpreter ipo irprinter irreader jitlink libdriver lineeditor linker loongarch loongarchasmparser loongarchcodegen loongarchdesc loongarchdisassembler loongarchinfo lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts objcopy object objectyaml option orcdebugging orcjit orcshared orctargetprocess passes plugins powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvtargetmca runtimedyld sandboxir scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support supportlsp symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target targetparser telemetry textapi textapibinaryreader transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsdriver windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xray xtensa xtensaasmparser xtensacodegen xtensadesc xtensadisassembler xtensainfo" LLVM_FILECHECK="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/build/bin/FileCheck" NODE="/opt/homebrew/bin/node" PYTHON="/opt/homebrew/opt/python@3.14/bin/python3.14" RUSTC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" RUSTDOC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustdoc" SOURCE_ROOT="/Users/runner/work/rust/rust" TARGET="aarch64-apple-darwin" TARGET_EXE_DYLIB_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" __BOOTSTRAP_JOBS="3" __RMAKE_VERBOSE_SUBPROCESS_OUTPUT="1" __RUSTC_DEBUG_ASSERTIONS_ENABLED="1" __STD_DEBUG_ASSERTIONS_ENABLED="1" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake"
stdout: none
--- stderr -------------------------------
"cc" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=11" "-c" "-mmacosx-version-min=15.5" "-o" "foo.o" "foo.c"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



"/Users/runner/work/rust/rust/build/aarch64-apple-darwin/llvm/bin/llvm-ar" "rcus" "libfoo.a" "foo.o"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lstatic=foo" "-Clink-arg=-mmacosx-version-min=11.2" "main.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===
warning: ld: warning: object file (/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/libfoo.a[2](foo.o)) was built for newer 'macOS' version (15.5) than being linked (11.2)
         
  |
note: the lint level is defined here
 --> main.rs:1:9
  |
---




"cc" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=11" "-shared" "-mmacosx-version-min=15.5" "-o" "libbar.dylib" "foo.c"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===



DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lbar" "-Clink-arg=-mmacosx-version-min=11.2" "main_dylib.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 0`
=== STDOUT ===



=== STDERR ===
warning: ld: warning: building for macOS-11.2, but linking with dylib 'libbar.dylib' which was built for newer version 15.5
         
  |
note: the lint level is defined here
 --> main_dylib.rs:1:9
  |
---



command failed at line 72
DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/aarch64-apple-darwin/release/build/run_make_support/8823fa2c7520abf5/out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out" "-lstatic=foo" "-Clink-self-contained=-linker" "-Zunstable-options" "-Clinker-flavor=darwin-lld" "-Clinker=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/ld64.lld" "main.rs" "--crate-type" "bin" "--target=aarch64-apple-darwin"
output status: `exit status: 1`
=== STDOUT ===



=== STDERR ===
error: linker `/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/macos-deployment-target-warning/rmake_out/ld64.lld` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to 1 previous error
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

7 participants