]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_session/utils.rs
Rollup merge of #68024 - petrochenkov:recoverall, r=Centril
[rust.git] / src / librustc_session / utils.rs
index a1b067209e0ed233fd8c84d52edfc26f5ef13593..7806f5e8753f22b9fcea1275ecabcf33e7571ca1 100644 (file)
@@ -1,9 +1,27 @@
-// Hack up our own formatting for the duration to make it easier for scripts
-// to parse (always use the same number of decimal places and the same unit).
-pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
-    const NANOS_PER_SEC: f64 = 1_000_000_000.0;
-    let secs = dur.as_secs() as f64 +
-               dur.subsec_nanos() as f64 / NANOS_PER_SEC;
+use crate::session::Session;
+use rustc_data_structures::profiling::VerboseTimingGuard;
 
-    format!("{:.3}", secs)
+impl Session {
+    pub fn timer<'a>(&'a self, what: &'a str) -> VerboseTimingGuard<'a> {
+        self.prof.sparse_pass(what)
+    }
+    pub fn time<R>(&self, what: &str, f: impl FnOnce() -> R) -> R {
+        self.prof.sparse_pass(what).run(f)
+    }
 }
+
+#[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);