|
| 1 | +// Specifying how rustc outputs a file can be done in different ways, such as |
| 2 | +// the output flag or the KIND=NAME syntax. However, some of these methods used |
| 3 | +// to result in different hashes on output files even though they yielded the |
| 4 | +// exact same result otherwise. This was fixed in #86045, and this test checks |
| 5 | +// that the hash is only modified when the output is made different, such as by |
| 6 | +// adding a new output type (in this test, metadata). |
| 7 | +// See https://github.com/rust-lang/rust/issues/86044 |
| 8 | + |
| 9 | +use run_make_support::{diff, fs_wrapper, rustc}; |
| 10 | + |
| 11 | +fn main() { |
| 12 | + fs_wrapper::create_dir("emit"); |
| 13 | + fs_wrapper::create_dir("emit/a"); |
| 14 | + fs_wrapper::create_dir("emit/b"); |
| 15 | + fs_wrapper::create_dir("emit/c"); |
| 16 | + // The default output name. |
| 17 | + rustc().emit("link").input("foo.rs").run(); |
| 18 | + // The output is named with the output flag. |
| 19 | + rustc().emit("link").output("emit/a/libfoo.rlib").input("foo.rs").run(); |
| 20 | + // The output is named with link=NAME. |
| 21 | + rustc().emit("link=emit/b/libfoo.rlib").input("foo.rs").run(); |
| 22 | + // The output is named with link=NAME, with an additional kind tacked on. |
| 23 | + rustc().emit("link=emit/c/libfoo.rlib,metadata").input("foo.rs").run(); |
| 24 | + |
| 25 | + let base = rustc().arg("-Zls=root").input("libfoo.rlib").run().stdout_utf8(); |
| 26 | + let a = rustc().arg("-Zls=root").input("emit/a/libfoo.rlib").run().stdout_utf8(); |
| 27 | + let b = rustc().arg("-Zls=root").input("emit/b/libfoo.rlib").run().stdout_utf8(); |
| 28 | + let c = rustc().arg("-Zls=root").input("emit/c/libfoo.rlib").run().stdout_utf8(); |
| 29 | + // Both the output flag and link=NAME methods do not modify the hash of the output file. |
| 30 | + diff().expected_text("base", &base).actual_text("a", a).run(); |
| 31 | + diff().expected_text("base", &base).actual_text("b", b).run(); |
| 32 | + // However, having multiple types of outputs does modify the hash. |
| 33 | + diff().expected_text("base", &base).actual_text("c", c).run_fail(); |
| 34 | +} |
0 commit comments