File: rmake.rs

package info (click to toggle)
rustc 1.89.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 906,624 kB
  • sloc: xml: 158,148; python: 34,888; javascript: 19,595; sh: 19,221; ansic: 13,046; cpp: 7,144; asm: 4,376; makefile: 692; lisp: 174; sql: 15
file content (36 lines) | stat: -rw-r--r-- 1,888 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//@ needs-target-std
//
// Specifying how rustc outputs a file can be done in different ways, such as
// the output flag or the KIND=NAME syntax. However, some of these methods used
// to result in different hashes on output files even though they yielded the
// exact same result otherwise. This was fixed in #86045, and this test checks
// that the hash is only modified when the output is made different, such as by
// adding a new output type (in this test, metadata).
// See https://github.com/rust-lang/rust/issues/86044

use run_make_support::{diff, rfs, rustc};

fn main() {
    rfs::create_dir("emit");
    rfs::create_dir("emit/a");
    rfs::create_dir("emit/b");
    rfs::create_dir("emit/c");
    // The default output name.
    rustc().emit("link").input("foo.rs").run();
    // The output is named with the output flag.
    rustc().emit("link").output("emit/a/libfoo.rlib").input("foo.rs").run();
    // The output is named with link=NAME.
    rustc().emit("link=emit/b/libfoo.rlib").input("foo.rs").run();
    // The output is named with link=NAME, with an additional kind tacked on.
    rustc().emit("link=emit/c/libfoo.rlib,metadata").input("foo.rs").run();

    let base = rustc().arg("-Zls=root").input("libfoo.rlib").run().stdout_utf8();
    let a = rustc().arg("-Zls=root").input("emit/a/libfoo.rlib").run().stdout_utf8();
    let b = rustc().arg("-Zls=root").input("emit/b/libfoo.rlib").run().stdout_utf8();
    let c = rustc().arg("-Zls=root").input("emit/c/libfoo.rlib").run().stdout_utf8();
    // Both the output flag and link=NAME methods do not modify the hash of the output file.
    diff().expected_text("base", &base).actual_text("a", a).run();
    diff().expected_text("base", &base).actual_text("b", b).run();
    // However, having multiple types of outputs does modify the hash.
    diff().expected_text("base", &base).actual_text("c", c).run_fail();
}