From 2835351feb1718892459b324c67680163a9569c9 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Sun, 16 May 2021 02:06:00 -0700 Subject: [PATCH 1/2] Use command line metadata path if provided If the command-line has `--emit metadata=some/path/libfoo.rmeta` then use that. Closes #85356 --- compiler/rustc_session/src/output.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index 777eea3f68d0..cc1e4bb198a3 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -127,6 +127,11 @@ pub fn filename_for_metadata( crate_name: &str, outputs: &OutputFilenames, ) -> PathBuf { + // If the command-line specified the path, use that directly. + if let Some(Some(out_filename)) = sess.opts.output_types.get(&OutputType::Metadata) { + return out_filename.clone(); + } + let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename); let out_filename = outputs From b14b7c6085a7bc4cbf6614ebe98a62847884e5a5 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Fri, 28 May 2021 22:47:58 -0700 Subject: [PATCH 2/2] Add test for --emit TYPE=path --- src/test/run-make/emit-named-files/Makefile | 33 +++++++++++++++++++++ src/test/run-make/emit-named-files/foo.rs | 1 + 2 files changed, 34 insertions(+) create mode 100644 src/test/run-make/emit-named-files/Makefile create mode 100644 src/test/run-make/emit-named-files/foo.rs diff --git a/src/test/run-make/emit-named-files/Makefile b/src/test/run-make/emit-named-files/Makefile new file mode 100644 index 000000000000..03eb83b97e38 --- /dev/null +++ b/src/test/run-make/emit-named-files/Makefile @@ -0,0 +1,33 @@ +-include ../../run-make-fulldeps/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) diff --git a/src/test/run-make/emit-named-files/foo.rs b/src/test/run-make/emit-named-files/foo.rs new file mode 100644 index 000000000000..c1bfaa6cab5d --- /dev/null +++ b/src/test/run-make/emit-named-files/foo.rs @@ -0,0 +1 @@ +#![crate_type = "rlib"]