Skip to content

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

Closed

Description

@farao

I faced a regression in building rust for l4re introduced by #158823. The core of the problem seems to be that FileSearch (from compilter/rustc_session/src/filesearch.rs) is used both to locate C runtime objects (crt*) and native libraries. However, #158823 introduces a prefix-filtering of the files found in the search paths (given by "-L" or "-Lnative") and this prefix only selects libraries and discards crt objects:

let prefixes = ["lib", &target.staticlib_prefix, &target.dll_prefix];
...
    if !prefixes.iter().any(|prefix| filename.starts_with(prefix)) {                                                                                                          
      return None;                                                                                                                                                          
    }                                                                                                                                                                         

A bit more detailled: My target config uses pre_link_objects to define the file names of the crt* files. These files are searched for in rustc_codegen_ssa/src/back/link.rs in link_natively(...) via get_object_file_path(..) which after the change uses get_file_candidates(...) which due to the filtering explained above only includes libraries.

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Aug 3, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 3, 2026
  3. lqd commented on Aug 3, 2026

    @lqd
    Member
  4. Kobzol commented on Aug 3, 2026

    @Kobzol
    Member

    Bah, I knew that I should skip this micro-optimization and only use get_file_candidates for the rlib lookup. Thanks for the report! #160449 should hopefully fix this.

  5. added a commit that references this issue on Aug 3, 2026
  6. added 2 commits that reference this issue on Aug 4, 2026
  7. added a commit that references this issue on Aug 4, 2026
  8. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 4, 2026
  9. added a commit that references this issue on Aug 4, 2026
  10. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 4, 2026
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

    C-bugCategory: This is a bug.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions