Skip to content

remap-path-prefix appears to be applied in a reverse order #82108

Closed
@nagisa

Description

@nagisa

It appears that if multiple--remap-path-prefix arguments are supplied on the CLI, they will be applied in the reverse order, rather than in the CLI-occurence order.

To reproduce:

$ mkdir -p apple/banana
$ echo 'fn main(){ panic!() }' > apple/banana/chaenomeles.rs
$ rustc apple/banana/chaenomeles.rs --remap-path-prefix=apple/banana/=/first/ --remap-path-prefix=apple/=/second/
$ ./chaenomeles
thread 'main' panicked at 'explicit panic', /second/banana/chaenomeles.rs:1:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Note that only the latter --remap-path-prefix got invoked and the panic path became /second/banana/chaenomeles.rs. Instead users need to specify the order of remappings in reverse:

$ rustc apple/banana/chaenomeles.rs --remap-path-prefix=apple/=/first/ --remap-path-prefix=apple/banana/=/second/
$ ./chaenomeles
thread 'main' panicked at 'explicit panic', /second/chaenomeles.rs:1:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

(in contrast clang/gcc will apply remappings front-to-back)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsD-papercutDiagnostics: An error or lint that needs small tweaks.T-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