Skip to content

Commit df3776b

Browse files
committed
allow wasm32 compilation of librustc_data_structures/profiling.rs
1 parent 20fc02f commit df3776b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/librustc_data_structures/profiling.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ use parking_lot::RwLock;
9999

100100
/// MmapSerializatioSink is faster on macOS and Linux
101101
/// but FileSerializationSink is faster on Windows
102-
#[cfg(not(windows))]
102+
#[cfg(all(not(windows),not(target_arch="wasm32")))]
103103
type SerializationSink = measureme::MmapSerializationSink;
104-
#[cfg(windows)]
104+
#[cfg(all(windows,not(target_arch="wasm32")))]
105105
type SerializationSink = measureme::FileSerializationSink;
106+
#[cfg(target_arch="wasm32")]
107+
type SerializationSink = measureme::ByteVecSink;
106108

107109
type Profiler = measureme::Profiler<SerializationSink>;
108110

@@ -602,7 +604,7 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
602604
}
603605

604606
// Memory reporting
605-
#[cfg(unix)]
607+
#[cfg(all(unix,not(target_arch="wasm32")))]
606608
fn get_resident() -> Option<usize> {
607609
let field = 1;
608610
let contents = fs::read("/proc/self/statm").ok()?;
@@ -612,7 +614,7 @@ fn get_resident() -> Option<usize> {
612614
Some(npages * 4096)
613615
}
614616

615-
#[cfg(windows)]
617+
#[cfg(all(windows,not(target_arch="wasm32")))]
616618
fn get_resident() -> Option<usize> {
617619
use std::mem::{self, MaybeUninit};
618620
use winapi::shared::minwindef::DWORD;
@@ -630,3 +632,8 @@ fn get_resident() -> Option<usize> {
630632
}
631633
}
632634
}
635+
636+
#[cfg(target_arch="wasm32")]
637+
fn get_resident() -> Option<usize> {
638+
None
639+
}

0 commit comments

Comments
 (0)