cleanup: config::CrateType
-> CrateType
This commit is contained in:
parent
dae90c1959
commit
ff86a45820
20 changed files with 142 additions and 160 deletions
|
@ -17,7 +17,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::dep_graph::WorkProduct;
|
||||
use rustc_middle::middle::exported_symbols::SymbolExportLevel;
|
||||
use rustc_session::cgu_reuse_tracker::CguReuse;
|
||||
use rustc_session::config::{self, Lto};
|
||||
use rustc_session::config::{self, CrateType, Lto};
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::fs::File;
|
||||
|
@ -33,13 +33,10 @@ use std::sync::Arc;
|
|||
/// compilation session.
|
||||
pub const THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME: &str = "thin-lto-past-imports.bin";
|
||||
|
||||
pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
|
||||
pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
|
||||
match crate_type {
|
||||
config::CrateType::Executable
|
||||
| config::CrateType::Staticlib
|
||||
| config::CrateType::Cdylib => true,
|
||||
|
||||
config::CrateType::Dylib | config::CrateType::Rlib | config::CrateType::ProcMacro => false,
|
||||
CrateType::Executable | CrateType::Staticlib | CrateType::Cdylib => true,
|
||||
CrateType::Dylib | CrateType::Rlib | CrateType::ProcMacro => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::mir::mono::CodegenUnit;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, CFGuard, DebugInfo};
|
||||
use rustc_session::config::{CFGuard, CrateType, DebugInfo};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
@ -101,9 +101,10 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
|
|||
/// If the list of crate types is not yet known we conservatively return `false`.
|
||||
pub fn all_outputs_are_pic_executables(sess: &Session) -> bool {
|
||||
sess.relocation_model() == RelocModel::Pic
|
||||
&& sess.crate_types.try_get().map_or(false, |crate_types| {
|
||||
crate_types.iter().all(|ty| *ty == config::CrateType::Executable)
|
||||
})
|
||||
&& sess
|
||||
.crate_types
|
||||
.try_get()
|
||||
.map_or(false, |crate_types| crate_types.iter().all(|ty| *ty == CrateType::Executable))
|
||||
}
|
||||
|
||||
fn strip_function_ptr_alignment(data_layout: String) -> String {
|
||||
|
|
|
@ -3,9 +3,8 @@ use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
|||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLibrary, NativeLibraryKind};
|
||||
use rustc_middle::middle::dependency_format::Linkage;
|
||||
use rustc_session::config::{
|
||||
self, CFGuard, DebugInfo, OutputFilenames, OutputType, PrintRequest, Sanitizer,
|
||||
};
|
||||
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo};
|
||||
use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, Sanitizer};
|
||||
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
/// For all the linkers we support, and information they might
|
||||
|
@ -55,7 +54,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
|||
// Ignore executable crates if we have -Z no-codegen, as they will error.
|
||||
if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen())
|
||||
&& !output_metadata
|
||||
&& crate_type == config::CrateType::Executable
|
||||
&& crate_type == CrateType::Executable
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
|||
if outputs.outputs.should_codegen() {
|
||||
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
|
||||
match crate_type {
|
||||
config::CrateType::Rlib => {
|
||||
CrateType::Rlib => {
|
||||
let _timer = sess.timer("link_rlib");
|
||||
link_rlib::<B>(
|
||||
sess,
|
||||
|
@ -93,7 +92,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
|||
)
|
||||
.build();
|
||||
}
|
||||
config::CrateType::Staticlib => {
|
||||
CrateType::Staticlib => {
|
||||
link_staticlib::<B>(sess, codegen_results, &out_filename, &tmpdir);
|
||||
}
|
||||
_ => {
|
||||
|
@ -236,10 +235,10 @@ pub fn each_linked_rlib(
|
|||
let mut fmts = None;
|
||||
for (ty, list) in info.dependency_formats.iter() {
|
||||
match ty {
|
||||
config::CrateType::Executable
|
||||
| config::CrateType::Staticlib
|
||||
| config::CrateType::Cdylib
|
||||
| config::CrateType::ProcMacro => {
|
||||
CrateType::Executable
|
||||
| CrateType::Staticlib
|
||||
| CrateType::Cdylib
|
||||
| CrateType::ProcMacro => {
|
||||
fmts = Some(list);
|
||||
break;
|
||||
}
|
||||
|
@ -461,7 +460,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
|
|||
// links to all upstream files as well.
|
||||
fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||
sess: &'a Session,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
out_filename: &Path,
|
||||
codegen_results: &CodegenResults,
|
||||
tmpdir: &Path,
|
||||
|
@ -664,13 +663,13 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||
}
|
||||
}
|
||||
|
||||
fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker: &mut dyn Linker) {
|
||||
fn link_sanitizer_runtime(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) {
|
||||
let sanitizer = match &sess.opts.debugging_opts.sanitizer {
|
||||
Some(s) => s,
|
||||
None => return,
|
||||
};
|
||||
|
||||
if crate_type != config::CrateType::Executable {
|
||||
if crate_type != CrateType::Executable {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -826,7 +825,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
|
|||
.crate_types
|
||||
.borrow()
|
||||
.iter()
|
||||
.any(|&x| x != config::CrateType::Rlib && x != config::CrateType::Staticlib);
|
||||
.any(|&x| x != CrateType::Rlib && x != CrateType::Staticlib);
|
||||
if !output_linked {
|
||||
return false;
|
||||
}
|
||||
|
@ -1132,8 +1131,8 @@ fn exec_linker(
|
|||
}
|
||||
|
||||
/// Add begin object files defined by the target spec.
|
||||
fn add_pre_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config::CrateType) {
|
||||
let pre_link_objects = if crate_type == config::CrateType::Executable {
|
||||
fn add_pre_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: CrateType) {
|
||||
let pre_link_objects = if crate_type == CrateType::Executable {
|
||||
&sess.target.target.options.pre_link_objects_exe
|
||||
} else {
|
||||
&sess.target.target.options.pre_link_objects_dll
|
||||
|
@ -1142,7 +1141,7 @@ fn add_pre_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config
|
|||
cmd.add_object(&get_object_file_path(sess, obj));
|
||||
}
|
||||
|
||||
if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
|
||||
if crate_type == CrateType::Executable && sess.crt_static(Some(crate_type)) {
|
||||
for obj in &sess.target.target.options.pre_link_objects_exe_crt {
|
||||
cmd.add_object(&get_object_file_path(sess, obj));
|
||||
}
|
||||
|
@ -1150,7 +1149,7 @@ fn add_pre_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config
|
|||
}
|
||||
|
||||
/// Add end object files defined by the target spec.
|
||||
fn add_post_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config::CrateType) {
|
||||
fn add_post_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: CrateType) {
|
||||
for obj in &sess.target.target.options.post_link_objects {
|
||||
cmd.add_object(&get_object_file_path(sess, obj));
|
||||
}
|
||||
|
@ -1167,7 +1166,7 @@ fn add_pre_link_args(
|
|||
cmd: &mut dyn Linker,
|
||||
sess: &Session,
|
||||
flavor: LinkerFlavor,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
) {
|
||||
if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
|
@ -1197,13 +1196,13 @@ fn add_late_link_args(
|
|||
cmd: &mut dyn Linker,
|
||||
sess: &Session,
|
||||
flavor: LinkerFlavor,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
codegen_results: &CodegenResults,
|
||||
) {
|
||||
if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
|
||||
cmd.args(args);
|
||||
}
|
||||
let any_dynamic_crate = crate_type == config::CrateType::Dylib
|
||||
let any_dynamic_crate = crate_type == CrateType::Dylib
|
||||
|| codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| {
|
||||
*ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
});
|
||||
|
@ -1243,13 +1242,13 @@ fn add_local_crate_allocator_objects(cmd: &mut dyn Linker, codegen_results: &Cod
|
|||
/// Add object files containing metadata for the current crate.
|
||||
fn add_local_crate_metadata_objects(
|
||||
cmd: &mut dyn Linker,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
codegen_results: &CodegenResults,
|
||||
) {
|
||||
// When linking a dynamic library, we put the metadata into a section of the
|
||||
// executable. This metadata is in a separate object file from the main
|
||||
// object file, so we link that in here.
|
||||
if crate_type == config::CrateType::Dylib || crate_type == config::CrateType::ProcMacro {
|
||||
if crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro {
|
||||
if let Some(obj) = codegen_results.metadata_module.as_ref().and_then(|m| m.object.as_ref())
|
||||
{
|
||||
cmd.add_object(obj);
|
||||
|
@ -1263,7 +1262,7 @@ fn add_local_crate_metadata_objects(
|
|||
fn link_local_crate_native_libs_and_dependent_crate_libs<'a, B: ArchiveBuilder<'a>>(
|
||||
cmd: &mut dyn Linker,
|
||||
sess: &'a Session,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
codegen_results: &CodegenResults,
|
||||
tmpdir: &Path,
|
||||
) {
|
||||
|
@ -1326,10 +1325,10 @@ fn add_position_independent_executable_args(
|
|||
cmd: &mut dyn Linker,
|
||||
sess: &Session,
|
||||
flavor: LinkerFlavor,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
codegen_results: &CodegenResults,
|
||||
) {
|
||||
if crate_type != config::CrateType::Executable {
|
||||
if crate_type != CrateType::Executable {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1406,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
path: &Path,
|
||||
flavor: LinkerFlavor,
|
||||
sess: &'a Session,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
tmpdir: &Path,
|
||||
out_filename: &Path,
|
||||
codegen_results: &CodegenResults,
|
||||
|
@ -1463,7 +1462,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
cmd.output_filename(out_filename);
|
||||
|
||||
// OBJECT-FILES-NO, AUDIT-ORDER
|
||||
if crate_type == config::CrateType::Executable && sess.target.target.options.is_like_windows {
|
||||
if crate_type == CrateType::Executable && sess.target.target.options.is_like_windows {
|
||||
if let Some(ref s) = codegen_results.windows_subsystem {
|
||||
cmd.subsystem(s);
|
||||
}
|
||||
|
@ -1486,7 +1485,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
// Try to strip as much out of the generated object by removing unused
|
||||
// sections if possible. See more comments in linker.rs
|
||||
if !sess.opts.cg.link_dead_code {
|
||||
let keep_metadata = crate_type == config::CrateType::Dylib;
|
||||
let keep_metadata = crate_type == CrateType::Dylib;
|
||||
cmd.gc_sections(keep_metadata);
|
||||
}
|
||||
|
||||
|
@ -1522,10 +1521,10 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
|
|||
|
||||
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
|
||||
// Tell the linker what we're doing.
|
||||
if crate_type != config::CrateType::Executable {
|
||||
if crate_type != CrateType::Executable {
|
||||
cmd.build_dylib(out_filename);
|
||||
}
|
||||
if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
|
||||
if crate_type == CrateType::Executable && sess.crt_static(Some(crate_type)) {
|
||||
cmd.build_static_executable();
|
||||
}
|
||||
|
||||
|
@ -1619,7 +1618,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||
cmd: &mut dyn Linker,
|
||||
sess: &'a Session,
|
||||
codegen_results: &CodegenResults,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
tmpdir: &Path,
|
||||
) {
|
||||
// All of the heavy lifting has previously been accomplished by the
|
||||
|
@ -1780,7 +1779,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||
sess: &'a Session,
|
||||
codegen_results: &CodegenResults,
|
||||
tmpdir: &Path,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
cnum: CrateNum,
|
||||
) {
|
||||
let src = &codegen_results.crate_info.used_crate_source[&cnum];
|
||||
|
@ -1796,7 +1795,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||
|
||||
if (!are_upstream_rust_objects_already_included(sess)
|
||||
|| ignored_for_lto(sess, &codegen_results.crate_info, cnum))
|
||||
&& crate_type != config::CrateType::Dylib
|
||||
&& crate_type != CrateType::Dylib
|
||||
&& !skip_native
|
||||
{
|
||||
cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
|
||||
|
@ -1857,7 +1856,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||
// Note, though, that we don't want to include the whole of a
|
||||
// compiler-builtins crate (e.g., compiler-rt) because it'll get
|
||||
// repeatedly linked anyway.
|
||||
if crate_type == config::CrateType::Dylib
|
||||
if crate_type == CrateType::Dylib
|
||||
&& codegen_results.crate_info.compiler_builtins != Some(cnum)
|
||||
{
|
||||
cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
|
||||
|
@ -1905,7 +1904,7 @@ fn add_upstream_native_libraries(
|
|||
cmd: &mut dyn Linker,
|
||||
sess: &Session,
|
||||
codegen_results: &CodegenResults,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
) {
|
||||
// Be sure to use a topological sorting of crates because there may be
|
||||
// interdependencies between native libraries. When passing -nodefaultlibs,
|
||||
|
|
|
@ -15,23 +15,22 @@ use rustc_middle::ty::query::Providers;
|
|||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::ty::{SymbolName, TyCtxt};
|
||||
use rustc_session::config::{self, Sanitizer};
|
||||
use rustc_session::config::{CrateType, Sanitizer};
|
||||
|
||||
pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
|
||||
crates_export_threshold(&tcx.sess.crate_types.borrow())
|
||||
}
|
||||
|
||||
fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel {
|
||||
fn crate_export_threshold(crate_type: CrateType) -> SymbolExportLevel {
|
||||
match crate_type {
|
||||
config::CrateType::Executable
|
||||
| config::CrateType::Staticlib
|
||||
| config::CrateType::ProcMacro
|
||||
| config::CrateType::Cdylib => SymbolExportLevel::C,
|
||||
config::CrateType::Rlib | config::CrateType::Dylib => SymbolExportLevel::Rust,
|
||||
CrateType::Executable | CrateType::Staticlib | CrateType::ProcMacro | CrateType::Cdylib => {
|
||||
SymbolExportLevel::C
|
||||
}
|
||||
CrateType::Rlib | CrateType::Dylib => SymbolExportLevel::Rust,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExportLevel {
|
||||
pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel {
|
||||
if crate_types
|
||||
.iter()
|
||||
.any(|&crate_type| crate_export_threshold(crate_type) == SymbolExportLevel::Rust)
|
||||
|
@ -213,7 +212,7 @@ fn exported_symbols_provider_local(
|
|||
}));
|
||||
}
|
||||
|
||||
if tcx.sess.crate_types.borrow().contains(&config::CrateType::Dylib) {
|
||||
if tcx.sess.crate_types.borrow().contains(&CrateType::Dylib) {
|
||||
let symbol_name = metadata_symbol_name(tcx);
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
|
||||
|
||||
|
|
|
@ -28,9 +28,8 @@ use rustc_middle::middle::cstore::EncodedMetadata;
|
|||
use rustc_middle::middle::exported_symbols::SymbolExportLevel;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::cgu_reuse_tracker::CguReuseTracker;
|
||||
use rustc_session::config::{
|
||||
self, Lto, OutputFilenames, OutputType, Passes, Sanitizer, SwitchWithOptPath,
|
||||
};
|
||||
use rustc_session::config::{self, CrateType, Lto, OutputFilenames, OutputType};
|
||||
use rustc_session::config::{Passes, Sanitizer, SwitchWithOptPath};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
|
@ -288,7 +287,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
|||
pub fewer_names: bool,
|
||||
pub exported_symbols: Option<Arc<ExportedSymbols>>,
|
||||
pub opts: Arc<config::Options>,
|
||||
pub crate_types: Vec<config::CrateType>,
|
||||
pub crate_types: Vec<CrateType>,
|
||||
pub each_linked_rlib_for_lto: Vec<(CrateNum, PathBuf)>,
|
||||
pub output_filenames: Arc<OutputFilenames>,
|
||||
pub regular_module_config: Arc<ModuleConfig>,
|
||||
|
@ -375,7 +374,7 @@ pub struct CompiledModules {
|
|||
|
||||
fn need_crate_bitcode_for_rlib(sess: &Session) -> bool {
|
||||
sess.opts.cg.embed_bitcode
|
||||
&& sess.crate_types.borrow().contains(&config::CrateType::Rlib)
|
||||
&& sess.crate_types.borrow().contains(&CrateType::Rlib)
|
||||
&& sess.opts.output_types.contains_key(&OutputType::Exe)
|
||||
}
|
||||
|
||||
|
@ -760,7 +759,7 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
|
|||
// require LTO so the request for LTO is always unconditionally
|
||||
// passed down to the backend, but we don't actually want to do
|
||||
// anything about it yet until we've got a final product.
|
||||
let is_rlib = cgcx.crate_types.len() == 1 && cgcx.crate_types[0] == config::CrateType::Rlib;
|
||||
let is_rlib = cgcx.crate_types.len() == 1 && cgcx.crate_types[0] == CrateType::Rlib;
|
||||
|
||||
// Metadata modules never participate in LTO regardless of the lto
|
||||
// settings.
|
||||
|
@ -1813,7 +1812,7 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
|
|||
);
|
||||
|
||||
tcx.sess.target.target.options.is_like_msvc &&
|
||||
tcx.sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateType::Rlib) &&
|
||||
tcx.sess.crate_types.borrow().iter().any(|ct| *ct == CrateType::Rlib) &&
|
||||
// ThinLTO can't handle this workaround in all cases, so we don't
|
||||
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
|
||||
// dynamic linking when linker plugin LTO is enabled.
|
||||
|
|
|
@ -27,9 +27,7 @@ use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
|
|||
use rustc_passes::{self, hir_stats, layout_test};
|
||||
use rustc_plugin_impl as plugin;
|
||||
use rustc_resolve::{Resolver, ResolverArenas};
|
||||
use rustc_session::config::{
|
||||
self, CrateType, Input, OutputFilenames, OutputType, PpMode, PpSourceMode,
|
||||
};
|
||||
use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType, PpMode, PpSourceMode};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::output::{filename_for_input, filename_for_metadata};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
|
@ -361,7 +359,7 @@ fn configure_and_expand_inner<'a>(
|
|||
});
|
||||
|
||||
let crate_types = sess.crate_types.borrow();
|
||||
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
|
||||
let is_proc_macro_crate = crate_types.contains(&CrateType::ProcMacro);
|
||||
|
||||
// For backwards compatibility, we don't try to run proc macro injection
|
||||
// if rustdoc is run on a proc macro crate without '--crate-type proc-macro' being
|
||||
|
|
|
@ -16,11 +16,12 @@ use rustc_metadata::dynamic_lib::DynamicLibrary;
|
|||
use rustc_middle::ty;
|
||||
use rustc_resolve::{self, Resolver};
|
||||
use rustc_session as session;
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutputFilenames};
|
||||
use rustc_session::lint::{self, BuiltinLintDiagnostics, LintBuffer};
|
||||
use rustc_session::parse::CrateConfig;
|
||||
use rustc_session::CrateDisambiguator;
|
||||
use rustc_session::{config, early_error, filesearch, output, DiagnosticOutput, Session};
|
||||
use rustc_session::{early_error, filesearch, output, DiagnosticOutput, Session};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::{FileLoader, SourceMap};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
@ -409,7 +410,7 @@ pub(crate) fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguat
|
|||
|
||||
// Also incorporate crate type, so that we don't get symbol conflicts when
|
||||
// linking against a library of the same name, if this is an executable.
|
||||
let is_exe = session.crate_types.borrow().contains(&config::CrateType::Executable);
|
||||
let is_exe = session.crate_types.borrow().contains(&CrateType::Executable);
|
||||
hasher.write(if is_exe { b"exe" } else { b"lib" });
|
||||
|
||||
CrateDisambiguator::from(hasher.finish::<Fingerprint>())
|
||||
|
@ -457,23 +458,23 @@ pub(crate) fn check_attr_crate_type(attrs: &[ast::Attribute], lint_buffer: &mut
|
|||
}
|
||||
}
|
||||
|
||||
const CRATE_TYPES: &[(Symbol, config::CrateType)] = &[
|
||||
(sym::rlib, config::CrateType::Rlib),
|
||||
(sym::dylib, config::CrateType::Dylib),
|
||||
(sym::cdylib, config::CrateType::Cdylib),
|
||||
const CRATE_TYPES: &[(Symbol, CrateType)] = &[
|
||||
(sym::rlib, CrateType::Rlib),
|
||||
(sym::dylib, CrateType::Dylib),
|
||||
(sym::cdylib, CrateType::Cdylib),
|
||||
(sym::lib, config::default_lib_output()),
|
||||
(sym::staticlib, config::CrateType::Staticlib),
|
||||
(sym::proc_dash_macro, config::CrateType::ProcMacro),
|
||||
(sym::bin, config::CrateType::Executable),
|
||||
(sym::staticlib, CrateType::Staticlib),
|
||||
(sym::proc_dash_macro, CrateType::ProcMacro),
|
||||
(sym::bin, CrateType::Executable),
|
||||
];
|
||||
|
||||
fn categorize_crate_type(s: Symbol) -> Option<config::CrateType> {
|
||||
fn categorize_crate_type(s: Symbol) -> Option<CrateType> {
|
||||
Some(CRATE_TYPES.iter().find(|(key, _)| *key == s)?.1)
|
||||
}
|
||||
|
||||
pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<config::CrateType> {
|
||||
pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<CrateType> {
|
||||
// Unconditionally collect crate types from attributes to make them used
|
||||
let attr_types: Vec<config::CrateType> = attrs
|
||||
let attr_types: Vec<CrateType> = attrs
|
||||
.iter()
|
||||
.filter_map(|a| {
|
||||
if a.check_name(sym::crate_type) {
|
||||
|
@ -490,7 +491,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
|||
// If we're generating a test executable, then ignore all other output
|
||||
// styles at all other locations
|
||||
if session.opts.test {
|
||||
return vec![config::CrateType::Executable];
|
||||
return vec![CrateType::Executable];
|
||||
}
|
||||
|
||||
// Only check command line flags if present. If no types are specified by
|
||||
|
|
|
@ -17,7 +17,7 @@ use rustc_middle::middle::cstore::{
|
|||
CrateSource, ExternCrate, ExternCrateSource, MetadataLoaderDyn,
|
||||
};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config;
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_session::output::validate_crate_name;
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_session::{CrateDisambiguator, Session};
|
||||
|
@ -615,8 +615,7 @@ impl<'a> CrateLoader<'a> {
|
|||
fn inject_panic_runtime(&mut self, krate: &ast::Crate) {
|
||||
// If we're only compiling an rlib, then there's no need to select a
|
||||
// panic runtime, so we just skip this section entirely.
|
||||
let any_non_rlib =
|
||||
self.sess.crate_types.borrow().iter().any(|ct| *ct != config::CrateType::Rlib);
|
||||
let any_non_rlib = self.sess.crate_types.borrow().iter().any(|ct| *ct != CrateType::Rlib);
|
||||
if !any_non_rlib {
|
||||
info!("panic runtime injection skipped, only generating rlib");
|
||||
return;
|
||||
|
@ -736,7 +735,7 @@ impl<'a> CrateLoader<'a> {
|
|||
// if our compilation session actually needs an allocator based on what
|
||||
// we're emitting.
|
||||
let all_rlib = self.sess.crate_types.borrow().iter().all(|ct| match *ct {
|
||||
config::CrateType::Rlib => true,
|
||||
CrateType::Rlib => true,
|
||||
_ => false,
|
||||
});
|
||||
if all_rlib {
|
||||
|
|
|
@ -59,7 +59,7 @@ use rustc_middle::middle::cstore::LinkagePreference::{self, RequireDynamic, Requ
|
|||
use rustc_middle::middle::cstore::{self, DepKind};
|
||||
use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
crate fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
|
||||
|
@ -75,7 +75,7 @@ crate fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
|
|||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn calculate_type(tcx: TyCtxt<'_>, ty: config::CrateType) -> DependencyList {
|
||||
fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||
let sess = &tcx.sess;
|
||||
|
||||
if !sess.opts.output_types.should_codegen() {
|
||||
|
@ -90,29 +90,25 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: config::CrateType) -> DependencyList {
|
|||
// Treat cdylibs similarly. If `-C prefer-dynamic` is set, the caller may
|
||||
// be code-size conscious, but without it, it makes sense to statically
|
||||
// link a cdylib.
|
||||
config::CrateType::Dylib | config::CrateType::Cdylib if !sess.opts.cg.prefer_dynamic => {
|
||||
Linkage::Static
|
||||
}
|
||||
config::CrateType::Dylib | config::CrateType::Cdylib => Linkage::Dynamic,
|
||||
CrateType::Dylib | CrateType::Cdylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
|
||||
CrateType::Dylib | CrateType::Cdylib => Linkage::Dynamic,
|
||||
|
||||
// If the global prefer_dynamic switch is turned off, or the final
|
||||
// executable will be statically linked, prefer static crate linkage.
|
||||
config::CrateType::Executable
|
||||
if !sess.opts.cg.prefer_dynamic || sess.crt_static(Some(ty)) =>
|
||||
{
|
||||
CrateType::Executable if !sess.opts.cg.prefer_dynamic || sess.crt_static(Some(ty)) => {
|
||||
Linkage::Static
|
||||
}
|
||||
config::CrateType::Executable => Linkage::Dynamic,
|
||||
CrateType::Executable => Linkage::Dynamic,
|
||||
|
||||
// proc-macro crates are mostly cdylibs, but we also need metadata.
|
||||
config::CrateType::ProcMacro => Linkage::Static,
|
||||
CrateType::ProcMacro => Linkage::Static,
|
||||
|
||||
// No linkage happens with rlibs, we just needed the metadata (which we
|
||||
// got long ago), so don't bother with anything.
|
||||
config::CrateType::Rlib => Linkage::NotLinked,
|
||||
CrateType::Rlib => Linkage::NotLinked,
|
||||
|
||||
// staticlibs must have all static dependencies.
|
||||
config::CrateType::Staticlib => Linkage::Static,
|
||||
CrateType::Staticlib => Linkage::Static,
|
||||
};
|
||||
|
||||
if preferred_linkage == Linkage::NotLinked {
|
||||
|
@ -129,8 +125,8 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: config::CrateType) -> DependencyList {
|
|||
|
||||
// Staticlibs and static executables must have all static dependencies.
|
||||
// If any are not found, generate some nice pretty errors.
|
||||
if ty == config::CrateType::Staticlib
|
||||
|| (ty == config::CrateType::Executable
|
||||
if ty == CrateType::Staticlib
|
||||
|| (ty == CrateType::Executable
|
||||
&& sess.crt_static(Some(ty))
|
||||
&& !sess.target.target.options.crt_static_allows_dylibs)
|
||||
{
|
||||
|
|
|
@ -220,9 +220,10 @@ use rustc_data_structures::svh::Svh;
|
|||
use rustc_data_structures::sync::MetadataRef;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_middle::middle::cstore::{CrateSource, MetadataLoader};
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_session::filesearch::{FileDoesntMatch, FileMatches, FileSearch};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_session::{config, CrateDisambiguator, Session};
|
||||
use rustc_session::{CrateDisambiguator, Session};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::{Target, TargetTriple};
|
||||
|
@ -669,7 +670,7 @@ impl<'a> CrateLocator<'a> {
|
|||
|
||||
// The all loop is because `--crate-type=rlib --crate-type=rlib` is
|
||||
// legal and produces both inside this type.
|
||||
let is_rlib = self.sess.crate_types.borrow().iter().all(|c| *c == config::CrateType::Rlib);
|
||||
let is_rlib = self.sess.crate_types.borrow().iter().all(|c| *c == CrateType::Rlib);
|
||||
let needs_object_code = self.sess.opts.output_types.should_codegen();
|
||||
// If we're producing an rlib, then we don't need object code.
|
||||
// Or, if we're not producing object code, then we don't need it either
|
||||
|
|
|
@ -30,7 +30,7 @@ use rustc_middle::traits::specialization_graph;
|
|||
use rustc_middle::ty::codec::{self as ty_codec, TyEncoder};
|
||||
use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
|
||||
use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder};
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{self, ExternalSource, FileName, SourceFile, Span};
|
||||
|
@ -1499,7 +1499,7 @@ impl EncodeContext<'tcx> {
|
|||
fn encode_dylib_dependency_formats(&mut self) -> Lazy<[Option<LinkagePreference>]> {
|
||||
let formats = self.tcx.dependency_formats(LOCAL_CRATE);
|
||||
for (ty, arr) in formats.iter() {
|
||||
if *ty != config::CrateType::Dylib {
|
||||
if *ty != CrateType::Dylib {
|
||||
continue;
|
||||
}
|
||||
return self.lazy(arr.iter().map(|slot| match *slot {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//! For all the gory details, see the provider of the `dependency_formats`
|
||||
//! query.
|
||||
|
||||
use rustc_session::config;
|
||||
use rustc_session::config::CrateType;
|
||||
|
||||
/// A list of dependencies for a certain crate type.
|
||||
///
|
||||
|
@ -17,7 +17,7 @@ pub type DependencyList = Vec<Linkage>;
|
|||
/// A mapping of all required dependencies for a particular flavor of output.
|
||||
///
|
||||
/// This is local to the tcx, and is generally relevant to one session.
|
||||
pub type Dependencies = Vec<(config::CrateType, DependencyList)>;
|
||||
pub type Dependencies = Vec<(CrateType, DependencyList)>;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug, HashStable, RustcEncodable, RustcDecodable)]
|
||||
pub enum Linkage {
|
||||
|
|
|
@ -54,8 +54,7 @@ use rustc_hir::{HirId, Node, TraitCandidate};
|
|||
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_session::config::{BorrowckMode, OutputFilenames};
|
||||
use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
|
||||
use rustc_session::lint::{Level, Lint};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::MultiSpan;
|
||||
|
|
|
@ -7,8 +7,8 @@ use rustc_hir::{HirId, ImplItem, Item, ItemKind, TraitItem};
|
|||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::EntryFnType;
|
||||
use rustc_session::{config, Session};
|
||||
use rustc_session::config::{CrateType, EntryFnType};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
|
@ -51,8 +51,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
|
|||
fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType)> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
let any_exe =
|
||||
tcx.sess.crate_types.borrow().iter().any(|ty| *ty == config::CrateType::Executable);
|
||||
let any_exe = tcx.sess.crate_types.borrow().iter().any(|ty| *ty == CrateType::Executable);
|
||||
if !any_exe {
|
||||
// No need to find a main function.
|
||||
return None;
|
||||
|
|
|
@ -17,7 +17,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
|
|||
use rustc_middle::middle::privacy;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::config;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
// Returns true if the given item must be inlined because it may be
|
||||
|
@ -375,11 +375,10 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet
|
|||
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
|
||||
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
||||
*ty == config::CrateType::Rlib
|
||||
|| *ty == config::CrateType::Dylib
|
||||
|| *ty == config::CrateType::ProcMacro
|
||||
});
|
||||
let any_library =
|
||||
tcx.sess.crate_types.borrow().iter().any(|ty| {
|
||||
*ty == CrateType::Rlib || *ty == CrateType::Dylib || *ty == CrateType::ProcMacro
|
||||
});
|
||||
let mut reachable_context = ReachableContext {
|
||||
tcx,
|
||||
tables: &ty::TypeckTables::empty(None),
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hir::lang_items;
|
|||
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
|
||||
use rustc_middle::middle::lang_items::whitelisted;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -38,12 +38,12 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
|
|||
// We only need to check for the presence of weak lang items if we're
|
||||
// emitting something that's not an rlib.
|
||||
let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| match *kind {
|
||||
config::CrateType::Dylib
|
||||
| config::CrateType::ProcMacro
|
||||
| config::CrateType::Cdylib
|
||||
| config::CrateType::Executable
|
||||
| config::CrateType::Staticlib => true,
|
||||
config::CrateType::Rlib => false,
|
||||
CrateType::Dylib
|
||||
| CrateType::ProcMacro
|
||||
| CrateType::Cdylib
|
||||
| CrateType::Executable
|
||||
| CrateType::Staticlib => true,
|
||||
CrateType::Rlib => false,
|
||||
});
|
||||
if !needs_check {
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//! Related to out filenames of compilation (e.g. save analysis, binaries).
|
||||
use crate::config::{self, Input, OutputFilenames, OutputType};
|
||||
use crate::config::{CrateType, Input, OutputFilenames, OutputType};
|
||||
use crate::Session;
|
||||
use rustc_ast::{ast, attr};
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -8,7 +8,7 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
pub fn out_filename(
|
||||
sess: &Session,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
outputs: &OutputFilenames,
|
||||
crate_name: &str,
|
||||
) -> PathBuf {
|
||||
|
@ -146,27 +146,27 @@ pub fn filename_for_metadata(
|
|||
|
||||
pub fn filename_for_input(
|
||||
sess: &Session,
|
||||
crate_type: config::CrateType,
|
||||
crate_type: CrateType,
|
||||
crate_name: &str,
|
||||
outputs: &OutputFilenames,
|
||||
) -> PathBuf {
|
||||
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
|
||||
|
||||
match crate_type {
|
||||
config::CrateType::Rlib => outputs.out_directory.join(&format!("lib{}.rlib", libname)),
|
||||
config::CrateType::Cdylib | config::CrateType::ProcMacro | config::CrateType::Dylib => {
|
||||
CrateType::Rlib => outputs.out_directory.join(&format!("lib{}.rlib", libname)),
|
||||
CrateType::Cdylib | CrateType::ProcMacro | CrateType::Dylib => {
|
||||
let (prefix, suffix) =
|
||||
(&sess.target.target.options.dll_prefix, &sess.target.target.options.dll_suffix);
|
||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
||||
}
|
||||
config::CrateType::Staticlib => {
|
||||
CrateType::Staticlib => {
|
||||
let (prefix, suffix) = (
|
||||
&sess.target.target.options.staticlib_prefix,
|
||||
&sess.target.target.options.staticlib_suffix,
|
||||
);
|
||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
|
||||
}
|
||||
config::CrateType::Executable => {
|
||||
CrateType::Executable => {
|
||||
let suffix = &sess.target.target.options.exe_suffix;
|
||||
let out_filename = outputs.path(OutputType::Exe);
|
||||
if suffix.is_empty() { out_filename } else { out_filename.with_extension(&suffix[1..]) }
|
||||
|
@ -183,18 +183,18 @@ pub fn filename_for_input(
|
|||
/// way to run iOS binaries anyway without jailbreaking and
|
||||
/// interaction with Rust code through static library is the only
|
||||
/// option for now
|
||||
pub fn default_output_for_target(sess: &Session) -> config::CrateType {
|
||||
pub fn default_output_for_target(sess: &Session) -> CrateType {
|
||||
if !sess.target.target.options.executables {
|
||||
config::CrateType::Staticlib
|
||||
CrateType::Staticlib
|
||||
} else {
|
||||
config::CrateType::Executable
|
||||
CrateType::Executable
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if target supports crate_type as output
|
||||
pub fn invalid_output_for_target(sess: &Session, crate_type: config::CrateType) -> bool {
|
||||
pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool {
|
||||
match crate_type {
|
||||
config::CrateType::Cdylib | config::CrateType::Dylib | config::CrateType::ProcMacro => {
|
||||
CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro => {
|
||||
if !sess.target.target.options.dynamic_linking {
|
||||
return true;
|
||||
}
|
||||
|
@ -208,12 +208,12 @@ pub fn invalid_output_for_target(sess: &Session, crate_type: config::CrateType)
|
|||
}
|
||||
if sess.target.target.options.only_cdylib {
|
||||
match crate_type {
|
||||
config::CrateType::ProcMacro | config::CrateType::Dylib => return true,
|
||||
CrateType::ProcMacro | CrateType::Dylib => return true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if !sess.target.target.options.executables {
|
||||
if crate_type == config::CrateType::Executable {
|
||||
if crate_type == CrateType::Executable {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::cgu_reuse_tracker::CguReuseTracker;
|
||||
use crate::code_stats::CodeStats;
|
||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||
use crate::config::{self, OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
|
||||
use crate::config::{self, CrateType, OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
|
||||
use crate::filesearch;
|
||||
use crate::lint;
|
||||
use crate::parse::ParseSess;
|
||||
|
@ -73,7 +73,7 @@ pub struct Session {
|
|||
/// (sub)diagnostics that have been set once, but should not be set again,
|
||||
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
|
||||
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
|
||||
pub crate_types: Once<Vec<config::CrateType>>,
|
||||
pub crate_types: Once<Vec<CrateType>>,
|
||||
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
|
||||
/// arguments passed to the compiler. Its value together with the crate-name
|
||||
/// forms a unique global identifier for the crate. It is used to allow
|
||||
|
@ -552,7 +552,7 @@ impl Session {
|
|||
}
|
||||
|
||||
/// Check whether this compile session and crate type use static crt.
|
||||
pub fn crt_static(&self, crate_type: Option<config::CrateType>) -> bool {
|
||||
pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
|
||||
// If the target does not opt in to crt-static support, use its default.
|
||||
if self.target.target.options.crt_static_respected {
|
||||
self.crt_static_feature(crate_type)
|
||||
|
@ -562,15 +562,15 @@ impl Session {
|
|||
}
|
||||
|
||||
/// Check whether this compile session and crate type use `crt-static` feature.
|
||||
pub fn crt_static_feature(&self, crate_type: Option<config::CrateType>) -> bool {
|
||||
pub fn crt_static_feature(&self, crate_type: Option<CrateType>) -> bool {
|
||||
let requested_features = self.opts.cg.target_feature.split(',');
|
||||
let found_negative = requested_features.clone().any(|r| r == "-crt-static");
|
||||
let found_positive = requested_features.clone().any(|r| r == "+crt-static");
|
||||
|
||||
if found_positive || found_negative {
|
||||
found_positive
|
||||
} else if crate_type == Some(config::CrateType::ProcMacro)
|
||||
|| crate_type == None && self.opts.crate_types.contains(&config::CrateType::ProcMacro)
|
||||
} else if crate_type == Some(CrateType::ProcMacro)
|
||||
|| crate_type == None && self.opts.crate_types.contains(&CrateType::ProcMacro)
|
||||
{
|
||||
// FIXME: When crate_type is not available,
|
||||
// we use compiler options to determine the crate_type.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use rustc_ast::ast::CRATE_NODE_ID;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
use rustc_driver::abort_on_err;
|
||||
use rustc_errors::emitter::{Emitter, EmitterWriter};
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
|
@ -13,15 +14,14 @@ use rustc_middle::middle::cstore::CrateStore;
|
|||
use rustc_middle::middle::privacy::AccessLevels;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_resolve as resolve;
|
||||
use rustc_session::config::ErrorOutputType;
|
||||
use rustc_session::config::{self, CrateType, ErrorOutputType};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::DiagnosticOutput;
|
||||
use rustc_session::{config, Session};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
@ -30,7 +30,6 @@ use crate::clean;
|
|||
use crate::clean::{AttributesExt, MAX_DEF_ID};
|
||||
use crate::config::{Options as RustdocOptions, RenderOptions};
|
||||
use crate::html::render::RenderInfo;
|
||||
|
||||
use crate::passes::{self, Condition::*, ConditionalPass};
|
||||
|
||||
pub use rustc_session::config::{CodegenOptions, DebuggingOptions, Input, Options};
|
||||
|
@ -301,11 +300,8 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
})
|
||||
.collect();
|
||||
|
||||
let crate_types = if proc_macro_crate {
|
||||
vec![config::CrateType::ProcMacro]
|
||||
} else {
|
||||
vec![config::CrateType::Rlib]
|
||||
};
|
||||
let crate_types =
|
||||
if proc_macro_crate { vec![CrateType::ProcMacro] } else { vec![CrateType::Rlib] };
|
||||
// plays with error output here!
|
||||
let sessopts = config::Options {
|
||||
maybe_sysroot,
|
||||
|
|
|
@ -9,12 +9,15 @@ use rustc_hir::{HirId, CRATE_HIR_ID};
|
|||
use rustc_interface::interface;
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::{self, config, lint, DiagnosticOutput, Session};
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_session::{lint, DiagnosticOutput, Session};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
|
||||
use rustc_target::spec::TargetTriple;
|
||||
use tempfile::Builder as TempFileBuilder;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::io::{self, Write};
|
||||
|
@ -22,7 +25,6 @@ use std::panic;
|
|||
use std::path::PathBuf;
|
||||
use std::process::{self, Command, Stdio};
|
||||
use std::str;
|
||||
use tempfile::Builder as TempFileBuilder;
|
||||
|
||||
use crate::clean::Attributes;
|
||||
use crate::config::Options;
|
||||
|
@ -82,11 +84,8 @@ pub fn run(options: Options) -> i32 {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let crate_types = if options.proc_macro_crate {
|
||||
vec![config::CrateType::ProcMacro]
|
||||
} else {
|
||||
vec![config::CrateType::Rlib]
|
||||
};
|
||||
let crate_types =
|
||||
if options.proc_macro_crate { vec![CrateType::ProcMacro] } else { vec![CrateType::Rlib] };
|
||||
|
||||
let sessopts = config::Options {
|
||||
maybe_sysroot: options.maybe_sysroot.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue