Skip to content

Commit e5396e0

Browse files
Choose different name for metadata obj-file to avoid clashes with user-chosen names.
1 parent a3da24b commit e5396e0

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/librustc_trans/back/link.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ use syntax::attr;
4848
use syntax::symbol::Symbol;
4949
use syntax_pos::Span;
5050

51+
/// The LLVM module name containing crate-metadata. This includes a `.` on
52+
/// purpose, so it cannot clash with the name of a user-defined module.
53+
pub const METADATA_MODULE_NAME: &'static str = "crate.metadata";
54+
/// The name of the crate-metadata object file the compiler generates. Must
55+
/// match up with `METADATA_MODULE_NAME`.
56+
pub const METADATA_OBJ_NAME: &'static str = "crate.metadata.o";
57+
5158
// RLIB LLVM-BYTECODE OBJECT LAYOUT
5259
// Version 1
5360
// Bytes Data
@@ -213,7 +220,7 @@ pub fn link_binary(sess: &Session,
213220
remove(sess, &obj);
214221
}
215222
}
216-
remove(sess, &outputs.with_extension("metadata.o"));
223+
remove(sess, &outputs.with_extension(METADATA_OBJ_NAME));
217224
}
218225

219226
out_filenames
@@ -832,7 +839,7 @@ fn link_args(cmd: &mut Linker,
832839
// object file, so we link that in here.
833840
if crate_type == config::CrateTypeDylib ||
834841
crate_type == config::CrateTypeProcMacro {
835-
cmd.add_object(&outputs.with_extension("metadata.o"));
842+
cmd.add_object(&outputs.with_extension(METADATA_OBJ_NAME));
836843
}
837844

838845
// Try to strip as much out of the generated object by removing unused

src/librustc_trans/back/write.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -866,12 +866,12 @@ pub fn run_passes(sess: &Session,
866866
// Clean up unwanted temporary files.
867867

868868
// We create the following files by default:
869-
// - crate.#module-name#.bc
870-
// - crate.#module-name#.o
871-
// - crate.metadata.bc
872-
// - crate.metadata.o
873-
// - crate.o (linked from crate.##.o)
874-
// - crate.bc (copied from crate.##.bc)
869+
// - #crate#.#module-name#.bc
870+
// - #crate#.#module-name#.o
871+
// - #crate#.crate.metadata.bc
872+
// - #crate#.crate.metadata.o
873+
// - #crate#.o (linked from crate.##.o)
874+
// - #crate#.bc (copied from crate.##.bc)
875875
// We may create additional files if requested by the user (through
876876
// `-C save-temps` or `--emit=` flags).
877877

@@ -919,9 +919,9 @@ pub fn run_passes(sess: &Session,
919919
}
920920

921921
// We leave the following files around by default:
922-
// - crate.o
923-
// - crate.metadata.o
924-
// - crate.bc
922+
// - #crate#.o
923+
// - #crate#.crate.metadata.o
924+
// - #crate#.bc
925925
// These are used in linking steps and will be cleaned up afterward.
926926

927927
// FIXME: time_llvm_passes support - does this use a global context or

src/librustc_trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11461146
});
11471147

11481148
let metadata_module = ModuleTranslation {
1149-
name: "metadata".to_string(),
1149+
name: link::METADATA_MODULE_NAME.to_string(),
11501150
symbol_name_hash: 0, // we always rebuild metadata, at least for now
11511151
source: ModuleSource::Translated(ModuleLlvm {
11521152
llcx: shared_ccx.metadata_llcx(),

0 commit comments

Comments
 (0)