about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-11-09 02:06:22 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-11-09 02:06:22 +0200
commit0da85d62283257516a1dab97f7156a4e0cd96266 (patch)
tree4a96732175e8a8d74e9f94267b4acf62f6e93949 /src
parent9e346646e93cc243567e27bb0f4e8716d56ad1f1 (diff)
downloadrust-0da85d62283257516a1dab97f7156a4e0cd96266.tar.gz
rust-0da85d62283257516a1dab97f7156a4e0cd96266.zip
rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_codegen_ssa/lib.rs3
-rw-r--r--src/librustc_metadata/rmeta/mod.rs9
-rw-r--r--src/test/run-make-fulldeps/invalid-library/Makefile4
3 files changed, 7 insertions, 9 deletions
diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs
index dd75883f97d..81e7ef64e97 100644
--- a/src/librustc_codegen_ssa/lib.rs
+++ b/src/librustc_codegen_ssa/lib.rs
@@ -59,7 +59,8 @@ pub struct ModuleCodegen<M> {
     pub kind: ModuleKind,
 }
 
-pub const METADATA_FILENAME: &str = "rust.metadata.bin";
+// FIXME(eddyb) maybe include the crate name in this?
+pub const METADATA_FILENAME: &str = "lib.rmeta";
 pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
 
 
diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs
index 4eabeac6d98..990a3d984b2 100644
--- a/src/librustc_metadata/rmeta/mod.rs
+++ b/src/librustc_metadata/rmeta/mod.rs
@@ -37,18 +37,15 @@ crate fn rustc_version() -> String {
 /// Metadata encoding version.
 /// N.B., increment this if you change the format of metadata such that
 /// the rustc version can't be found to compare with `rustc_version()`.
-const METADATA_VERSION: u8 = 4;
+const METADATA_VERSION: u8 = 5;
 
 /// Metadata header which includes `METADATA_VERSION`.
-/// To get older versions of rustc to ignore this metadata,
-/// there are 4 zero bytes at the start, which are treated
-/// as a length of 0 by old compilers.
 ///
 /// This header is followed by the position of the `CrateRoot`,
 /// which is encoded as a 32-bit big-endian unsigned integer,
 /// and further followed by the rustc version string.
-crate const METADATA_HEADER: &[u8; 12] =
-    &[0, 0, 0, 0, b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
+crate const METADATA_HEADER: &[u8; 8] =
+    &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
 
 /// Additional metadata for a `Lazy<T>` where `T` may not be `Sized`,
 /// e.g. for `Lazy<[T]>`, this is the length (count of `T` values).
diff --git a/src/test/run-make-fulldeps/invalid-library/Makefile b/src/test/run-make-fulldeps/invalid-library/Makefile
index b6fb122d98b..c75713c3ee5 100644
--- a/src/test/run-make-fulldeps/invalid-library/Makefile
+++ b/src/test/run-make-fulldeps/invalid-library/Makefile
@@ -1,6 +1,6 @@
 -include ../tools.mk
 
 all:
-	touch $(TMPDIR)/rust.metadata.bin
-	$(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin
+	touch $(TMPDIR)/lib.rmeta
+	$(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/lib.rmeta
 	$(RUSTC) foo.rs 2>&1 | $(CGREP) "can't find crate for"