-
-
Save anp/590645a26a4d469abe04bf7b9c5e57de to your computer and use it in GitHub Desktop.
profiler_builtins support wasi maybe?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/library/profiler_builtins/build.rs b/library/profiler_builtins/build.rs | |
index 7d5c601df53..fdd41522852 100644 | |
--- a/library/profiler_builtins/build.rs | |
+++ b/library/profiler_builtins/build.rs | |
@@ -72,6 +72,15 @@ fn main() { | |
cfg.define("COMPILER_RT_HAS_ATOMICS", Some("1")); | |
} | |
+ if let Ok(sysroot) = env::var("CARGO_CFG_WASI_SYSROOT") { | |
+ cfg.flag(&format!("--sysroot={}", sysroot)) | |
+ .define("_WASI_EMULATED_MMAN", None) | |
+ .flag("-lwasi-emulated-mman"); | |
+ } else { | |
+ // FIXME this is almost certianly broken for windows | |
+ cfg.define("COMPILER_RT_HAS_FORK", None); | |
+ } | |
+ | |
// Note that this should exist if we're going to run (otherwise we just | |
// don't build profiler builtins at all). | |
let root = Path::new("../../src/llvm-project/compiler-rt"); | |
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs | |
index 34002019a6f..25a8b051678 100644 | |
--- a/src/bootstrap/compile.rs | |
+++ b/src/bootstrap/compile.rs | |
@@ -274,8 +274,12 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car | |
if target.ends_with("-wasi") { | |
if let Some(p) = builder.wasi_root(target) { | |
- let root = format!("native={}/lib/wasm32-wasi", p.to_str().unwrap()); | |
- cargo.rustflag("-L").rustflag(&root); | |
+ let path = p.to_str().unwrap(); | |
+ let root = format!("native={}/lib/wasm32-wasi", path); | |
+ cargo | |
+ .rustflag("-L") | |
+ .rustflag(&root) | |
+ .env("CARGO_CFG_WASI_SYSROOT", path); | |
} | |
} | |
} | |
Submodule src/llvm-project contains modified content | |
diff --git a/src/llvm-project/compiler-rt/lib/profile/CMakeLists.txt b/src/llvm-project/compiler-rt/lib/profile/CMakeLists.txt | |
index 29c6c02f2d03..784f72324010 100644 | |
--- a/src/llvm-project/compiler-rt/lib/profile/CMakeLists.txt | |
+++ b/src/llvm-project/compiler-rt/lib/profile/CMakeLists.txt | |
@@ -38,6 +38,15 @@ int main() { | |
" COMPILER_RT_TARGET_HAS_FCNTL_LCK) | |
+CHECK_CXX_SOURCE_COMPILES(" | |
+#include <unistd.h> | |
+int main() { | |
+ pid_t pid = fork(); | |
+ return 0; | |
+} | |
+ | |
+" COMPILER_RT_TARGET_HAS_FORK) | |
+ | |
CHECK_CXX_SOURCE_COMPILES(" | |
#include <sys/utsname.h> | |
int main() { | |
@@ -96,7 +105,7 @@ if(COMPILER_RT_TARGET_HAS_ATOMICS) | |
set(EXTRA_FLAGS | |
${EXTRA_FLAGS} | |
-DCOMPILER_RT_HAS_ATOMICS=1) | |
-endif() | |
+endif() | |
if(COMPILER_RT_TARGET_HAS_FCNTL_LCK) | |
set(EXTRA_FLAGS | |
@@ -104,6 +113,12 @@ if(COMPILER_RT_TARGET_HAS_FCNTL_LCK) | |
-DCOMPILER_RT_HAS_FCNTL_LCK=1) | |
endif() | |
+if(COMPILER_RT_TARGET_HAS_FORK) | |
+ set(EXTRA_FLAGS | |
+ ${EXTRA_FLAGS} | |
+ -DCOMPILER_RT_HAS_FORK=1) | |
+endif() | |
+ | |
if(COMPILER_RT_TARGET_HAS_UNAME) | |
set(EXTRA_FLAGS | |
${EXTRA_FLAGS} | |
diff --git a/src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c b/src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c | |
index 82369357e986..b68bce5b6517 100644 | |
--- a/src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c | |
+++ b/src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c | |
@@ -665,6 +665,7 @@ void llvm_reset_counters(void) { | |
} | |
} | |
+#ifdef COMPILER_RT_HAS_FORK | |
#if !defined(_WIN32) | |
COMPILER_RT_VISIBILITY | |
pid_t __gcov_fork() { | |
@@ -683,6 +684,7 @@ pid_t __gcov_fork() { | |
return pid; | |
} | |
#endif | |
+#endif | |
COMPILER_RT_VISIBILITY | |
void llvm_gcov_init(fn_ptr wfn, fn_ptr ffn, fn_ptr rfn) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment