Skip to content

rustc doesn't handle relative symlinks to libraries #13890

Closed
@yuriks

Description

@yuriks

When rustc searches for libraries and encounters a symlink, instead of directly opening the link, it uses readlink and then uses the resulting path relative to cwd instead of relative to the link, causing it to fail to find the file.

The problem can be seen in the following excerpt from the output of strace on rustc:

...
[pid  2359] openat(AT_FDCWD, "/home/yuriks/projects/distrocast/.rust/lib/x86_64-unknown-linux-gnu", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
[pid  2359] getdents(3, /* 3 entries */, 32768) = 104
[pid  2359] getdents(3, /* 0 entries */, 32768) = 0
[pid  2359] close(3)                    = 0
[pid  2359] readlink("/home/yuriks/projects/distrocast/.rust/lib/x86_64-unknown-linux-gnu/librust-crypto-c53dba27-0.1.rlib", "../../../rust-crypto/librust-cry"..., 4096) = 53
[pid  2359] stat("../../../rust-crypto/librust-crypto-c53dba27-0.1.rlib", 0x7fd1ba017980) = -1 ENOENT (No such file or directory)
[pid  2359] write(2, "client.rs:5:1: 5:37 error: can't"..., 57client.rs:5:1: 5:37 error: can't find crate for `crypto`
...

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

    Issue actions