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

Cleanup for librustc::session #52758

Merged
merged 9 commits into from
Aug 4, 2018
20 changes: 10 additions & 10 deletions src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,30 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

let preferred_linkage = match ty {
// cdylibs must have all static dependencies.
config::CrateTypeCdylib => Linkage::Static,
config::CrateType::Cdylib => Linkage::Static,

// Generating a dylib without `-C prefer-dynamic` means that we're going
// to try to eagerly statically link all dependencies. This is normally
// done for end-product dylibs, not intermediate products.
config::CrateTypeDylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
config::CrateTypeDylib => Linkage::Dynamic,
config::CrateType::Dylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
config::CrateType::Dylib => Linkage::Dynamic,

// If the global prefer_dynamic switch is turned off, or the final
// executable will be statically linked, prefer static crate linkage.
config::CrateTypeExecutable if !sess.opts.cg.prefer_dynamic ||
config::CrateType::Executable if !sess.opts.cg.prefer_dynamic ||
sess.crt_static() => Linkage::Static,
config::CrateTypeExecutable => Linkage::Dynamic,
config::CrateType::Executable => Linkage::Dynamic,

// proc-macro crates are required to be dylibs, and they're currently
// required to link to libsyntax as well.
config::CrateTypeProcMacro => Linkage::Dynamic,
config::CrateType::ProcMacro => Linkage::Dynamic,

// No linkage happens with rlibs, we just needed the metadata (which we
// got long ago), so don't bother with anything.
config::CrateTypeRlib => Linkage::NotLinked,
config::CrateType::Rlib => Linkage::NotLinked,

// staticlibs must have all static dependencies.
config::CrateTypeStaticlib => Linkage::Static,
config::CrateType::Staticlib => Linkage::Static,
};

if preferred_linkage == Linkage::NotLinked {
Expand All @@ -155,8 +155,8 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

// Staticlibs, cdylibs, and static executables must have all static
// dependencies. If any are not found, generate some nice pretty errors.
if ty == config::CrateTypeCdylib || ty == config::CrateTypeStaticlib ||
(ty == config::CrateTypeExecutable && sess.crt_static() &&
if ty == config::CrateType::Cdylib || ty == config::CrateType::Staticlib ||
(ty == config::CrateType::Executable && sess.crt_static() &&
!sess.target.target.options.crt_static_allows_dylibs) {
for &cnum in tcx.crates().iter() {
if tcx.dep_kind(cnum).macros_only() { continue }
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use hir::map as hir_map;
use hir::def_id::{CRATE_DEF_INDEX};
use session::{config, Session};
use session::config::EntryFnType;
use syntax::ast::NodeId;
use syntax::attr;
use syntax::entry::EntryPointType;
Expand Down Expand Up @@ -59,7 +60,7 @@ pub fn find_entry_point(session: &Session,
hir_map: &hir_map::Map,
crate_name: &str) {
let any_exe = session.crate_types.borrow().iter().any(|ty| {
*ty == config::CrateTypeExecutable
*ty == config::CrateType::Executable
});
if !any_exe {
// No need to find a main function
Expand Down Expand Up @@ -155,11 +156,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {

fn configure_main(this: &mut EntryContext, crate_name: &str) {
if let Some((node_id, span)) = this.start_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryStart)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Start)));
} else if let Some((node_id, span)) = this.attr_main_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
} else if let Some((node_id, span)) = this.main_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
} else {
// No main function
this.session.entry_fn.set(None);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);

let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
*ty == config::CrateTypeProcMacro
*ty == config::CrateType::Rlib || *ty == config::CrateType::Dylib ||
*ty == config::CrateType::ProcMacro
});
let mut reachable_context = ReachableContext {
tcx,
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// emitting something that's not an rlib.
let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| {
match *kind {
config::CrateTypeDylib |
config::CrateTypeProcMacro |
config::CrateTypeCdylib |
config::CrateTypeExecutable |
config::CrateTypeStaticlib => true,
config::CrateTypeRlib => false,
config::CrateType::Dylib |
config::CrateType::ProcMacro |
config::CrateType::Cdylib |
config::CrateType::Executable |
config::CrateType::Staticlib => true,
config::CrateType::Rlib => false,
}
});
if !needs_check {
Expand Down
Loading