From 285144a8def18534daf2a1a66baf9e89248e0f63 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 14 Nov 2019 12:16:24 -0500 Subject: [PATCH] Move NativeLibraryKind to rustc_session --- src/librustc/middle/cstore.rs | 16 +--------------- src/librustc/session/config.rs | 27 +++++++++++++++------------ src/librustc_session/utils.rs | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 44c6f6b07f5..324b01316fa 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -20,6 +20,7 @@ use rustc_target::spec::Target; use rustc_data_structures::sync::{self, MetadataRef}; use rustc_macros::HashStable; +pub use rustc_session::utils::NativeLibraryKind; pub use self::NativeLibraryKind::*; // lonely orphan structs and enums looking for a better home @@ -94,21 +95,6 @@ pub enum LinkagePreference { RequireStatic, } -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, - RustcEncodable, RustcDecodable, HashStable)] -pub enum NativeLibraryKind { - /// native static library (.a archive) - NativeStatic, - /// native static library, which doesn't get bundled into .rlibs - NativeStaticNobundle, - /// macOS-specific - NativeFramework, - /// Windows dynamic library without import library. - NativeRawDylib, - /// default way to specify a dynamic library - NativeUnknown, -} - #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct NativeLibrary { pub kind: NativeLibraryKind, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 6a6ed3260de..1aea224e566 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -2,7 +2,7 @@ //! command-line options. use rustc_session::lint; -use crate::middle::cstore; +use rustc_session::utils::NativeLibraryKind; use crate::session::{early_error, early_warn, Session}; use crate::session::search_paths::SearchPath; @@ -415,7 +415,7 @@ top_level_options!( describe_lints: bool [UNTRACKED], output_types: OutputTypes [TRACKED], search_paths: Vec [UNTRACKED], - libs: Vec<(String, Option, Option)> [TRACKED], + libs: Vec<(String, Option, Option)> [TRACKED], maybe_sysroot: Option [UNTRACKED], target_triple: TargetTriple [TRACKED], @@ -2379,7 +2379,7 @@ fn select_debuginfo( fn parse_libs( matches: &getopts::Matches, error_format: ErrorOutputType, -) -> Vec<(String, Option, Option)> { +) -> Vec<(String, Option, Option)> { matches .opt_strs("l") .into_iter() @@ -2390,10 +2390,12 @@ fn parse_libs( let kind = parts.next().unwrap(); let (name, kind) = match (parts.next(), kind) { (None, name) => (name, None), - (Some(name), "dylib") => (name, Some(cstore::NativeUnknown)), - (Some(name), "framework") => (name, Some(cstore::NativeFramework)), - (Some(name), "static") => (name, Some(cstore::NativeStatic)), - (Some(name), "static-nobundle") => (name, Some(cstore::NativeStaticNobundle)), + (Some(name), "dylib") => (name, Some(NativeLibraryKind::NativeUnknown)), + (Some(name), "framework") => (name, Some(NativeLibraryKind::NativeFramework)), + (Some(name), "static") => (name, Some(NativeLibraryKind::NativeStatic)), + (Some(name), "static-nobundle") => { + (name, Some(NativeLibraryKind::NativeStaticNobundle)) + } (_, s) => { early_error( error_format, @@ -2405,7 +2407,8 @@ fn parse_libs( ); } }; - if kind == Some(cstore::NativeStaticNobundle) && !nightly_options::is_nightly_build() { + if kind == Some(NativeLibraryKind::NativeStaticNobundle) && + !nightly_options::is_nightly_build() { early_error( error_format, &format!( @@ -2855,7 +2858,7 @@ impl PpMode { /// how the hash should be calculated when adding a new command-line argument. mod dep_tracking { use rustc_session::lint; - use crate::middle::cstore; + use rustc_session::utils::NativeLibraryKind; use std::collections::BTreeMap; use std::hash::Hash; use std::path::PathBuf; @@ -2913,7 +2916,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); - impl_dep_tracking_hash_via_hash!(Option); + impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(CrateType); impl_dep_tracking_hash_via_hash!(MergeFunctions); impl_dep_tracking_hash_via_hash!(PanicStrategy); @@ -2924,7 +2927,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(DebugInfo); impl_dep_tracking_hash_via_hash!(UnstableFeatures); impl_dep_tracking_hash_via_hash!(OutputTypes); - impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); + impl_dep_tracking_hash_via_hash!(NativeLibraryKind); impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(TargetTriple); @@ -2940,7 +2943,7 @@ mod dep_tracking { impl_dep_tracking_hash_for_sortable_vec_of!(( String, Option, - Option + Option )); impl_dep_tracking_hash_for_sortable_vec_of!((String, u64)); impl_dep_tracking_hash_for_sortable_vec_of!(Sanitizer); diff --git a/src/librustc_session/utils.rs b/src/librustc_session/utils.rs index a1b067209e0..ad593398a52 100644 --- a/src/librustc_session/utils.rs +++ b/src/librustc_session/utils.rs @@ -7,3 +7,19 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String { format!("{:.3}", secs) } + +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +pub enum NativeLibraryKind { + /// native static library (.a archive) + NativeStatic, + /// native static library, which doesn't get bundled into .rlibs + NativeStaticNobundle, + /// macOS-specific + NativeFramework, + /// Windows dynamic library without import library. + NativeRawDylib, + /// default way to specify a dynamic library + NativeUnknown, +} + +rustc_data_structures::impl_stable_hash_via_hash!(NativeLibraryKind);