[llvm-branch-commits] [compiler-rt] 5fd26fb - Patches from emscripten 3.1.20

Sam Clegg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 6 02:21:56 PDT 2022


Author: Sam Clegg
Date: 2022-09-06T02:21:33-07:00
New Revision: 5fd26fb4fcb1657bff8fc489cf6cd8628993f71c

URL: https://github.com/llvm/llvm-project/commit/5fd26fb4fcb1657bff8fc489cf6cd8628993f71c
DIFF: https://github.com/llvm/llvm-project/commit/5fd26fb4fcb1657bff8fc489cf6cd8628993f71c.diff

LOG: Patches from emscripten 3.1.20

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_globals.cpp
    compiler-rt/lib/lsan/lsan_interceptors.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_globals.cpp b/compiler-rt/lib/asan/asan_globals.cpp
index ecc2600f039a1..fa050988e5351 100644
--- a/compiler-rt/lib/asan/asan_globals.cpp
+++ b/compiler-rt/lib/asan/asan_globals.cpp
@@ -315,6 +315,7 @@ void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) {
 // ---------------------- Interface ---------------- {{{1
 using namespace __asan;
 
+#if !SANITIZER_EMSCRIPTEN
 // Apply __asan_register_globals to all globals found in the same loaded
 // executable or shared library as `flag'. The flag tracks whether globals have
 // already been registered or not for this image.
@@ -352,6 +353,7 @@ void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop) {
   __asan_unregister_globals(globals_start, globals_stop - globals_start);
   *flag = 0;
 }
+#endif
 
 // Register an array of globals.
 void __asan_register_globals(__asan_global *globals, uptr n) {

diff  --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index c7032032ff9a7..00c0428f4a8bb 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -32,6 +32,17 @@
 #include "lsan_common.h"
 #include "lsan_thread.h"
 
+#if SANITIZER_EMSCRIPTEN
+#define __ATTRP_C11_THREAD ((void*)(uptr)-1)
+#include <emscripten/heap.h>
+extern "C" {
+int emscripten_builtin_pthread_create(void *thread, void *attr,
+                                      void *(*callback)(void *), void *arg);
+int emscripten_builtin_pthread_join(void *th, void **ret);
+int emscripten_builtin_pthread_detach(void *th);
+}
+#endif
+
 #include <stddef.h>
 
 using namespace __lsan;
@@ -403,18 +414,6 @@ INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void (*parent)(),
 #define LSAN_MAYBE_INTERCEPT_PTHREAD_ATFORK
 #endif
 
-#if SANITIZER_EMSCRIPTEN
-#define __ATTRP_C11_THREAD ((void*)(uptr)-1)
-extern "C" {
-  int emscripten_builtin_pthread_create(void *thread, void *attr,
-                                        void *(*callback)(void *), void *arg);
-  int emscripten_builtin_pthread_join(void *th, void **ret);
-  int emscripten_builtin_pthread_detach(void *th);
-  void *emscripten_builtin_malloc(size_t size);
-  void emscripten_builtin_free(void *);
-}
-#endif
-
 #if SANITIZER_INTERCEPT_STRERROR
 INTERCEPTOR(char *, strerror, int errnum) {
   __lsan::ScopedInterceptorDisabler disabler;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index c4cc0e45193ea..c64b0955b78c5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -78,6 +78,7 @@ void *BackgroundThread(void *arg) {
   }
 }
 
+#if !SANITIZER_EMSCRIPTEN
 void MaybeStartBackgroudThread() {
   // Need to implement/test on other platforms.
   // Start the background thread if one of the rss limits is given.
@@ -110,6 +111,7 @@ static struct BackgroudThreadStarted {
 #else
 void MaybeStartBackgroudThread() {}
 #endif
+#endif
 
 void WriteToSyslog(const char *msg) {
   InternalScopedString msg_copy;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index ef0b0167fb3a6..33e7f017aac83 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -59,7 +59,7 @@
 #include <signal.h>
 #include <sys/mman.h>
 #include <sys/param.h>
-#if !SANITIZER_SOLARIS
+#if !SANITIZER_SOLARIS && !SANITIZER_EMSCRIPTEN
 #include <sys/ptrace.h>
 #endif
 #include <sys/resource.h>
@@ -596,7 +596,9 @@ u64 NanoTime() {
 #endif
 
 #if SANITIZER_EMSCRIPTEN
+extern "C" {
 int __clock_gettime(__sanitizer_clockid_t clk_id, void *tp);
+}
 
 uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) {
   return __clock_gettime(clk_id, tp);
@@ -1850,7 +1852,7 @@ HandleSignalMode GetHandleSignalMode(int signum) {
   return result;
 }
 
-#if !SANITIZER_GO
+#if !SANITIZER_GO && !SANITIZER_EMSCRIPTEN
 void *internal_start_thread(void *(*func)(void *arg), void *arg) {
   if (&real_pthread_create == 0)
     return nullptr;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 4ccd2e8281080..ce1212aba3145 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -899,6 +899,7 @@ u64 MonotonicNanoTime() {
 }
 #endif  // SANITIZER_GLIBC && !SANITIZER_GO
 
+#if !SANITIZER_EMSCRIPTEN
 void ReExec() {
   const char *pathname = "/proc/self/exe";
 
@@ -930,6 +931,7 @@ void ReExec() {
   Printf("execve failed, errno %d\n", rverrno);
   Die();
 }
+#endif
 
 void UnmapFromTo(uptr from, uptr to) {
   if (to == from)

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index 6fef032f542bb..f5dbf909239f0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -429,6 +429,7 @@ void AdjustStackSize(void *attr_) {
 }
 #endif // !SANITIZER_GO
 
+#if !SANITIZER_EMSCRIPTEN
 pid_t StartSubprocess(const char *program, const char *const argv[],
                       const char *const envp[], fd_t stdin_fd, fd_t stdout_fd,
                       fd_t stderr_fd) {
@@ -503,6 +504,7 @@ int WaitForProcess(pid_t pid) {
   }
   return process_status;
 }
+#endif
 
 bool IsStateDetached(int state) {
   return state == PTHREAD_CREATE_DETACHED;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
index df122ed3425c3..b8de41214842e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
@@ -74,6 +74,7 @@ class SymbolizerTool {
   ~SymbolizerTool() {}
 };
 
+#if !SANITIZER_EMSCRIPTEN
 // SymbolizerProcess encapsulates communication between the tool and
 // external symbolizer program, running in a 
diff erent subprocess.
 // SymbolizerProcess may not be used from two threads simultaneously.
@@ -145,6 +146,7 @@ class LLVMSymbolizer final : public SymbolizerTool {
   static const uptr kBufferSize = 16 * 1024;
   char buffer_[kBufferSize];
 };
+#endif
 
 // Parses one or more two-line strings in the following format:
 //   <function_name>

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
index 8bbd4af0c7c27..bc8796e6469fd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
@@ -224,6 +224,7 @@ const LoadedModule *Symbolizer::FindModuleForAddress(uptr address) {
   return module;
 }
 
+#if !SANITIZER_EMSCRIPTEN
 // For now we assume the following protocol:
 // For each request of the form
 //   <module_name> <module_offset>
@@ -551,6 +552,7 @@ bool SymbolizerProcess::WriteToSymbolizer(const char *buffer, uptr length) {
   }
   return true;
 }
+#endif
 
 #endif  // !SANITIZER_SYMBOLIZER_MARKUP
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index b39b4d8400fe7..273bbdc4d9a75 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -201,6 +201,7 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
   return true;
 }
 
+#if !SANITIZER_EMSCRIPTEN
 class Addr2LineProcess final : public SymbolizerProcess {
  public:
   Addr2LineProcess(const char *path, const char *module_name)
@@ -316,6 +317,7 @@ class Addr2LinePool final : public SymbolizerTool {
   static const uptr dummy_address_ =
       FIRST_32_SECOND_64(UINT32_MAX, UINT64_MAX);
 };
+#endif
 
 #  if SANITIZER_SUPPORTS_WEAK_HOOKS
 extern "C" {


        


More information about the llvm-branch-commits mailing list