Normalize variants of CrateType to standard style
This is a clippy-breaking change.
This commit is contained in:
parent
e59e02ef46
commit
2a9344206b
22 changed files with 144 additions and 145 deletions
|
@ -115,30 +115,30 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
let preferred_linkage = match ty {
|
let preferred_linkage = match ty {
|
||||||
// cdylibs must have all static dependencies.
|
// 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
|
// Generating a dylib without `-C prefer-dynamic` means that we're going
|
||||||
// to try to eagerly statically link all dependencies. This is normally
|
// to try to eagerly statically link all dependencies. This is normally
|
||||||
// done for end-product dylibs, not intermediate products.
|
// done for end-product dylibs, not intermediate products.
|
||||||
config::CrateTypeDylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
|
config::CrateType::Dylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
|
||||||
config::CrateTypeDylib => Linkage::Dynamic,
|
config::CrateType::Dylib => Linkage::Dynamic,
|
||||||
|
|
||||||
// If the global prefer_dynamic switch is turned off, or the final
|
// If the global prefer_dynamic switch is turned off, or the final
|
||||||
// executable will be statically linked, prefer static crate linkage.
|
// 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,
|
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
|
// proc-macro crates are required to be dylibs, and they're currently
|
||||||
// required to link to libsyntax as well.
|
// 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
|
// No linkage happens with rlibs, we just needed the metadata (which we
|
||||||
// got long ago), so don't bother with anything.
|
// got long ago), so don't bother with anything.
|
||||||
config::CrateTypeRlib => Linkage::NotLinked,
|
config::CrateType::Rlib => Linkage::NotLinked,
|
||||||
|
|
||||||
// staticlibs must have all static dependencies.
|
// staticlibs must have all static dependencies.
|
||||||
config::CrateTypeStaticlib => Linkage::Static,
|
config::CrateType::Staticlib => Linkage::Static,
|
||||||
};
|
};
|
||||||
|
|
||||||
if preferred_linkage == Linkage::NotLinked {
|
if preferred_linkage == Linkage::NotLinked {
|
||||||
|
@ -155,8 +155,8 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// Staticlibs, cdylibs, and static executables must have all static
|
// Staticlibs, cdylibs, and static executables must have all static
|
||||||
// dependencies. If any are not found, generate some nice pretty errors.
|
// dependencies. If any are not found, generate some nice pretty errors.
|
||||||
if ty == config::CrateTypeCdylib || ty == config::CrateTypeStaticlib ||
|
if ty == config::CrateType::Cdylib || ty == config::CrateType::Staticlib ||
|
||||||
(ty == config::CrateTypeExecutable && sess.crt_static() &&
|
(ty == config::CrateType::Executable && sess.crt_static() &&
|
||||||
!sess.target.target.options.crt_static_allows_dylibs) {
|
!sess.target.target.options.crt_static_allows_dylibs) {
|
||||||
for &cnum in tcx.crates().iter() {
|
for &cnum in tcx.crates().iter() {
|
||||||
if tcx.dep_kind(cnum).macros_only() { continue }
|
if tcx.dep_kind(cnum).macros_only() { continue }
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub fn find_entry_point(session: &Session,
|
||||||
hir_map: &hir_map::Map,
|
hir_map: &hir_map::Map,
|
||||||
crate_name: &str) {
|
crate_name: &str) {
|
||||||
let any_exe = session.crate_types.borrow().iter().any(|ty| {
|
let any_exe = session.crate_types.borrow().iter().any(|ty| {
|
||||||
*ty == config::CrateTypeExecutable
|
*ty == config::CrateType::Executable
|
||||||
});
|
});
|
||||||
if !any_exe {
|
if !any_exe {
|
||||||
// No need to find a main function
|
// No need to find a main function
|
||||||
|
|
|
@ -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 access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
|
|
||||||
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
||||||
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
|
*ty == config::CrateType::Rlib || *ty == config::CrateType::Dylib ||
|
||||||
*ty == config::CrateTypeProcMacro
|
*ty == config::CrateType::ProcMacro
|
||||||
});
|
});
|
||||||
let mut reachable_context = ReachableContext {
|
let mut reachable_context = ReachableContext {
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -89,12 +89,12 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// emitting something that's not an rlib.
|
// emitting something that's not an rlib.
|
||||||
let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| {
|
let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| {
|
||||||
match *kind {
|
match *kind {
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeProcMacro |
|
config::CrateType::ProcMacro |
|
||||||
config::CrateTypeCdylib |
|
config::CrateType::Cdylib |
|
||||||
config::CrateTypeExecutable |
|
config::CrateType::Executable |
|
||||||
config::CrateTypeStaticlib => true,
|
config::CrateType::Staticlib => true,
|
||||||
config::CrateTypeRlib => false,
|
config::CrateType::Rlib => false,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if !needs_check {
|
if !needs_check {
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//! command line options.
|
//! command line options.
|
||||||
|
|
||||||
pub use self::EntryFnType::*;
|
pub use self::EntryFnType::*;
|
||||||
pub use self::CrateType::*;
|
|
||||||
pub use self::Passes::*;
|
pub use self::Passes::*;
|
||||||
pub use self::DebugInfoLevel::*;
|
pub use self::DebugInfoLevel::*;
|
||||||
|
|
||||||
|
@ -670,12 +669,12 @@ pub enum EntryFnType {
|
||||||
|
|
||||||
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
|
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
|
||||||
pub enum CrateType {
|
pub enum CrateType {
|
||||||
CrateTypeExecutable,
|
Executable,
|
||||||
CrateTypeDylib,
|
Dylib,
|
||||||
CrateTypeRlib,
|
Rlib,
|
||||||
CrateTypeStaticlib,
|
Staticlib,
|
||||||
CrateTypeCdylib,
|
Cdylib,
|
||||||
CrateTypeProcMacro,
|
ProcMacro,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Hash)]
|
#[derive(Clone, Hash)]
|
||||||
|
@ -1374,7 +1373,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_lib_output() -> CrateType {
|
pub fn default_lib_output() -> CrateType {
|
||||||
CrateTypeRlib
|
CrateType::Rlib
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||||
|
@ -1432,7 +1431,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||||
if sess.opts.debug_assertions {
|
if sess.opts.debug_assertions {
|
||||||
ret.insert((Symbol::intern("debug_assertions"), None));
|
ret.insert((Symbol::intern("debug_assertions"), None));
|
||||||
}
|
}
|
||||||
if sess.opts.crate_types.contains(&CrateTypeProcMacro) {
|
if sess.opts.crate_types.contains(&CrateType::ProcMacro) {
|
||||||
ret.insert((Symbol::intern("proc_macro"), None));
|
ret.insert((Symbol::intern("proc_macro"), None));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2277,12 +2276,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
|
||||||
for part in unparsed_crate_type.split(',') {
|
for part in unparsed_crate_type.split(',') {
|
||||||
let new_part = match part {
|
let new_part = match part {
|
||||||
"lib" => default_lib_output(),
|
"lib" => default_lib_output(),
|
||||||
"rlib" => CrateTypeRlib,
|
"rlib" => CrateType::Rlib,
|
||||||
"staticlib" => CrateTypeStaticlib,
|
"staticlib" => CrateType::Staticlib,
|
||||||
"dylib" => CrateTypeDylib,
|
"dylib" => CrateType::Dylib,
|
||||||
"cdylib" => CrateTypeCdylib,
|
"cdylib" => CrateType::Cdylib,
|
||||||
"bin" => CrateTypeExecutable,
|
"bin" => CrateType::Executable,
|
||||||
"proc-macro" => CrateTypeProcMacro,
|
"proc-macro" => CrateType::ProcMacro,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(format!("unknown crate type: `{}`", part));
|
return Err(format!("unknown crate type: `{}`", part));
|
||||||
}
|
}
|
||||||
|
@ -2360,12 +2359,12 @@ pub mod nightly_options {
|
||||||
impl fmt::Display for CrateType {
|
impl fmt::Display for CrateType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
CrateTypeExecutable => "bin".fmt(f),
|
CrateType::Executable => "bin".fmt(f),
|
||||||
CrateTypeDylib => "dylib".fmt(f),
|
CrateType::Dylib => "dylib".fmt(f),
|
||||||
CrateTypeRlib => "rlib".fmt(f),
|
CrateType::Rlib => "rlib".fmt(f),
|
||||||
CrateTypeStaticlib => "staticlib".fmt(f),
|
CrateType::Staticlib => "staticlib".fmt(f),
|
||||||
CrateTypeCdylib => "cdylib".fmt(f),
|
CrateType::Cdylib => "cdylib".fmt(f),
|
||||||
CrateTypeProcMacro => "proc-macro".fmt(f),
|
CrateType::ProcMacro => "proc-macro".fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use dep_graph::{DepNode, DepConstructor};
|
||||||
use errors::DiagnosticBuilder;
|
use errors::DiagnosticBuilder;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use session::config::{BorrowckMode, OutputFilenames, OptLevel};
|
use session::config::{BorrowckMode, OutputFilenames, OptLevel};
|
||||||
use session::config::CrateType::*;
|
use session::config::CrateType;
|
||||||
use middle;
|
use middle;
|
||||||
use hir::{TraitCandidate, HirId, ItemLocalId};
|
use hir::{TraitCandidate, HirId, ItemLocalId};
|
||||||
use hir::def::{Def, Export};
|
use hir::def::{Def, Export};
|
||||||
|
@ -1493,12 +1493,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
self.sess.crate_types.borrow().iter().any(|crate_type| {
|
self.sess.crate_types.borrow().iter().any(|crate_type| {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateTypeExecutable |
|
CrateType::Executable |
|
||||||
CrateTypeStaticlib |
|
CrateType::Staticlib |
|
||||||
CrateTypeProcMacro |
|
CrateType::ProcMacro |
|
||||||
CrateTypeCdylib => false,
|
CrateType::Cdylib => false,
|
||||||
CrateTypeRlib |
|
CrateType::Rlib |
|
||||||
CrateTypeDylib => true,
|
CrateType::Dylib => true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ pub(crate) fn link_binary(sess: &Session,
|
||||||
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
|
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
|
||||||
if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen()) &&
|
if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen()) &&
|
||||||
!output_metadata &&
|
!output_metadata &&
|
||||||
crate_type == config::CrateTypeExecutable {
|
crate_type == config::CrateType::Executable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
|
||||||
// the objects as they're losslessly contained inside the archives.
|
// the objects as they're losslessly contained inside the archives.
|
||||||
let output_linked = sess.crate_types.borrow()
|
let output_linked = sess.crate_types.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| *x != config::CrateTypeRlib && *x != config::CrateTypeStaticlib);
|
.any(|x| *x != config::CrateType::Rlib && *x != config::CrateType::Staticlib);
|
||||||
if !output_linked {
|
if !output_linked {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -255,10 +255,10 @@ pub(crate) fn each_linked_rlib(sess: &Session,
|
||||||
f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {
|
f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {
|
||||||
let crates = info.used_crates_static.iter();
|
let crates = info.used_crates_static.iter();
|
||||||
let fmts = sess.dependency_formats.borrow();
|
let fmts = sess.dependency_formats.borrow();
|
||||||
let fmts = fmts.get(&config::CrateTypeExecutable)
|
let fmts = fmts.get(&config::CrateType::Executable)
|
||||||
.or_else(|| fmts.get(&config::CrateTypeStaticlib))
|
.or_else(|| fmts.get(&config::CrateType::Staticlib))
|
||||||
.or_else(|| fmts.get(&config::CrateTypeCdylib))
|
.or_else(|| fmts.get(&config::CrateType::Cdylib))
|
||||||
.or_else(|| fmts.get(&config::CrateTypeProcMacro));
|
.or_else(|| fmts.get(&config::CrateType::ProcMacro));
|
||||||
let fmts = match fmts {
|
let fmts = match fmts {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
None => return Err("could not find formats for rlibs".to_string())
|
None => return Err("could not find formats for rlibs".to_string())
|
||||||
|
@ -344,14 +344,14 @@ fn link_binary_output(sess: &Session,
|
||||||
if outputs.outputs.should_codegen() {
|
if outputs.outputs.should_codegen() {
|
||||||
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
|
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeRlib => {
|
config::CrateType::Rlib => {
|
||||||
link_rlib(sess,
|
link_rlib(sess,
|
||||||
codegen_results,
|
codegen_results,
|
||||||
RlibFlavor::Normal,
|
RlibFlavor::Normal,
|
||||||
&out_filename,
|
&out_filename,
|
||||||
&tmpdir).build();
|
&tmpdir).build();
|
||||||
}
|
}
|
||||||
config::CrateTypeStaticlib => {
|
config::CrateType::Staticlib => {
|
||||||
link_staticlib(sess, codegen_results, &out_filename, &tmpdir);
|
link_staticlib(sess, codegen_results, &out_filename, &tmpdir);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -644,7 +644,7 @@ fn link_natively(sess: &Session,
|
||||||
}
|
}
|
||||||
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
|
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
|
||||||
|
|
||||||
let pre_link_objects = if crate_type == config::CrateTypeExecutable {
|
let pre_link_objects = if crate_type == config::CrateType::Executable {
|
||||||
&sess.target.target.options.pre_link_objects_exe
|
&sess.target.target.options.pre_link_objects_exe
|
||||||
} else {
|
} else {
|
||||||
&sess.target.target.options.pre_link_objects_dll
|
&sess.target.target.options.pre_link_objects_dll
|
||||||
|
@ -653,7 +653,7 @@ fn link_natively(sess: &Session,
|
||||||
cmd.arg(root.join(obj));
|
cmd.arg(root.join(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
if crate_type == config::CrateTypeExecutable && sess.crt_static() {
|
if crate_type == config::CrateType::Executable && sess.crt_static() {
|
||||||
for obj in &sess.target.target.options.pre_link_objects_exe_crt {
|
for obj in &sess.target.target.options.pre_link_objects_exe_crt {
|
||||||
cmd.arg(root.join(obj));
|
cmd.arg(root.join(obj));
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1013,7 @@ fn link_args(cmd: &mut dyn Linker,
|
||||||
}
|
}
|
||||||
cmd.output_filename(out_filename);
|
cmd.output_filename(out_filename);
|
||||||
|
|
||||||
if crate_type == config::CrateTypeExecutable &&
|
if crate_type == config::CrateType::Executable &&
|
||||||
sess.target.target.options.is_like_windows {
|
sess.target.target.options.is_like_windows {
|
||||||
if let Some(ref s) = codegen_results.windows_subsystem {
|
if let Some(ref s) = codegen_results.windows_subsystem {
|
||||||
cmd.subsystem(s);
|
cmd.subsystem(s);
|
||||||
|
@ -1022,7 +1022,7 @@ fn link_args(cmd: &mut dyn Linker,
|
||||||
|
|
||||||
// If we're building a dynamic library then some platforms need to make sure
|
// If we're building a dynamic library then some platforms need to make sure
|
||||||
// that all symbols are exported correctly from the dynamic library.
|
// that all symbols are exported correctly from the dynamic library.
|
||||||
if crate_type != config::CrateTypeExecutable ||
|
if crate_type != config::CrateType::Executable ||
|
||||||
sess.target.target.options.is_like_emscripten {
|
sess.target.target.options.is_like_emscripten {
|
||||||
cmd.export_symbols(tmpdir, crate_type);
|
cmd.export_symbols(tmpdir, crate_type);
|
||||||
}
|
}
|
||||||
|
@ -1030,8 +1030,8 @@ fn link_args(cmd: &mut dyn Linker,
|
||||||
// When linking a dynamic library, we put the metadata into a section of the
|
// 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
|
// executable. This metadata is in a separate object file from the main
|
||||||
// object file, so we link that in here.
|
// object file, so we link that in here.
|
||||||
if crate_type == config::CrateTypeDylib ||
|
if crate_type == config::CrateType::Dylib ||
|
||||||
crate_type == config::CrateTypeProcMacro {
|
crate_type == config::CrateType::ProcMacro {
|
||||||
if let Some(obj) = codegen_results.metadata_module.object.as_ref() {
|
if let Some(obj) = codegen_results.metadata_module.object.as_ref() {
|
||||||
cmd.add_object(obj);
|
cmd.add_object(obj);
|
||||||
}
|
}
|
||||||
|
@ -1047,13 +1047,13 @@ fn link_args(cmd: &mut dyn Linker,
|
||||||
// Try to strip as much out of the generated object by removing unused
|
// Try to strip as much out of the generated object by removing unused
|
||||||
// sections if possible. See more comments in linker.rs
|
// sections if possible. See more comments in linker.rs
|
||||||
if !sess.opts.cg.link_dead_code {
|
if !sess.opts.cg.link_dead_code {
|
||||||
let keep_metadata = crate_type == config::CrateTypeDylib;
|
let keep_metadata = crate_type == config::CrateType::Dylib;
|
||||||
cmd.gc_sections(keep_metadata);
|
cmd.gc_sections(keep_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
let used_link_args = &codegen_results.crate_info.link_args;
|
let used_link_args = &codegen_results.crate_info.link_args;
|
||||||
|
|
||||||
if crate_type == config::CrateTypeExecutable {
|
if crate_type == config::CrateType::Executable {
|
||||||
let mut position_independent_executable = false;
|
let mut position_independent_executable = false;
|
||||||
|
|
||||||
if t.options.position_independent_executables {
|
if t.options.position_independent_executables {
|
||||||
|
@ -1145,10 +1145,10 @@ fn link_args(cmd: &mut dyn Linker,
|
||||||
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
|
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
|
||||||
|
|
||||||
// Tell the linker what we're doing.
|
// Tell the linker what we're doing.
|
||||||
if crate_type != config::CrateTypeExecutable {
|
if crate_type != config::CrateType::Executable {
|
||||||
cmd.build_dylib(out_filename);
|
cmd.build_dylib(out_filename);
|
||||||
}
|
}
|
||||||
if crate_type == config::CrateTypeExecutable && sess.crt_static() {
|
if crate_type == config::CrateType::Executable && sess.crt_static() {
|
||||||
cmd.build_static_executable();
|
cmd.build_static_executable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1448,7 +1448,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
|
||||||
|
|
||||||
if (!is_full_lto_enabled(sess) ||
|
if (!is_full_lto_enabled(sess) ||
|
||||||
ignored_for_lto(sess, &codegen_results.crate_info, cnum)) &&
|
ignored_for_lto(sess, &codegen_results.crate_info, cnum)) &&
|
||||||
crate_type != config::CrateTypeDylib &&
|
crate_type != config::CrateType::Dylib &&
|
||||||
!skip_native {
|
!skip_native {
|
||||||
cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
|
cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
|
||||||
return
|
return
|
||||||
|
@ -1524,7 +1524,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
|
||||||
// Note, though, that we don't want to include the whole of 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
|
// compiler-builtins crate (e.g. compiler-rt) because it'll get
|
||||||
// repeatedly linked anyway.
|
// repeatedly linked anyway.
|
||||||
if crate_type == config::CrateTypeDylib &&
|
if crate_type == config::CrateType::Dylib &&
|
||||||
codegen_results.crate_info.compiler_builtins != Some(cnum) {
|
codegen_results.crate_info.compiler_builtins != Some(cnum) {
|
||||||
cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
|
cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -387,8 +387,8 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
// exported symbols to ensure we don't expose any more. The object files
|
// exported symbols to ensure we don't expose any more. The object files
|
||||||
// have far more public symbols than we actually want to export, so we
|
// have far more public symbols than we actually want to export, so we
|
||||||
// hide them all here.
|
// hide them all here.
|
||||||
if crate_type == CrateType::CrateTypeDylib ||
|
if crate_type == CrateType::Dylib ||
|
||||||
crate_type == CrateType::CrateTypeProcMacro {
|
crate_type == CrateType::ProcMacro {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,13 @@ use std::sync::Arc;
|
||||||
|
|
||||||
pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
|
pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeExecutable |
|
config::CrateType::Executable |
|
||||||
config::CrateTypeStaticlib |
|
config::CrateType::Staticlib |
|
||||||
config::CrateTypeCdylib => true,
|
config::CrateType::Cdylib => true,
|
||||||
|
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeRlib |
|
config::CrateType::Rlib |
|
||||||
config::CrateTypeProcMacro => false,
|
config::CrateType::ProcMacro => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ pub fn threshold(tcx: TyCtxt) -> SymbolExportLevel {
|
||||||
|
|
||||||
fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel {
|
fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeExecutable |
|
config::CrateType::Executable |
|
||||||
config::CrateTypeStaticlib |
|
config::CrateType::Staticlib |
|
||||||
config::CrateTypeProcMacro |
|
config::CrateType::ProcMacro |
|
||||||
config::CrateTypeCdylib => SymbolExportLevel::C,
|
config::CrateType::Cdylib => SymbolExportLevel::C,
|
||||||
config::CrateTypeRlib |
|
config::CrateType::Rlib |
|
||||||
config::CrateTypeDylib => SymbolExportLevel::Rust,
|
config::CrateType::Dylib => SymbolExportLevel::Rust,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tcx.sess.crate_types.borrow().contains(&config::CrateTypeDylib) {
|
if tcx.sess.crate_types.borrow().contains(&config::CrateType::Dylib) {
|
||||||
let symbol_name = metadata_symbol_name(tcx);
|
let symbol_name = metadata_symbol_name(tcx);
|
||||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
|
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
|
||||||
|
|
||||||
|
|
|
@ -875,7 +875,7 @@ pub(crate) struct CompiledModules {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn need_crate_bitcode_for_rlib(sess: &Session) -> bool {
|
fn need_crate_bitcode_for_rlib(sess: &Session) -> bool {
|
||||||
sess.crate_types.borrow().contains(&config::CrateTypeRlib) &&
|
sess.crate_types.borrow().contains(&config::CrateType::Rlib) &&
|
||||||
sess.opts.output_types.contains_key(&OutputType::Exe)
|
sess.opts.output_types.contains_key(&OutputType::Exe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1341,7 +1341,7 @@ fn execute_work_item(cgcx: &CodegenContext,
|
||||||
// anything about it yet until we've got a final product.
|
// anything about it yet until we've got a final product.
|
||||||
Lto::Yes | Lto::Fat | Lto::Thin => {
|
Lto::Yes | Lto::Fat | Lto::Thin => {
|
||||||
cgcx.crate_types.len() != 1 ||
|
cgcx.crate_types.len() != 1 ||
|
||||||
cgcx.crate_types[0] != config::CrateTypeRlib
|
cgcx.crate_types[0] != config::CrateType::Rlib
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we're automatically doing ThinLTO for multi-codegen-unit
|
// When we're automatically doing ThinLTO for multi-codegen-unit
|
||||||
|
@ -2346,7 +2346,7 @@ pub(crate) fn submit_codegened_module_to_llvm(tcx: TyCtxt,
|
||||||
|
|
||||||
fn msvc_imps_needed(tcx: TyCtxt) -> bool {
|
fn msvc_imps_needed(tcx: TyCtxt) -> bool {
|
||||||
tcx.sess.target.target.options.is_like_msvc &&
|
tcx.sess.target.target.options.is_like_msvc &&
|
||||||
tcx.sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateTypeRlib)
|
tcx.sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateType::Rlib)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
|
// Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
|
||||||
|
|
|
@ -645,14 +645,14 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
|
||||||
|
|
||||||
let kind = tcx.sess.crate_types.borrow().iter().map(|ty| {
|
let kind = tcx.sess.crate_types.borrow().iter().map(|ty| {
|
||||||
match *ty {
|
match *ty {
|
||||||
config::CrateTypeExecutable |
|
config::CrateType::Executable |
|
||||||
config::CrateTypeStaticlib |
|
config::CrateType::Staticlib |
|
||||||
config::CrateTypeCdylib => MetadataKind::None,
|
config::CrateType::Cdylib => MetadataKind::None,
|
||||||
|
|
||||||
config::CrateTypeRlib => MetadataKind::Uncompressed,
|
config::CrateType::Rlib => MetadataKind::Uncompressed,
|
||||||
|
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeProcMacro => MetadataKind::Compressed,
|
config::CrateType::ProcMacro => MetadataKind::Compressed,
|
||||||
}
|
}
|
||||||
}).max().unwrap_or(MetadataKind::None);
|
}).max().unwrap_or(MetadataKind::None);
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ impl CrateInfo {
|
||||||
|
|
||||||
let load_wasm_items = tcx.sess.crate_types.borrow()
|
let load_wasm_items = tcx.sess.crate_types.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|c| *c != config::CrateTypeRlib) &&
|
.any(|c| *c != config::CrateType::Rlib) &&
|
||||||
tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown";
|
tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown";
|
||||||
|
|
||||||
if load_wasm_items {
|
if load_wasm_items {
|
||||||
|
|
|
@ -147,7 +147,7 @@ fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
|
||||||
|
|
||||||
fn is_any_library(sess: &Session) -> bool {
|
fn is_any_library(sess: &Session) -> bool {
|
||||||
sess.crate_types.borrow().iter().any(|ty| {
|
sess.crate_types.borrow().iter().any(|ty| {
|
||||||
*ty != config::CrateTypeExecutable
|
*ty != config::CrateType::Executable
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
|
||||||
fn init(&self, sess: &Session) {
|
fn init(&self, sess: &Session) {
|
||||||
for cty in sess.opts.crate_types.iter() {
|
for cty in sess.opts.crate_types.iter() {
|
||||||
match *cty {
|
match *cty {
|
||||||
CrateType::CrateTypeRlib | CrateType::CrateTypeDylib |
|
CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {},
|
||||||
CrateType::CrateTypeExecutable => {},
|
|
||||||
_ => {
|
_ => {
|
||||||
sess.parse_sess.span_diagnostic.warn(
|
sess.parse_sess.span_diagnostic.warn(
|
||||||
&format!("LLVM unsupported, so output type {} is not supported", cty)
|
&format!("LLVM unsupported, so output type {} is not supported", cty)
|
||||||
|
@ -201,13 +200,14 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
|
||||||
let ongoing_codegen = ongoing_codegen.downcast::<OngoingCodegen>()
|
let ongoing_codegen = ongoing_codegen.downcast::<OngoingCodegen>()
|
||||||
.expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<dyn Any>");
|
.expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<dyn Any>");
|
||||||
for &crate_type in sess.opts.crate_types.iter() {
|
for &crate_type in sess.opts.crate_types.iter() {
|
||||||
if crate_type != CrateType::CrateTypeRlib && crate_type != CrateType::CrateTypeDylib {
|
if crate_type != CrateType::Rlib &&
|
||||||
|
crate_type != CrateType::Dylib {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let output_name =
|
let output_name =
|
||||||
out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str());
|
out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str());
|
||||||
let mut compressed = ongoing_codegen.metadata_version.clone();
|
let mut compressed = ongoing_codegen.metadata_version.clone();
|
||||||
let metadata = if crate_type == CrateType::CrateTypeDylib {
|
let metadata = if crate_type == CrateType::Dylib {
|
||||||
DeflateEncoder::new(&mut compressed, Compression::fast())
|
DeflateEncoder::new(&mut compressed, Compression::fast())
|
||||||
.write_all(&ongoing_codegen.metadata.raw_data)
|
.write_all(&ongoing_codegen.metadata.raw_data)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -220,8 +220,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.abort_if_errors();
|
sess.abort_if_errors();
|
||||||
if !sess.opts.crate_types.contains(&CrateType::CrateTypeRlib)
|
if !sess.opts.crate_types.contains(&CrateType::Rlib)
|
||||||
&& !sess.opts.crate_types.contains(&CrateType::CrateTypeDylib)
|
&& !sess.opts.crate_types.contains(&CrateType::Dylib)
|
||||||
{
|
{
|
||||||
sess.fatal("Executables are not supported by the metadata-only backend.");
|
sess.fatal("Executables are not supported by the metadata-only backend.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,24 +114,24 @@ pub fn filename_for_input(sess: &Session,
|
||||||
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
|
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
|
||||||
|
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeRlib => {
|
config::CrateType::Rlib => {
|
||||||
outputs.out_directory.join(&format!("lib{}.rlib", libname))
|
outputs.out_directory.join(&format!("lib{}.rlib", libname))
|
||||||
}
|
}
|
||||||
config::CrateTypeCdylib |
|
config::CrateType::Cdylib |
|
||||||
config::CrateTypeProcMacro |
|
config::CrateType::ProcMacro |
|
||||||
config::CrateTypeDylib => {
|
config::CrateType::Dylib => {
|
||||||
let (prefix, suffix) = (&sess.target.target.options.dll_prefix,
|
let (prefix, suffix) = (&sess.target.target.options.dll_prefix,
|
||||||
&sess.target.target.options.dll_suffix);
|
&sess.target.target.options.dll_suffix);
|
||||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
|
outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
|
||||||
suffix))
|
suffix))
|
||||||
}
|
}
|
||||||
config::CrateTypeStaticlib => {
|
config::CrateType::Staticlib => {
|
||||||
let (prefix, suffix) = (&sess.target.target.options.staticlib_prefix,
|
let (prefix, suffix) = (&sess.target.target.options.staticlib_prefix,
|
||||||
&sess.target.target.options.staticlib_suffix);
|
&sess.target.target.options.staticlib_suffix);
|
||||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
|
outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
|
||||||
suffix))
|
suffix))
|
||||||
}
|
}
|
||||||
config::CrateTypeExecutable => {
|
config::CrateType::Executable => {
|
||||||
let suffix = &sess.target.target.options.exe_suffix;
|
let suffix = &sess.target.target.options.exe_suffix;
|
||||||
let out_filename = outputs.path(OutputType::Exe);
|
let out_filename = outputs.path(OutputType::Exe);
|
||||||
if suffix.is_empty() {
|
if suffix.is_empty() {
|
||||||
|
@ -148,15 +148,15 @@ pub fn filename_for_input(sess: &Session,
|
||||||
/// Default crate type is used when crate type isn't provided neither
|
/// Default crate type is used when crate type isn't provided neither
|
||||||
/// through cmd line arguments nor through crate attributes
|
/// through cmd line arguments nor through crate attributes
|
||||||
///
|
///
|
||||||
/// It is CrateTypeExecutable for all platforms but iOS as there is no
|
/// It is CrateType::Executable for all platforms but iOS as there is no
|
||||||
/// way to run iOS binaries anyway without jailbreaking and
|
/// way to run iOS binaries anyway without jailbreaking and
|
||||||
/// interaction with Rust code through static library is the only
|
/// interaction with Rust code through static library is the only
|
||||||
/// option for now
|
/// option for now
|
||||||
pub fn default_output_for_target(sess: &Session) -> config::CrateType {
|
pub fn default_output_for_target(sess: &Session) -> config::CrateType {
|
||||||
if !sess.target.target.options.executables {
|
if !sess.target.target.options.executables {
|
||||||
config::CrateTypeStaticlib
|
config::CrateType::Staticlib
|
||||||
} else {
|
} else {
|
||||||
config::CrateTypeExecutable
|
config::CrateType::Executable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,9 +164,9 @@ pub fn default_output_for_target(sess: &Session) -> config::CrateType {
|
||||||
pub fn invalid_output_for_target(sess: &Session,
|
pub fn invalid_output_for_target(sess: &Session,
|
||||||
crate_type: config::CrateType) -> bool {
|
crate_type: config::CrateType) -> bool {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeCdylib |
|
config::CrateType::Cdylib |
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeProcMacro => {
|
config::CrateType::ProcMacro => {
|
||||||
if !sess.target.target.options.dynamic_linking {
|
if !sess.target.target.options.dynamic_linking {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -178,12 +178,12 @@ pub fn invalid_output_for_target(sess: &Session,
|
||||||
}
|
}
|
||||||
if sess.target.target.options.only_cdylib {
|
if sess.target.target.options.only_cdylib {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
config::CrateTypeProcMacro | config::CrateTypeDylib => return true,
|
config::CrateType::ProcMacro | config::CrateType::Dylib => return true,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !sess.target.target.options.executables {
|
if !sess.target.target.options.executables {
|
||||||
if crate_type == config::CrateTypeExecutable {
|
if crate_type == config::CrateType::Executable {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ where
|
||||||
krate = time(sess, "maybe creating a macro crate", || {
|
krate = time(sess, "maybe creating a macro crate", || {
|
||||||
let crate_types = sess.crate_types.borrow();
|
let crate_types = sess.crate_types.borrow();
|
||||||
let num_crate_types = crate_types.len();
|
let num_crate_types = crate_types.len();
|
||||||
let is_proc_macro_crate = crate_types.contains(&config::CrateTypeProcMacro);
|
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
|
||||||
let is_test_crate = sess.opts.test;
|
let is_test_crate = sess.opts.test;
|
||||||
syntax_ext::proc_macro_registrar::modify(
|
syntax_ext::proc_macro_registrar::modify(
|
||||||
&sess.parse_sess,
|
&sess.parse_sess,
|
||||||
|
@ -1501,13 +1501,13 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
||||||
.filter_map(|a| {
|
.filter_map(|a| {
|
||||||
if a.check_name("crate_type") {
|
if a.check_name("crate_type") {
|
||||||
match a.value_str() {
|
match a.value_str() {
|
||||||
Some(ref n) if *n == "rlib" => Some(config::CrateTypeRlib),
|
Some(ref n) if *n == "rlib" => Some(config::CrateType::Rlib),
|
||||||
Some(ref n) if *n == "dylib" => Some(config::CrateTypeDylib),
|
Some(ref n) if *n == "dylib" => Some(config::CrateType::Dylib),
|
||||||
Some(ref n) if *n == "cdylib" => Some(config::CrateTypeCdylib),
|
Some(ref n) if *n == "cdylib" => Some(config::CrateType::Cdylib),
|
||||||
Some(ref n) if *n == "lib" => Some(config::default_lib_output()),
|
Some(ref n) if *n == "lib" => Some(config::default_lib_output()),
|
||||||
Some(ref n) if *n == "staticlib" => Some(config::CrateTypeStaticlib),
|
Some(ref n) if *n == "staticlib" => Some(config::CrateType::Staticlib),
|
||||||
Some(ref n) if *n == "proc-macro" => Some(config::CrateTypeProcMacro),
|
Some(ref n) if *n == "proc-macro" => Some(config::CrateType::ProcMacro),
|
||||||
Some(ref n) if *n == "bin" => Some(config::CrateTypeExecutable),
|
Some(ref n) if *n == "bin" => Some(config::CrateType::Executable),
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
session.buffer_lint(
|
session.buffer_lint(
|
||||||
lint::builtin::UNKNOWN_CRATE_TYPES,
|
lint::builtin::UNKNOWN_CRATE_TYPES,
|
||||||
|
@ -1534,7 +1534,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
|
// If we're generating a test executable, then ignore all other output
|
||||||
// styles at all other locations
|
// styles at all other locations
|
||||||
if session.opts.test {
|
if session.opts.test {
|
||||||
return vec![config::CrateTypeExecutable];
|
return vec![config::CrateType::Executable];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only check command line flags if present. If no types are specified by
|
// Only check command line flags if present. If no types are specified by
|
||||||
|
@ -1598,7 +1598,7 @@ pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator {
|
||||||
let is_exe = session
|
let is_exe = session
|
||||||
.crate_types
|
.crate_types
|
||||||
.borrow()
|
.borrow()
|
||||||
.contains(&config::CrateTypeExecutable);
|
.contains(&config::CrateType::Executable);
|
||||||
hasher.write(if is_exe { b"exe" } else { b"lib" });
|
hasher.write(if is_exe { b"exe" } else { b"lib" });
|
||||||
|
|
||||||
CrateDisambiguator::from(hasher.finish())
|
CrateDisambiguator::from(hasher.finish())
|
||||||
|
|
|
@ -627,7 +627,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
// If we're only compiling an rlib, then there's no need to select a
|
// If we're only compiling an rlib, then there's no need to select a
|
||||||
// panic runtime, so we just skip this section entirely.
|
// panic runtime, so we just skip this section entirely.
|
||||||
let any_non_rlib = self.sess.crate_types.borrow().iter().any(|ct| {
|
let any_non_rlib = self.sess.crate_types.borrow().iter().any(|ct| {
|
||||||
*ct != config::CrateTypeRlib
|
*ct != config::CrateType::Rlib
|
||||||
});
|
});
|
||||||
if !any_non_rlib {
|
if !any_non_rlib {
|
||||||
info!("panic runtime injection skipped, only generating rlib");
|
info!("panic runtime injection skipped, only generating rlib");
|
||||||
|
@ -738,13 +738,13 @@ impl<'a> CrateLoader<'a> {
|
||||||
if !self.sess.crate_types.borrow().iter().all(|ct| {
|
if !self.sess.crate_types.borrow().iter().all(|ct| {
|
||||||
match *ct {
|
match *ct {
|
||||||
// Link the runtime
|
// Link the runtime
|
||||||
config::CrateTypeStaticlib |
|
config::CrateType::Staticlib |
|
||||||
config::CrateTypeExecutable => true,
|
config::CrateType::Executable => true,
|
||||||
// This crate will be compiled with the required
|
// This crate will be compiled with the required
|
||||||
// instrumentation pass
|
// instrumentation pass
|
||||||
config::CrateTypeRlib |
|
config::CrateType::Rlib |
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeCdylib =>
|
config::CrateType::Cdylib =>
|
||||||
false,
|
false,
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.err(&format!("Only executables, staticlibs, \
|
self.sess.err(&format!("Only executables, staticlibs, \
|
||||||
|
@ -760,10 +760,10 @@ impl<'a> CrateLoader<'a> {
|
||||||
if !self.sess.crate_types.borrow().iter().all(|ct| {
|
if !self.sess.crate_types.borrow().iter().all(|ct| {
|
||||||
match *ct {
|
match *ct {
|
||||||
// Link the runtime
|
// Link the runtime
|
||||||
config::CrateTypeExecutable => true,
|
config::CrateType::Executable => true,
|
||||||
// This crate will be compiled with the required
|
// This crate will be compiled with the required
|
||||||
// instrumentation pass
|
// instrumentation pass
|
||||||
config::CrateTypeRlib => false,
|
config::CrateType::Rlib => false,
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.err(&format!("Only executables and rlibs can be \
|
self.sess.err(&format!("Only executables and rlibs can be \
|
||||||
compiled with `-Z sanitizer`"));
|
compiled with `-Z sanitizer`"));
|
||||||
|
@ -853,12 +853,12 @@ impl<'a> CrateLoader<'a> {
|
||||||
let mut need_exe_alloc = false;
|
let mut need_exe_alloc = false;
|
||||||
for ct in self.sess.crate_types.borrow().iter() {
|
for ct in self.sess.crate_types.borrow().iter() {
|
||||||
match *ct {
|
match *ct {
|
||||||
config::CrateTypeExecutable => need_exe_alloc = true,
|
config::CrateType::Executable => need_exe_alloc = true,
|
||||||
config::CrateTypeDylib |
|
config::CrateType::Dylib |
|
||||||
config::CrateTypeProcMacro |
|
config::CrateType::ProcMacro |
|
||||||
config::CrateTypeCdylib |
|
config::CrateType::Cdylib |
|
||||||
config::CrateTypeStaticlib => need_lib_alloc = true,
|
config::CrateType::Staticlib => need_lib_alloc = true,
|
||||||
config::CrateTypeRlib => {}
|
config::CrateType::Rlib => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !need_lib_alloc && !need_exe_alloc {
|
if !need_lib_alloc && !need_exe_alloc {
|
||||||
|
|
|
@ -28,7 +28,7 @@ use rustc::traits::specialization_graph;
|
||||||
use rustc::ty::{self, Ty, TyCtxt, ReprOptions, SymbolName};
|
use rustc::ty::{self, Ty, TyCtxt, ReprOptions, SymbolName};
|
||||||
use rustc::ty::codec::{self as ty_codec, TyEncoder};
|
use rustc::ty::codec::{self as ty_codec, TyEncoder};
|
||||||
|
|
||||||
use rustc::session::config::{self, CrateTypeProcMacro};
|
use rustc::session::config::{self, CrateType};
|
||||||
use rustc::util::nodemap::FxHashMap;
|
use rustc::util::nodemap::FxHashMap;
|
||||||
|
|
||||||
use rustc_data_structures::stable_hasher::StableHasher;
|
use rustc_data_structures::stable_hasher::StableHasher;
|
||||||
|
@ -478,7 +478,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
let attrs = tcx.hir.krate_attrs();
|
let attrs = tcx.hir.krate_attrs();
|
||||||
let link_meta = self.link_meta;
|
let link_meta = self.link_meta;
|
||||||
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
|
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro);
|
||||||
let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
|
let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
|
||||||
let has_global_allocator = *tcx.sess.has_global_allocator.get();
|
let has_global_allocator = *tcx.sess.has_global_allocator.get();
|
||||||
|
|
||||||
|
@ -1542,7 +1542,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_dylib_dependency_formats(&mut self, _: ()) -> LazySeq<Option<LinkagePreference>> {
|
fn encode_dylib_dependency_formats(&mut self, _: ()) -> LazySeq<Option<LinkagePreference>> {
|
||||||
match self.tcx.sess.dependency_formats.borrow().get(&config::CrateTypeDylib) {
|
match self.tcx.sess.dependency_formats.borrow().get(&config::CrateType::Dylib) {
|
||||||
Some(arr) => {
|
Some(arr) => {
|
||||||
self.lazy_seq(arr.iter().map(|slot| {
|
self.lazy_seq(arr.iter().map(|slot| {
|
||||||
match *slot {
|
match *slot {
|
||||||
|
|
|
@ -44,7 +44,7 @@ use rustc::hir::def::Def as HirDef;
|
||||||
use rustc::hir::map::{Node, NodeTraitItem, NodeImplItem};
|
use rustc::hir::map::{Node, NodeTraitItem, NodeImplItem};
|
||||||
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||||
use rustc::middle::cstore::ExternCrate;
|
use rustc::middle::cstore::ExternCrate;
|
||||||
use rustc::session::config::CrateType::CrateTypeExecutable;
|
use rustc::session::config::CrateType;
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt};
|
||||||
use rustc_typeck::hir_ty_to_ty;
|
use rustc_typeck::hir_ty_to_ty;
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ impl<'a> DumpHandler<'a> {
|
||||||
let executable = sess.crate_types
|
let executable = sess.crate_types
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|ct| *ct == CrateTypeExecutable);
|
.any(|ct| *ct == CrateType::Executable);
|
||||||
let mut out_name = if executable {
|
let mut out_name = if executable {
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -223,7 +223,7 @@ pub fn run_core(search_paths: SearchPaths,
|
||||||
let sessopts = config::Options {
|
let sessopts = config::Options {
|
||||||
maybe_sysroot,
|
maybe_sysroot,
|
||||||
search_paths,
|
search_paths,
|
||||||
crate_types: vec![config::CrateTypeRlib],
|
crate_types: vec![config::CrateType::Rlib],
|
||||||
lint_opts: if !allow_warnings {
|
lint_opts: if !allow_warnings {
|
||||||
lints
|
lints
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn run(input_path: &Path,
|
||||||
maybe_sysroot: maybe_sysroot.clone().or_else(
|
maybe_sysroot: maybe_sysroot.clone().or_else(
|
||||||
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
|
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
|
||||||
search_paths: libs.clone(),
|
search_paths: libs.clone(),
|
||||||
crate_types: vec![config::CrateTypeDylib],
|
crate_types: vec![config::CrateType::Dylib],
|
||||||
cg: cg.clone(),
|
cg: cg.clone(),
|
||||||
externs: externs.clone(),
|
externs: externs.clone(),
|
||||||
unstable_features: UnstableFeatures::from_environment(),
|
unstable_features: UnstableFeatures::from_environment(),
|
||||||
|
@ -216,7 +216,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
|
||||||
maybe_sysroot: maybe_sysroot.or_else(
|
maybe_sysroot: maybe_sysroot.or_else(
|
||||||
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
|
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
|
||||||
search_paths: libs,
|
search_paths: libs,
|
||||||
crate_types: vec![config::CrateTypeExecutable],
|
crate_types: vec![config::CrateType::Executable],
|
||||||
output_types: outputs,
|
output_types: outputs,
|
||||||
externs,
|
externs,
|
||||||
cg: config::CodegenOptions {
|
cg: config::CodegenOptions {
|
||||||
|
|
|
@ -63,7 +63,7 @@ impl CodegenBackend for TheBackend {
|
||||||
let crate_name = ongoing_codegen.downcast::<Symbol>()
|
let crate_name = ongoing_codegen.downcast::<Symbol>()
|
||||||
.expect("in join_codegen_and_link: ongoing_codegen is not a Symbol");
|
.expect("in join_codegen_and_link: ongoing_codegen is not a Symbol");
|
||||||
for &crate_type in sess.opts.crate_types.iter() {
|
for &crate_type in sess.opts.crate_types.iter() {
|
||||||
if crate_type != CrateType::CrateTypeRlib {
|
if crate_type != CrateType::Rlib {
|
||||||
sess.fatal(&format!("Crate type is {:?}", crate_type));
|
sess.fatal(&format!("Crate type is {:?}", crate_type));
|
||||||
}
|
}
|
||||||
let output_name =
|
let output_name =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue