Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
o01eg opened this issue Dec 20, 2018 · 5 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@o01eg
Copy link
Contributor

o01eg commented Dec 20, 2018

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
@o01eg
Copy link
Contributor Author

o01eg commented Dec 20, 2018

Third solution I came up with is if librustc_driver*.so placed in the libdir why it's required to search sysroot if it possible to simply add $RUST_LIB_DIR/$target/codegen-backends to get correct codegen folder?

@o01eg
Copy link
Contributor Author

o01eg commented Dec 20, 2018

The current algorithm was introduced in 884715c
cc @alexcrichton

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jan 3, 2019
Search codegen backends based on target libdir instead of sysroot

Fixes rust-lang#57014

Fixes cases with custom libdir when it consists of two or more parts.
bors added a commit that referenced this issue Jan 5, 2019
Search codegen backends based on target libdir instead of sysroot

Fixes #57014

Fixes cases with custom libdir when it consists of two or more parts.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 7, 2019
This reverts commit 6861426, reversing
changes made to cae623c.

Should fix tools on windows.

Reopens rust-lang#57014
@o01eg
Copy link
Contributor Author

o01eg commented Jan 8, 2019

Could this issue be reopened because the PR was reverted?

@alexcrichton alexcrichton reopened this Jan 8, 2019
@jonas-schievink jonas-schievink added the A-driver Area: rustc_driver that ties everything together into the `rustc` compiler label Jan 26, 2019
@o01eg
Copy link
Contributor Author

o01eg commented Aug 8, 2019

While working on #62497 I think, what if move codegen libraries from sysroot libdir to rustc libdir? I think it is more useful because codegen are libraries rustc loads and links itself.

@Enselic Enselic added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 9, 2023
@Enselic
Copy link
Member

Enselic commented Dec 9, 2023

Triage: Is this still a problem? If yes, can you please provide updated step by step instructions on how to reproduce? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants