Skip to content

Do not set library kind to dylib if not specified - #3049

Merged
sylvestre merged 4 commits into
mozilla:mainfrom
anti-social:main
Nov 20, 2026
Merged

sylvestre merged 4 commits into
mozilla:mainfrom
anti-social:main

Conversation

@anti-social

@anti-social anti-social commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3048

@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.26%. Comparing base (43c90af) to head (1be820d).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/rust.rs 92.10% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3049      +/-   ##
==========================================
+ Coverage   79.16%   79.26%   +0.09%     
==========================================
  Files          75       75              
  Lines       46166    46400     +234     
==========================================
+ Hits        36548    36779     +231     
- Misses       9618     9621       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A library without a kind must stay without one: rustc picks the kind per
target (e.g. static with crt-static), so turning it into dylib changes
the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sylvestre

Copy link
Copy Markdown
Collaborator

thanks for looking into this!
The fix looks right, but it needs a test showing that -l bar is passed to rustc unchanged (details inline).

Comment thread src/compiler/rust.rs Outdated
// aren't copied into the rlib, so they don't change the output.
let bundled_static = match kind.split_once(':') {
// Libraries without a kind are never bundled.
let kind_and_modifiers = kind

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could be simpler with is_some_and, no?
kind.as_deref().is_some_and(|kind| { let (kind, modifiers) = kind.split_once(':').unwrap_or((kind, "")); kind == "static" && ... })

(fine in a different PR)

@anti-social

Copy link
Copy Markdown
Contributor Author

thanks for looking into this! The fix looks right, but it needs a test showing that -l bar is passed to rustc unchanged (details inline).

I run the tests before the fix and it failed (maybe you started your review before the commit with the test):

running 4 tests
test compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_3_static_with_modifiers ... ok
test compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_2_static ... ok
test compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_4_dylib ... ok
test compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_1_without_kind ... FAILED

failures:

---- compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_1_without_kind stdout ----
thread 'compiler::rust::test::test_parse_arguments_link_library_is_passed_unchanged::test_case_1_without_kind' (34) panicked at src/compiler/rust.rs:3780:9:
assertion `left == right` failed
  left: "dylib=bar"
 right: "bar"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@sylvestre

Copy link
Copy Markdown
Collaborator

ok, please run rustfmt

@sylvestre
sylvestre merged commit 153cad6 into mozilla:main Nov 20, 2026
51 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

codeandsolder added a commit to codeandsolder/sccache-deduplicated that referenced this pull request Nov 22, 2026
* rust: hash static libraries passed with link modifiers

(cherry picked from commit b63a6ed)

* Do not set library kind to dylib if not specified (mozilla#3049)

* Do not set library kind to dylib if not specified

* Test that -l arguments reach rustc unchanged

A library without a kind must stay without one: rustc picks the kind per
target (e.g. static with crt-static), so turning it into dylib changes
the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Simplify parsing bundled link arguments

* Fix code formatting

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 153cad6)

* rust: treat the -C profile-use file as an input, not an output

rustc lists the profile in its dep-info, so its contents already reach the hash key. Listing it as an output made every cache hit write it back, and the new mtime made cargo rebuild every crate that reads it.

Fixes mozilla#2960

(cherry picked from commit 60e5268)

* rust: parse the profile-use test's arguments with parses!

The match's fallback arm only runs when parsing fails, so it was a line of
the patch no test could cover. The arguments need no working directory
(no response file, no -L path), which is what parses! assumes.

(cherry picked from commit 13d7023)

* rust: unescape env-dep names and values

rustc escapes backslashes, newlines and carriage returns in them. Keys
change once for crates whose env-deps contain one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a9d792d)

* rust: preserve native-library input and PGO path semantics across layouts

* rust: remove unused formatting import

---------

Co-authored-by: tiny-ac <agostina@wyeworks.com>
Co-authored-by: Alexander <kovalidis@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: feder-cr <85809106+feder-cr@users.noreply.github.com>
Co-authored-by: ghoulspa <331221112+ghoulspa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken static linking of libstdc++ on musl

3 participants