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

Add --emit metadata #37411

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 18 additions & 13 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,7 @@ pub enum OutputType {
Object,
Exe,
DepInfo,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ErrorOutputType {
HumanReadable(ColorConfig),
Json,
}

impl Default for ErrorOutputType {
fn default() -> ErrorOutputType {
ErrorOutputType::HumanReadable(ColorConfig::Auto)
}
Metadata
}

impl OutputType {
Expand All @@ -98,7 +87,8 @@ impl OutputType {
OutputType::Bitcode |
OutputType::Assembly |
OutputType::LlvmAssembly |
OutputType::Object => false,
OutputType::Object |
OutputType::Metadata => false,
}
}

Expand All @@ -110,6 +100,7 @@ impl OutputType {
OutputType::Object => "obj",
OutputType::Exe => "link",
OutputType::DepInfo => "dep-info",
OutputType::Metadata => "metadata",
}
}

Expand All @@ -121,10 +112,23 @@ impl OutputType {
OutputType::Object => "o",
OutputType::DepInfo => "d",
OutputType::Exe => "",
OutputType::Metadata => "",
}
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ErrorOutputType {
HumanReadable(ColorConfig),
Json,
}

impl Default for ErrorOutputType {
fn default() -> ErrorOutputType {
ErrorOutputType::HumanReadable(ColorConfig::Auto)
}
}

// Use tree-based collections to cheaply get a deterministic Hash implementation.
// DO NOT switch BTreeMap out for an unsorted container type! That would break
// dependency tracking for commandline arguments.
Expand Down Expand Up @@ -1329,6 +1333,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
"obj" => OutputType::Object,
"link" => OutputType::Exe,
"dep-info" => OutputType::DepInfo,
"metadata" => OutputType::Metadata,
part => {
early_error(error_format, &format!("unknown emission type: `{}`",
part))
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ pub fn link_binary(sess: &Session,
let mut out_filenames = Vec::new();
for &crate_type in sess.crate_types.borrow().iter() {
// Ignore executable crates if we have -Z no-trans, as they will error.
if sess.opts.debugging_opts.no_trans &&
if (sess.opts.debugging_opts.no_trans ||
sess.opts.output_types.keys().all(|k| k == &OutputType::Metadata)) &&
crate_type == config::CrateTypeExecutable {
continue;
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ pub fn run_passes(sess: &Session,
modules_config.emit_obj = true;
metadata_config.emit_obj = true;
},
OutputType::DepInfo => {}
OutputType::DepInfo | OutputType::Metadata => {}
}
}

Expand Down Expand Up @@ -845,7 +845,8 @@ pub fn run_passes(sess: &Session,
copy_if_one_unit(OutputType::Object, true);
}
OutputType::Exe |
OutputType::DepInfo => {}
OutputType::DepInfo |
OutputType::Metadata => {}
}
}
let user_wants_bitcode = user_wants_bitcode;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use rustc::dep_graph::{DepNode, WorkProduct};
use rustc::hir::map as hir_map;
use rustc::util::common::time;
use rustc::mir::mir_map::MirMap;
use session::config::{self, NoDebugInfo};
use session::config::{self, NoDebugInfo, OutputType};
use rustc_incremental::IncrementalHashesMap;
use session::Session;
use abi::{self, Abi, FnType};
Expand Down Expand Up @@ -1607,7 +1607,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
assert_module_sources::assert_module_sources(tcx, &modules);

// Skip crate items and just output metadata in -Z no-trans mode.
if tcx.sess.opts.debugging_opts.no_trans {
if tcx.sess.opts.debugging_opts.no_trans ||
tcx.sess.opts.output_types.keys().all(|k| k == &OutputType::Metadata) {
let linker_info = LinkerInfo::new(&shared_ccx, &[]);
return CrateTranslation {
modules: modules,
Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ actual:\n\

// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!("-".to_owned(),
"-Zno-trans".to_owned(),
"--emit".to_owned(),
"metadata".to_owned(),
"--out-dir".to_owned(),
out_dir.to_str().unwrap().to_owned(),
format!("--target={}", target),
Expand Down