From df3776bc0f7f250a7650fcaea67ac4a869cbcb80 Mon Sep 17 00:00:00 2001 From: Cameron Taggart Date: Mon, 20 Apr 2020 18:09:11 -0600 Subject: [PATCH] allow wasm32 compilation of librustc_data_structures/profiling.rs --- src/librustc_data_structures/profiling.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustc_data_structures/profiling.rs b/src/librustc_data_structures/profiling.rs index 23f3558cbdfa..7377b7a6c8bb 100644 --- a/src/librustc_data_structures/profiling.rs +++ b/src/librustc_data_structures/profiling.rs @@ -99,10 +99,12 @@ use parking_lot::RwLock; /// MmapSerializatioSink is faster on macOS and Linux /// but FileSerializationSink is faster on Windows -#[cfg(not(windows))] +#[cfg(all(not(windows),not(target_arch="wasm32")))] type SerializationSink = measureme::MmapSerializationSink; -#[cfg(windows)] +#[cfg(all(windows,not(target_arch="wasm32")))] type SerializationSink = measureme::FileSerializationSink; +#[cfg(target_arch="wasm32")] +type SerializationSink = measureme::ByteVecSink; type Profiler = measureme::Profiler; @@ -602,7 +604,7 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String { } // Memory reporting -#[cfg(unix)] +#[cfg(all(unix,not(target_arch="wasm32")))] fn get_resident() -> Option { let field = 1; let contents = fs::read("/proc/self/statm").ok()?; @@ -612,7 +614,7 @@ fn get_resident() -> Option { Some(npages * 4096) } -#[cfg(windows)] +#[cfg(all(windows,not(target_arch="wasm32")))] fn get_resident() -> Option { use std::mem::{self, MaybeUninit}; use winapi::shared::minwindef::DWORD; @@ -630,3 +632,8 @@ fn get_resident() -> Option { } } } + +#[cfg(target_arch="wasm32")] +fn get_resident() -> Option { + None +}