| 
 | 1 | +// A SourceFile created during compilation may have a relative  | 
 | 2 | +// path (e.g. if rustc itself is invoked with a relative path).  | 
 | 3 | +// When we write out crate metadata, we convert all relative paths  | 
 | 4 | +// to absolute paths using the current working directory.  | 
 | 5 | +// However, the working directory was previously not included in the crate hash.  | 
 | 6 | +// This meant that the crate metadata could change while the crate  | 
 | 7 | +// hash remained the same. Among other problems, this could cause a  | 
 | 8 | +// fingerprint mismatch ICE, since incremental compilation uses  | 
 | 9 | +// the crate metadata hash to determine if a foreign query is green.  | 
 | 10 | +// This test checks that we don't get an ICE when the working directory  | 
 | 11 | +// (but not the build directory!) changes between compilation  | 
 | 12 | +// sessions.  | 
 | 13 | +// See https://github.com/rust-lang/rust/issues/85019  | 
 | 14 | + | 
 | 15 | +//@ ignore-none  | 
 | 16 | +// Reason: no-std is not supported  | 
 | 17 | +//@ ignore-nvptx64-nvidia-cuda  | 
 | 18 | +// FIXME: can't find crate for 'std'  | 
 | 19 | + | 
 | 20 | +use run_make_support::{fs_wrapper, rust_lib_name, rustc};  | 
 | 21 | + | 
 | 22 | +fn main() {  | 
 | 23 | +    fs_wrapper::create_dir("incr");  | 
 | 24 | +    fs_wrapper::create_dir("first_src");  | 
 | 25 | +    fs_wrapper::create_dir("output");  | 
 | 26 | +    fs_wrapper::rename("my_lib.rs", "first_src/my_lib.rs");  | 
 | 27 | +    fs_wrapper::rename("main.rs", "first_src/main.rs");  | 
 | 28 | +    // Build from "first_src"  | 
 | 29 | +    std::env::set_current_dir("first_src").unwrap();  | 
 | 30 | +    rustc().input("my_lib.rs").incremental("incr").crate_type("lib").run();  | 
 | 31 | +    rustc().input("main.rs").incremental("incr").extern_("my_lib", rust_lib_name("my_lib")).run();  | 
 | 32 | +    std::env::set_current_dir("..").unwrap();  | 
 | 33 | +    fs_wrapper::rename("first_src", "second_src");  | 
 | 34 | +    std::env::set_current_dir("second_src").unwrap();  | 
 | 35 | +    // Build from "second_src" - the output and incremental directory remain identical  | 
 | 36 | +    rustc().input("my_lib.rs").incremental("incr").crate_type("lib").run();  | 
 | 37 | +    rustc().input("main.rs").incremental("incr").extern_("my_lib", rust_lib_name("my_lib")).run();  | 
 | 38 | +}  | 
0 commit comments