Skip to content

Fix lookup of object files - #160449

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Kobzol:filesearch-lookup-fix
Aug 4, 2026
Merged

Fix lookup of object files#160449
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Kobzol:filesearch-lookup-fix

Conversation

@Kobzol

@Kobzol Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member

I broke this in #158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: #160446

@rustbot rustbot added 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 Aug 3, 2026
@rust-log-analyzer

This comment has been minimized.

if path.file_name().map_or(false, |n| n == OsStr::new(name)) && path.exists() {
return path;
// Note: this is O(n^2), it could be expensive-ish if we lookup many object files for many
// search paths

@petrochenkov petrochenkov Aug 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thankfully, we only lookup 1-3 object files in these directories (if we lookup them at all).

View changes since the review

@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after fixing CI.
@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 Aug 3, 2026
@Kobzol
Kobzol force-pushed the filesearch-lookup-fix branch from 63b5363 to 07e1398 Compare August 3, 2026 16:46
@Kobzol

Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@bors r=petrochenkov rollup

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 07e1398 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…trochenkov

Fix lookup of object files

I broke this in rust-lang#158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: rust-lang#160446
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
…uwer

Rollup of 26 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #158727 (std: use `readdir` on nearly all UNIX platforms)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
…trochenkov

Fix lookup of object files

I broke this in rust-lang#158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: rust-lang#160446
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
…trochenkov

Fix lookup of object files

I broke this in rust-lang#158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: rust-lang#160446
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 29 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #160434 (Avoid Docker push when the image did not change)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
@rust-bors
rust-bors Bot merged commit 3ee6e30 into rust-lang:main Aug 4, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 4, 2026
@Kobzol
Kobzol deleted the filesearch-lookup-fix branch August 4, 2026 12:40
rust-timer added a commit that referenced this pull request Aug 4, 2026
Rollup merge of #160449 - Kobzol:filesearch-lookup-fix, r=petrochenkov

Fix lookup of object files

I broke this in #158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: #160446
WhySoBad pushed a commit to WhySoBad/miri that referenced this pull request Aug 5, 2026
Rollup of 29 pull requests

Successful merges:

 - rust-lang/rust#153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - rust-lang/rust#159130 (a bit optimize four-digit chunks in integer formatting)
 - rust-lang/rust#159326 (Deny multiple EII impls on a single item)
 - rust-lang/rust#159535 (Optimize slice::contains for bytewise types)
 - rust-lang/rust#159595 (Promote loongarch32-unknown-none* to Tier 2)
 - rust-lang/rust#160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - rust-lang/rust#160320 (point at trait definition when it is used as a derive macro)
 - rust-lang/rust#160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - rust-lang/rust#160406 (`DepKind` cleanups)
 - rust-lang/rust#160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - rust-lang/rust#160434 (Avoid Docker push when the image did not change)
 - rust-lang/rust#159303 (Fix ICE for direct inline const generic defaults)
 - rust-lang/rust#159977 (Add regression test for bool indexing codegen)
 - rust-lang/rust#160011 (remove InterpError::map_err_info)
 - rust-lang/rust#160165 (reject `...` without pattern post-expansion)
 - rust-lang/rust#160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - rust-lang/rust#160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - rust-lang/rust#160305 (Linkify C-SKY targets in `platform-support.md`)
 - rust-lang/rust#160314 (fix borrowck ICE for consts with fn pointer type)
 - rust-lang/rust#160322 (ElaborateBoxDeref: remove unnecessary projection)
 - rust-lang/rust#160338 (Add regression test for supertrait associated type normalization through dyn)
 - rust-lang/rust#160340 (Add regression test for unused_parens on contract clauses)
 - rust-lang/rust#160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - rust-lang/rust#160384 (Add PR body notes for Cargo lock file maintenance)
 - rust-lang/rust#160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - rust-lang/rust#160427 (Run try builds on EC2 by default)
 - rust-lang/rust#160435 (bump tracing-tree)
 - rust-lang/rust#160449 (Fix lookup of object files)
 - rust-lang/rust#160477 (Update the tracking issue for `borrowed_buf_init`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: crt* Objects not found in library search path after #158823

4 participants