Skip to content

Rustc_driver cann't correctly find codegen dirs with multiple subfolders in libdir. #57014

Open
@o01eg

Description

@o01eg

When rust compiled and installed with multiple subfolders in libdir it cann't correctly found directory with codegen-backends. See rust-lang/rust-clippy#3565

        // use `parent` twice to chop off the file name and then also the
        // directory containing the dll which should be either `lib` or `bin`.
        if let Some(path) = dll.parent().and_then(|p| p.parent()) {

https://github.com/rust-lang/rust/blob/master/src/librustc_driver/lib.rs#L302

It would be work if rustc_driver was placed in /usr/lib64/librustc_driver-62d9b292bf74f4a6.so so it get /usr as sysroot but it placed in /usr/lib64/rust-9999/librustc_driver-62d9b292bf74f4a6.so so it get incorrect /usr/lib64.

I suppose it could be two possible solutions: The first is about to iterate parents until root will be reached. The second is to calculate number of parents need to be removed with find_libdir from filesearch.rs. Which are better or there are some other ways to solve this?

P.S. Looks like it doesn't fail for system-wide installed rustc and clippy because filesearch::get_or_default_sysroot got correct /usr sysroot from binaries in /usr/bin. If them will be moved same way as gcc in Gentoo it will break as well:

$ echo `which gcc`
/usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0/gcc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions