Skip to content

Commit 758c00e

Browse files
committed
Auto merge of rust-lang#85362 - jsgf:fix-emit-metadata, r=estebank
Use command line metadata path if provided If the command-line has `--emit metadata=some/path/libfoo.rmeta` then use that. Closes rust-lang#85356 I couldn't find any existing tests for the `--emit TYPE=PATH` command line syntax, so I wasn't sure how to test this aside from ad-hoc manual testing. Is there a ui test type for "generated output file with expected name"?
2 parents 5957990 + b14b7c6 commit 758c00e

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

compiler/rustc_session/src/output.rs

+5
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ pub fn filename_for_metadata(
127127
crate_name: &str,
128128
outputs: &OutputFilenames,
129129
) -> PathBuf {
130+
// If the command-line specified the path, use that directly.
131+
if let Some(Some(out_filename)) = sess.opts.output_types.get(&OutputType::Metadata) {
132+
return out_filename.clone();
133+
}
134+
130135
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
131136

132137
let out_filename = outputs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-include ../../run-make-fulldeps/tools.mk
2+
3+
OUT=$(TMPDIR)/emit
4+
5+
all: asm llvm-bc llvm-ir obj metadata link dep-info mir
6+
7+
asm: $(OUT)
8+
$(RUSTC) --emit asm=$(OUT)/libfoo.s foo.rs
9+
test -f $(OUT)/libfoo.s
10+
llvm-bc: $(OUT)
11+
$(RUSTC) --emit llvm-bc=$(OUT)/libfoo.bc foo.rs
12+
test -f $(OUT)/libfoo.bc
13+
llvm-ir: $(OUT)
14+
$(RUSTC) --emit llvm-ir=$(OUT)/libfoo.ll foo.rs
15+
test -f $(OUT)/libfoo.ll
16+
obj: $(OUT)
17+
$(RUSTC) --emit obj=$(OUT)/libfoo.o foo.rs
18+
test -f $(OUT)/libfoo.o
19+
metadata: $(OUT)
20+
$(RUSTC) --emit metadata=$(OUT)/libfoo.rmeta foo.rs
21+
test -f $(OUT)/libfoo.rmeta
22+
link: $(OUT)
23+
$(RUSTC) --emit link=$(OUT)/libfoo.rlib foo.rs
24+
test -f $(OUT)/libfoo.rlib
25+
dep-info: $(OUT)
26+
$(RUSTC) --emit dep-info=$(OUT)/libfoo.d foo.rs
27+
test -f $(OUT)/libfoo.d
28+
mir: $(OUT)
29+
$(RUSTC) --emit mir=$(OUT)/libfoo.mir foo.rs
30+
test -f $(OUT)/libfoo.mir
31+
32+
$(OUT):
33+
mkdir -p $(OUT)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#![crate_type = "rlib"]

0 commit comments

Comments
 (0)