Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose different name for metadata obj-file to avoid clashes with user-chosen names. #39619

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,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).

Expand Down Expand Up @@ -919,9 +919,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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,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(),
Expand Down