File: rmake.rs

package info (click to toggle)
rustc 1.90.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 925,928 kB
  • sloc: xml: 158,148; javascript: 19,781; sh: 19,174; python: 15,732; ansic: 13,096; cpp: 7,181; asm: 4,376; makefile: 697; lisp: 176; sql: 15
file content (45 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
//@ needs-target-std
//
// rust should produce artifact notifications about files it was asked to --emit.
//
// It should work in incremental mode both on the first pass where files are generated as well
// as on subsequent passes where they are taken from the incremental cache
//
// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477>
extern crate run_make_support;

use run_make_support::{cwd, rustc};

fn main() {
    // With single codegen unit files are renamed to match the source file name
    for _ in 0..=1 {
        let output = rustc()
            .input("lib.rs")
            .emit("obj,asm,llvm-ir,llvm-bc,mir")
            .codegen_units(1)
            .json("artifacts")
            .error_format("json")
            .incremental(cwd())
            .run();
        let stderr = output.stderr_utf8();
        for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
        }
    }

    // with multiple codegen units files keep codegen unit id part.
    for _ in 0..=1 {
        let output = rustc()
            .input("lib.rs")
            .emit("obj,asm,llvm-ir,llvm-bc,mir")
            .codegen_units(2)
            .json("artifacts")
            .error_format("json")
            .incremental(cwd())
            .run();
        let stderr = output.stderr_utf8();
        for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
            assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
        }
    }
}