Skip to content

Clippy built from sources couldn't find codegen directory #3565

@o01eg

Description

@o01eg
Contributor

While looking for other #2874 solutions found another bug. Compiled with rustc clippy correctly finds codegen folder while built from sources doesn't:

$ RUST_LOG=debug rustc src/driver.rs
...
 INFO 2018-12-19T20:37:40Z: rustc_driver: codegen backend candidate: /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends
 INFO 2018-12-19T20:37:40Z: rustc_driver: probing /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends for a codegen backend
...
$ RUST_LOG=debug clippy-driver src/driver.rs
...
 INFO 2018-12-19T20:37:04Z: rustc_driver: codegen backend candidate: /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends
 INFO 2018-12-19T20:37:04Z: rustc_driver: probing /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends for a codegen backend
...
$ RUST_LOG=debug ./target/release/clippy-driver src/driver.rs
...
 INFO 2018-12-19T20:36:27Z: rustc_driver: codegen backend candidate: /tmp/rust-clippy/target/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends
 INFO 2018-12-19T20:36:27Z: rustc_driver: codegen backend candidate: /usr/lib64/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends
...

rustc config.toml:

[llvm]
optimize = true
release-debuginfo = false
assertions = false
targets = "X86;Mips;NVPTX;BPF;AArch64"
[build]
build = "x86_64-unknown-linux-gnu"
host = ["x86_64-unknown-linux-gnu"]
target = ["x86_64-unknown-linux-gnu"]
docs = false
submodules = false
python = "python2.7"
locked-deps = true
vendor = false
verbose = 2
sanitizers = false
extended = true
tools = ["clippy",]
[install]
prefix = "/usr"
libdir = "lib64/rust-9999"
docdir = "share/doc/rust-9999"
mandir = "share/rust-9999/man"
[rust]
optimize = true
debuginfo = false
debug-assertions = true # false
jemalloc = true
default-linker = "x86_64-pc-linux-gnu-gcc"
rpath = false
ignore-git = false
lld = false
llvm-tools = true
[target.x86_64-unknown-linux-gnu]
cc = "x86_64-pc-linux-gnu-gcc"
cxx = "x86_64-pc-linux-gnu-g++"
linker = "x86_64-pc-linux-gnu-gcc"
ar = "x86_64-pc-linux-gnu-ar"

OS: Gentoo Linux AMD64
Clippy from sources rev: 691e5e7
Rustc rev: rust-lang/rust@e7b4bc3

Activity

o01eg

o01eg commented on Dec 20, 2018

@o01eg
ContributorAuthor

When I launch system installed rustc or clippy-driver in the librustc_driver's get_codegen_sysroot happened next:

  1. filesearch::get_or_default_sysroot gets current binary /usr/bin/clippy-driver-9999 and gets sysroot /usr from it.
  2. then it concatenates sysroot with relative libdir from filesearch::relative_target_lib_path lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib and replace last element with codegen-backends
    Correct codegen /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends folder found.

When I launch ./target/release/clippy-driver from /tmp/rust-clippy in won't work:

  1. filesearch::get_or_default_sysroot gets current binary /tmp/rust-clippy/target/release/clippy-driver and gets sysroot /tmp/rust-clippy/target from it.
  2. then it concatenates sysroot with relative libdir from filesearch::relative_target_lib_path lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib and replace last element with codegen-backends
    /tmp/rust-clippy/target/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/codegen-backends isn't correct folder.
    But also it tries /usr/lib64 sysroot which also incorrect.
o01eg

o01eg commented on Dec 20, 2018

@o01eg
ContributorAuthor

Looks like it's a rustc issue: rust-lang/rust#57014

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @o01eg

        Issue actions

          Clippy built from sources couldn't find codegen directory · Issue #3565 · rust-lang/rust-clippy