Skip to content

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

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

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