Rollup merge of #125849 - GuillaumeGomez:migrate-emit-named-files, r=jieyouxu

Migrate `run-make/emit-named-files` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
This commit is contained in:
Jubilee 2024-06-02 05:06:47 -07:00 committed by GitHub
commit 0722c9439e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 34 deletions

View File

@ -37,7 +37,6 @@ run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/duplicate-output-flavors/Makefile
run-make/dylib-chain/Makefile
run-make/emit-named-files/Makefile
run-make/emit-path-unhashed/Makefile
run-make/emit-shared-files/Makefile
run-make/emit-stack-sizes/Makefile

View File

@ -1,33 +0,0 @@
include ../tools.mk
OUT=$(TMPDIR)/emit
all: asm llvm-bc llvm-ir obj metadata link dep-info mir
asm: $(OUT)
$(RUSTC) --emit asm=$(OUT)/libfoo.s foo.rs
test -f $(OUT)/libfoo.s
llvm-bc: $(OUT)
$(RUSTC) --emit llvm-bc=$(OUT)/libfoo.bc foo.rs
test -f $(OUT)/libfoo.bc
llvm-ir: $(OUT)
$(RUSTC) --emit llvm-ir=$(OUT)/libfoo.ll foo.rs
test -f $(OUT)/libfoo.ll
obj: $(OUT)
$(RUSTC) --emit obj=$(OUT)/libfoo.o foo.rs
test -f $(OUT)/libfoo.o
metadata: $(OUT)
$(RUSTC) --emit metadata=$(OUT)/libfoo.rmeta foo.rs
test -f $(OUT)/libfoo.rmeta
link: $(OUT)
$(RUSTC) --emit link=$(OUT)/libfoo.rlib foo.rs
test -f $(OUT)/libfoo.rlib
dep-info: $(OUT)
$(RUSTC) --emit dep-info=$(OUT)/libfoo.d foo.rs
test -f $(OUT)/libfoo.d
mir: $(OUT)
$(RUSTC) --emit mir=$(OUT)/libfoo.mir foo.rs
test -f $(OUT)/libfoo.mir
$(OUT):
mkdir -p $(OUT)

View File

@ -0,0 +1,25 @@
use std::fs::create_dir;
use std::path::Path;
use run_make_support::{rustc, tmp_dir};
fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) {
let out_file = out_dir.join(out_file);
rustc().input("foo.rs").emit(&format!("{format}={}", out_file.display())).run();
assert!(out_file.is_file());
}
fn main() {
let out_dir = tmp_dir().join("emit");
create_dir(&out_dir).unwrap();
emit_and_check(&out_dir, "libfoo.s", "asm");
emit_and_check(&out_dir, "libfoo.bc", "llvm-bc");
emit_and_check(&out_dir, "libfoo.ll", "llvm-ir");
emit_and_check(&out_dir, "libfoo.o", "obj");
emit_and_check(&out_dir, "libfoo.rmeta", "metadata");
emit_and_check(&out_dir, "libfoo.rlib", "link");
emit_and_check(&out_dir, "libfoo.d", "dep-info");
emit_and_check(&out_dir, "libfoo.mir", "mir");
}