diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-02-09 12:14:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-09 12:14:19 -0500 |
| commit | 3eaca413fe44dbd4e59c648a14efa8a2888622b0 (patch) | |
| tree | 71446db7b9fc202e454ff31a307d5f65a5a3295d /src | |
| parent | a05cc5ca9d52b9f88b285433715aa97ed0d66ea8 (diff) | |
| parent | e5396e025ed886c827348aac996c4c6c846fb5ab (diff) | |
| download | rust-3eaca413fe44dbd4e59c648a14efa8a2888622b0.tar.gz rust-3eaca413fe44dbd4e59c648a14efa8a2888622b0.zip | |
Rollup merge of #39619 - michaelwoerister:rename-crate-metadata, r=alexcrichton
Choose different name for metadata obj-file to avoid clashes with user-chosen names. Fixes #39585 and probably https://github.com/rust-lang/rust/issues/39508. Incremental compilation assigns different names to obj-files than regular compilation. If a crate is called "metadata" this can lead to a clash between the root module's obj-file and the obj-file containing crate-metadata. This PR assigns a name to the metadata obj-file that cannot clash with other obj-file because it contains a `.` which is not allowed in a Rust module identifier. r? @alexcrichton cc @nikomatsakis
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/back/link.rs | 11 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 18 | ||||
| -rw-r--r-- | src/librustc_trans/base.rs | 2 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 1cbfa26b705..9d48dc523d3 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -48,6 +48,13 @@ use syntax::attr; use syntax::symbol::Symbol; use syntax_pos::Span; +/// The LLVM module name containing crate-metadata. This includes a `.` on +/// purpose, so it cannot clash with the name of a user-defined module. +pub const METADATA_MODULE_NAME: &'static str = "crate.metadata"; +/// The name of the crate-metadata object file the compiler generates. Must +/// match up with `METADATA_MODULE_NAME`. +pub const METADATA_OBJ_NAME: &'static str = "crate.metadata.o"; + // RLIB LLVM-BYTECODE OBJECT LAYOUT // Version 1 // Bytes Data @@ -213,7 +220,7 @@ pub fn link_binary(sess: &Session, remove(sess, &obj); } } - remove(sess, &outputs.with_extension("metadata.o")); + remove(sess, &outputs.with_extension(METADATA_OBJ_NAME)); } out_filenames @@ -832,7 +839,7 @@ fn link_args(cmd: &mut Linker, // object file, so we link that in here. if crate_type == config::CrateTypeDylib || crate_type == config::CrateTypeProcMacro { - cmd.add_object(&outputs.with_extension("metadata.o")); + cmd.add_object(&outputs.with_extension(METADATA_OBJ_NAME)); } // Try to strip as much out of the generated object by removing unused diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 5c4a5a9a442..b717254ef0d 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -886,12 +886,12 @@ pub fn run_passes(sess: &Session, // Clean up unwanted temporary files. // We create the following files by default: - // - crate.#module-name#.bc - // - crate.#module-name#.o - // - crate.metadata.bc - // - crate.metadata.o - // - crate.o (linked from crate.##.o) - // - crate.bc (copied from crate.##.bc) + // - #crate#.#module-name#.bc + // - #crate#.#module-name#.o + // - #crate#.crate.metadata.bc + // - #crate#.crate.metadata.o + // - #crate#.o (linked from crate.##.o) + // - #crate#.bc (copied from crate.##.bc) // We may create additional files if requested by the user (through // `-C save-temps` or `--emit=` flags). @@ -939,9 +939,9 @@ pub fn run_passes(sess: &Session, } // We leave the following files around by default: - // - crate.o - // - crate.metadata.o - // - crate.bc + // - #crate#.o + // - #crate#.crate.metadata.o + // - #crate#.bc // These are used in linking steps and will be cleaned up afterward. // FIXME: time_llvm_passes support - does this use a global context or diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 5312cc60b09..ce02c9725d1 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1151,7 +1151,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }); let metadata_module = ModuleTranslation { - name: "metadata".to_string(), + name: link::METADATA_MODULE_NAME.to_string(), symbol_name_hash: 0, // we always rebuild metadata, at least for now source: ModuleSource::Translated(ModuleLlvm { llcx: shared_ccx.metadata_llcx(), |
