1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 use driver::session::Session;
17 use llvm::{ContextRef, ModuleRef};
18 use metadata::common::LinkMeta;
19 use metadata::creader;
20 use middle::{trans, stability, kind, ty, typeck, reachable};
21 use middle::dependency_format;
23 use plugin::load::Plugins;
24 use plugin::registry::Registry;
27 use util::common::time;
28 use util::nodemap::{NodeSet};
30 use serialize::{json, Encodable};
35 use arena::TypedArena;
39 use syntax::attr::{AttrMetaMethods};
40 use syntax::diagnostics;
42 use syntax::parse::token;
45 pub fn host_triple() -> &'static str {
46 // Get the host triple out of the build environment. This ensures that our
47 // idea of the host triple is the same as for the set of libraries we've
48 // actually built. We can't just take LLVM's host triple because they
49 // normalize all ix86 architectures to i386.
51 // Instead of grabbing the host triple (for the current host), we grab (at
52 // compile time) the target triple that this rustc is built with and
53 // calling that (at runtime) the host triple.
54 (option_env!("CFG_COMPILER_HOST_TRIPLE")).
55 expect("CFG_COMPILER_HOST_TRIPLE")
58 pub fn compile_input(sess: Session,
59 cfg: ast::CrateConfig,
61 outdir: &Option<Path>,
62 output: &Option<Path>,
63 addl_plugins: Option<Plugins>) {
64 // We need nested scopes here, because the intermediate results can keep
65 // large chunks of memory alive and we want to free them as soon as
66 // possible to keep the peak memory usage low
67 let (outputs, trans, sess) = {
68 let (outputs, expanded_crate, id) = {
69 let krate = phase_1_parse_input(&sess, cfg, input);
70 if stop_after_phase_1(&sess) { return; }
71 let outputs = build_output_filenames(input,
74 krate.attrs.as_slice(),
76 let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(),
79 = match phase_2_configure_and_expand(&sess, krate, id.as_slice(),
85 (outputs, expanded_crate, id)
88 let mut forest = ast_map::Forest::new(expanded_crate);
89 let ast_map = assign_node_ids_and_map(&sess, &mut forest);
91 write_out_deps(&sess, input, &outputs, id.as_slice());
93 if stop_after_phase_2(&sess) { return; }
95 let type_arena = TypedArena::new();
96 let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, id);
97 phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir);
98 if stop_after_phase_3(&analysis.ty_cx.sess) { return; }
99 let (tcx, trans) = phase_4_translate_to_llvm(analysis);
101 // Discard interned strings as they are no longer required.
102 token::get_ident_interner().clear();
104 (outputs, trans, tcx.sess)
106 phase_5_run_llvm_passes(&sess, &trans, &outputs);
107 if stop_after_phase_5(&sess) { return; }
108 phase_6_link_output(&sess, &trans, &outputs);
112 * The name used for source code that doesn't originate in a file
113 * (e.g. source from stdin or a string)
115 pub fn anon_src() -> String {
119 pub fn source_name(input: &Input) -> String {
121 // FIXME (#9639): This needs to handle non-utf8 paths
122 FileInput(ref ifile) => ifile.as_str().unwrap().to_string(),
123 StrInput(_) => anon_src()
128 /// Load source from file
130 /// The string is the source
135 fn filestem(&self) -> String {
137 FileInput(ref ifile) => ifile.filestem_str().unwrap().to_string(),
138 StrInput(_) => "rust_out".to_string(),
144 pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
146 let krate = time(sess.time_passes(), "parsing", (), |_| {
148 FileInput(ref file) => {
149 parse::parse_crate_from_file(&(*file), cfg.clone(), &sess.parse_sess)
151 StrInput(ref src) => {
152 parse::parse_crate_from_source_str(anon_src().to_string(),
160 if sess.opts.debugging_opts & config::AST_JSON_NOEXPAND != 0 {
161 let mut stdout = io::BufferedWriter::new(io::stdout());
162 let mut json = json::PrettyEncoder::new(&mut stdout);
163 // unwrapping so IoError isn't ignored
164 krate.encode(&mut json).unwrap();
167 if sess.show_span() {
168 syntax::show_span::run(sess.diagnostic(), &krate);
174 // For continuing compilation after a parsed crate has been
177 /// Run the "early phases" of the compiler: initial `cfg` processing,
178 /// loading compiler plugins (including those from `addl_plugins`),
179 /// syntax expansion, secondary `cfg` expansion, synthesis of a test
180 /// harness if one is to be provided and injection of a dependency on the
181 /// standard library and prelude.
183 /// Returns `None` if we're aborting after handling -W help.
184 pub fn phase_2_configure_and_expand(sess: &Session,
185 mut krate: ast::Crate,
187 addl_plugins: Option<Plugins>)
188 -> Option<ast::Crate> {
189 let time_passes = sess.time_passes();
191 *sess.crate_types.borrow_mut() =
192 collect_crate_types(sess, krate.attrs.as_slice());
193 *sess.crate_metadata.borrow_mut() =
194 collect_crate_metadata(sess, krate.attrs.as_slice());
196 time(time_passes, "gated feature checking", (), |_| {
197 let (features, unknown_features) =
198 syntax::feature_gate::check_crate(&sess.parse_sess.span_diagnostic, &krate);
200 for uf in unknown_features.iter() {
201 sess.add_lint(lint::builtin::UNKNOWN_FEATURES,
204 "unknown feature".to_string());
207 sess.abort_if_errors();
208 *sess.features.borrow_mut() = features;
211 let any_exe = sess.crate_types.borrow().iter().any(|ty| {
212 *ty == config::CrateTypeExecutable
215 krate = time(time_passes, "crate injection", krate, |krate|
216 syntax::std_inject::maybe_inject_crates_ref(krate,
217 sess.opts.alt_std_name.clone(),
220 // strip before expansion to allow macros to depend on
221 // configuration variables e.g/ in
223 // #[macro_escape] #[cfg(foo)]
224 // mod bar { macro_rules! baz!(() => {{}}) }
226 // baz! should not use this definition unless foo is enabled.
228 krate = time(time_passes, "configuration 1", krate, |krate|
229 syntax::config::strip_unconfigured_items(krate));
231 let mut addl_plugins = Some(addl_plugins);
232 let Plugins { macros, registrars }
233 = time(time_passes, "plugin loading", (), |_|
234 plugin::load::load_plugins(sess, &krate, addl_plugins.take().unwrap()));
236 let mut registry = Registry::new(&krate);
238 time(time_passes, "plugin registration", (), |_| {
239 if sess.features.borrow().rustc_diagnostic_macros {
240 registry.register_macro("__diagnostic_used",
241 diagnostics::plugin::expand_diagnostic_used);
242 registry.register_macro("__register_diagnostic",
243 diagnostics::plugin::expand_register_diagnostic);
244 registry.register_macro("__build_diagnostic_array",
245 diagnostics::plugin::expand_build_diagnostic_array);
248 for ®istrar in registrars.iter() {
249 registrar(&mut registry);
253 let Registry { syntax_exts, lint_passes, lint_groups, .. } = registry;
256 let mut ls = sess.lint_store.borrow_mut();
257 for pass in lint_passes.into_iter() {
258 ls.register_pass(Some(sess), true, pass);
261 for (name, to) in lint_groups.into_iter() {
262 ls.register_group(Some(sess), true, name, to);
266 // Lint plugins are registered; now we can process command line flags.
267 if sess.opts.describe_lints {
268 super::describe_lints(&*sess.lint_store.borrow(), true);
271 sess.lint_store.borrow_mut().process_command_line(sess);
273 // Abort if there are errors from lint processing or a plugin registrar.
274 sess.abort_if_errors();
276 krate = time(time_passes, "expansion", (krate, macros, syntax_exts),
277 |(krate, macros, syntax_exts)| {
278 // Windows dlls do not have rpaths, so they don't know how to find their
279 // dependencies. It's up to us to tell the system where to find all the
280 // dependent dlls. Note that this uses cfg!(windows) as opposed to
281 // targ_cfg because syntax extensions are always loaded for the host
282 // compiler, not for the target.
283 let mut _old_path = String::new();
285 _old_path = os::getenv("PATH").unwrap_or(_old_path);
286 let mut new_path = sess.host_filesearch().get_dylib_search_paths();
287 new_path.push_all_move(os::split_paths(_old_path.as_slice()));
288 os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());
290 let cfg = syntax::ext::expand::ExpansionConfig {
291 deriving_hash_type_parameter: sess.features.borrow().default_type_params,
292 crate_name: crate_name.to_string(),
294 let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
300 os::setenv("PATH", _old_path);
306 // JBC: make CFG processing part of expansion to avoid this problem:
308 // strip again, in case expansion added anything with a #[cfg].
309 krate = time(time_passes, "configuration 2", krate, |krate|
310 syntax::config::strip_unconfigured_items(krate));
312 krate = time(time_passes, "maybe building test harness", krate, |krate|
313 syntax::test::modify_for_testing(&sess.parse_sess,
318 krate = time(time_passes, "prelude injection", krate, |krate|
319 syntax::std_inject::maybe_inject_prelude(krate));
321 time(time_passes, "checking that all macro invocations are gone", &krate, |krate|
322 syntax::ext::expand::check_for_macros(&sess.parse_sess, krate));
327 pub fn assign_node_ids_and_map<'ast>(sess: &Session,
328 forest: &'ast mut ast_map::Forest)
329 -> ast_map::Map<'ast> {
330 struct NodeIdAssigner<'a> {
334 impl<'a> ast_map::FoldOps for NodeIdAssigner<'a> {
335 fn new_id(&self, old_id: ast::NodeId) -> ast::NodeId {
336 assert_eq!(old_id, ast::DUMMY_NODE_ID);
337 self.sess.next_node_id()
341 let map = time(sess.time_passes(), "assigning node ids and indexing ast", forest, |forest|
342 ast_map::map_crate(forest, NodeIdAssigner { sess: sess }));
344 if sess.opts.debugging_opts & config::AST_JSON != 0 {
345 let mut stdout = io::BufferedWriter::new(io::stdout());
346 let mut json = json::PrettyEncoder::new(&mut stdout);
347 // unwrapping so IoError isn't ignored
348 map.krate().encode(&mut json).unwrap();
354 pub struct CrateAnalysis<'tcx> {
355 pub exp_map2: middle::resolve::ExportMap2,
356 pub exported_items: middle::privacy::ExportedItems,
357 pub public_items: middle::privacy::PublicItems,
358 pub ty_cx: ty::ctxt<'tcx>,
359 pub reachable: NodeSet,
364 /// Run the resolution, typechecking, region checking and other
365 /// miscellaneous analysis passes on the crate. Return various
366 /// structures carrying the results of the analysis.
367 pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
368 ast_map: ast_map::Map<'tcx>,
369 type_arena: &'tcx TypedArena<ty::t_box_>,
370 name: String) -> CrateAnalysis<'tcx> {
371 let time_passes = sess.time_passes();
372 let krate = ast_map.krate();
374 time(time_passes, "external crate/lib resolution", (), |_|
375 creader::read_crates(&sess, krate));
377 let lang_items = time(time_passes, "language item collection", (), |_|
378 middle::lang_items::collect_language_items(krate, &sess));
380 let middle::resolve::CrateMap {
389 time(time_passes, "resolution", (), |_|
390 middle::resolve::resolve_crate(&sess, &lang_items, krate));
392 // Discard MTWT tables that aren't required past resolution.
393 syntax::ext::mtwt::clear_tables();
395 let named_region_map = time(time_passes, "lifetime resolution", (),
396 |_| middle::resolve_lifetime::krate(&sess, krate));
398 time(time_passes, "looking for entry point", (),
399 |_| middle::entry::find_entry_point(&sess, &ast_map));
401 sess.plugin_registrar_fn.set(
402 time(time_passes, "looking for plugin registrar", (), |_|
403 plugin::build::find_plugin_registrar(
404 sess.diagnostic(), krate)));
406 let region_map = time(time_passes, "region resolution", (), |_|
407 middle::region::resolve_crate(&sess, krate));
409 time(time_passes, "loop checking", (), |_|
410 middle::check_loop::check_crate(&sess, krate));
412 let stability_index = time(time_passes, "stability index", (), |_|
413 stability::Index::build(krate));
415 time(time_passes, "static item recursion checking", (), |_|
416 middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
418 let ty_cx = ty::mk_ctxt(sess,
429 // passes are timed inside typeck
430 typeck::check_crate(&ty_cx, trait_map);
432 time(time_passes, "check static items", (), |_|
433 middle::check_static::check_crate(&ty_cx));
435 // These next two const passes can probably be merged
436 time(time_passes, "const marking", (), |_|
437 middle::const_eval::process_crate(&ty_cx));
439 time(time_passes, "const checking", (), |_|
440 middle::check_const::check_crate(&ty_cx));
442 let maps = (external_exports, last_private_map);
443 let (exported_items, public_items) =
444 time(time_passes, "privacy checking", maps, |(a, b)|
445 middle::privacy::check_crate(&ty_cx, &exp_map2, a, b));
447 time(time_passes, "intrinsic checking", (), |_|
448 middle::intrinsicck::check_crate(&ty_cx));
450 time(time_passes, "effect checking", (), |_|
451 middle::effect::check_crate(&ty_cx));
453 time(time_passes, "match checking", (), |_|
454 middle::check_match::check_crate(&ty_cx));
456 time(time_passes, "liveness checking", (), |_|
457 middle::liveness::check_crate(&ty_cx));
459 time(time_passes, "borrow checking", (), |_|
460 middle::borrowck::check_crate(&ty_cx));
462 time(time_passes, "rvalue checking", (), |_|
463 middle::check_rvalues::check_crate(&ty_cx, krate));
465 time(time_passes, "kind checking", (), |_|
466 kind::check_crate(&ty_cx));
469 time(time_passes, "reachability checking", (), |_|
470 reachable::find_reachable(&ty_cx, &exported_items));
472 time(time_passes, "death checking", (), |_| {
473 middle::dead::check_crate(&ty_cx,
478 time(time_passes, "lint checking", (), |_|
479 lint::check_crate(&ty_cx, &exported_items));
484 exported_items: exported_items,
485 public_items: public_items,
486 reachable: reachable_map,
491 pub fn phase_save_analysis(sess: &Session,
493 analysis: &CrateAnalysis,
494 odir: &Option<Path>) {
495 if (sess.opts.debugging_opts & config::SAVE_ANALYSIS) == 0 {
498 time(sess.time_passes(), "save analysis", krate, |krate|
499 middle::save::process_crate(sess, krate, analysis, odir));
502 pub struct ModuleTranslation {
503 pub llcx: ContextRef,
504 pub llmod: ModuleRef,
507 pub struct CrateTranslation {
508 pub modules: Vec<ModuleTranslation>,
509 pub metadata_module: ModuleTranslation,
511 pub metadata: Vec<u8>,
512 pub reachable: Vec<String>,
513 pub crate_formats: dependency_format::Dependencies,
514 pub no_builtins: bool,
517 /// Run the translation phase to LLVM, after which the AST and analysis can
519 pub fn phase_4_translate_to_llvm<'tcx>(analysis: CrateAnalysis<'tcx>)
520 -> (ty::ctxt<'tcx>, CrateTranslation) {
521 let time_passes = analysis.ty_cx.sess.time_passes();
523 time(time_passes, "resolving dependency formats", (), |_|
524 dependency_format::calculate(&analysis.ty_cx));
526 // Option dance to work around the lack of stack once closures.
527 time(time_passes, "translation", analysis, |analysis|
528 trans::base::trans_crate(analysis))
531 /// Run LLVM itself, producing a bitcode file, assembly file or object file
532 /// as a side effect.
533 pub fn phase_5_run_llvm_passes(sess: &Session,
534 trans: &CrateTranslation,
535 outputs: &OutputFilenames) {
536 if sess.opts.cg.no_integrated_as {
537 let output_type = write::OutputTypeAssembly;
539 time(sess.time_passes(), "LLVM passes", (), |_|
540 write::run_passes(sess, trans, [output_type], outputs));
542 write::run_assembler(sess, outputs);
544 // Remove assembly source, unless --save-temps was specified
545 if !sess.opts.cg.save_temps {
546 fs::unlink(&outputs.temp_path(write::OutputTypeAssembly)).unwrap();
549 time(sess.time_passes(), "LLVM passes", (), |_|
550 write::run_passes(sess,
552 sess.opts.output_types.as_slice(),
557 /// Run the linker on any artifacts that resulted from the LLVM run.
558 /// This should produce either a finished executable or library.
559 pub fn phase_6_link_output(sess: &Session,
560 trans: &CrateTranslation,
561 outputs: &OutputFilenames) {
562 let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
563 let mut new_path = os::split_paths(old_path.as_slice());
564 new_path.push_all_move(sess.host_filesearch().get_tools_search_paths());
565 os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());
567 time(sess.time_passes(), "linking", (), |_|
568 link::link_binary(sess,
571 trans.link.crate_name.as_slice()));
573 os::setenv("PATH", old_path);
576 pub fn stop_after_phase_3(sess: &Session) -> bool {
577 if sess.opts.no_trans {
578 debug!("invoked with --no-trans, returning early from compile_input");
584 pub fn stop_after_phase_1(sess: &Session) -> bool {
585 if sess.opts.parse_only {
586 debug!("invoked with --parse-only, returning early from compile_input");
589 if sess.show_span() {
592 return sess.opts.debugging_opts & config::AST_JSON_NOEXPAND != 0;
595 pub fn stop_after_phase_2(sess: &Session) -> bool {
596 if sess.opts.no_analysis {
597 debug!("invoked with --no-analysis, returning early from compile_input");
600 return sess.opts.debugging_opts & config::AST_JSON != 0;
603 pub fn stop_after_phase_5(sess: &Session) -> bool {
604 if !sess.opts.output_types.iter().any(|&i| i == write::OutputTypeExe) {
605 debug!("not building executable, returning early from compile_input");
611 fn write_out_deps(sess: &Session,
613 outputs: &OutputFilenames,
616 let mut out_filenames = Vec::new();
617 for output_type in sess.opts.output_types.iter() {
618 let file = outputs.path(*output_type);
620 write::OutputTypeExe => {
621 for output in sess.crate_types.borrow().iter() {
622 let p = link::filename_for_input(sess, *output,
624 out_filenames.push(p);
627 _ => { out_filenames.push(file); }
631 // Write out dependency rules to the dep-info file if requested with
633 let deps_filename = match sess.opts.write_dependency_info {
634 // Use filename from --dep-file argument if given
635 (true, Some(ref filename)) => filename.clone(),
636 // Use default filename: crate source filename with extension replaced
638 (true, None) => match *input {
639 FileInput(..) => outputs.with_extension("d"),
641 sess.warn("can not write --dep-info without a filename \
642 when compiling stdin.");
650 // Build a list of files used to compile the output and
651 // write Makefile-compatible dependency rules
652 let files: Vec<String> = sess.codemap().files.borrow()
653 .iter().filter(|fmap| fmap.is_real_file())
654 .map(|fmap| fmap.name.to_string())
656 let mut file = try!(io::File::create(&deps_filename));
657 for path in out_filenames.iter() {
658 try!(write!(&mut file as &mut Writer,
659 "{}: {}\n\n", path.display(), files.connect(" ")));
667 sess.fatal(format!("error writing dependencies to `{}`: {}",
668 deps_filename.display(), e).as_slice());
673 pub fn collect_crate_types(session: &Session,
674 attrs: &[ast::Attribute]) -> Vec<config::CrateType> {
675 // Unconditionally collect crate types from attributes to make them used
676 let attr_types: Vec<config::CrateType> = attrs.iter().filter_map(|a| {
677 if a.check_name("crate_type") {
678 match a.value_str() {
679 Some(ref n) if n.equiv(&("rlib")) => {
680 Some(config::CrateTypeRlib)
682 Some(ref n) if n.equiv(&("dylib")) => {
683 Some(config::CrateTypeDylib)
685 Some(ref n) if n.equiv(&("lib")) => {
686 Some(config::default_lib_output())
688 Some(ref n) if n.equiv(&("staticlib")) => {
689 Some(config::CrateTypeStaticlib)
691 Some(ref n) if n.equiv(&("bin")) => Some(config::CrateTypeExecutable),
693 session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE,
696 "invalid `crate_type` \
701 session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE,
704 "`crate_type` requires a \
714 // If we're generating a test executable, then ignore all other output
715 // styles at all other locations
716 if session.opts.test {
717 return vec!(config::CrateTypeExecutable)
720 // Only check command line flags if present. If no types are specified by
721 // command line, then reuse the empty `base` Vec to hold the types that
722 // will be found in crate attributes.
723 let mut base = session.opts.crate_types.clone();
725 base.extend(attr_types.into_iter());
727 base.push(link::default_output_for_target(session));
729 base.as_mut_slice().sort();
733 base.into_iter().filter(|crate_type| {
734 let res = !link::invalid_output_for_target(session, *crate_type);
737 session.warn(format!("dropping unsupported crate type `{}` \
739 *crate_type, session.targ_cfg.os).as_slice());
746 pub fn collect_crate_metadata(session: &Session,
747 _attrs: &[ast::Attribute]) -> Vec<String> {
748 session.opts.cg.metadata.clone()
752 pub struct OutputFilenames {
753 pub out_directory: Path,
754 pub out_filestem: String,
755 pub single_output_file: Option<Path>,
759 impl OutputFilenames {
760 pub fn path(&self, flavor: write::OutputType) -> Path {
761 match self.single_output_file {
762 Some(ref path) => return path.clone(),
765 self.temp_path(flavor)
768 pub fn temp_path(&self, flavor: write::OutputType) -> Path {
769 let base = self.out_directory.join(self.filestem());
771 write::OutputTypeBitcode => base.with_extension("bc"),
772 write::OutputTypeAssembly => base.with_extension("s"),
773 write::OutputTypeLlvmAssembly => base.with_extension("ll"),
774 write::OutputTypeObject => base.with_extension("o"),
775 write::OutputTypeExe => base,
779 pub fn with_extension(&self, extension: &str) -> Path {
780 self.out_directory.join(self.filestem()).with_extension(extension)
783 fn filestem(&self) -> String {
784 format!("{}{}", self.out_filestem, self.extra)
788 pub fn build_output_filenames(input: &Input,
790 ofile: &Option<Path>,
791 attrs: &[ast::Attribute],
796 // "-" as input file will cause the parser to read from stdin so we
797 // have to make up a name
798 // We want to toss everything after the final '.'
799 let dirpath = match *odir {
800 Some(ref d) => d.clone(),
801 None => Path::new(".")
804 // If a crate name is present, we use it as the link name
805 let stem = sess.opts.crate_name.clone().or_else(|| {
806 attr::find_crate_name(attrs).map(|n| n.get().to_string())
808 // NB: this clause can be removed once #[crate_id] is no longer
811 // Also note that this will be warned about later so we don't
812 // warn about it here.
813 use syntax::crateid::CrateId;
814 attrs.iter().find(|at| at.check_name("crate_id"))
815 .and_then(|at| at.value_str())
816 .and_then(|s| from_str::<CrateId>(s.get()))
818 }).unwrap_or(input.filestem());
821 out_directory: dirpath,
823 single_output_file: None,
824 extra: sess.opts.cg.extra_filename.clone(),
828 Some(ref out_file) => {
829 let ofile = if sess.opts.output_types.len() > 1 {
830 sess.warn("ignoring specified output filename because multiple \
831 outputs were requested");
834 Some(out_file.clone())
837 sess.warn("ignoring --out-dir flag due to -o flag.");
840 out_directory: out_file.dir_path(),
841 out_filestem: out_file.filestem_str().unwrap().to_string(),
842 single_output_file: ofile,
843 extra: sess.opts.cg.extra_filename.clone(),