From 79f3dec06eb5adcc151a68947803f055e1679666 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Tue, 15 Aug 2023 10:03:11 -0700 Subject: PR #1509: Allow building when targeting WASI Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1509 WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it. Merge ec9fa081609687035005dfdafd312754f31c3fbb into 861e53c8f075c8c4d67bd4c82217c57239fc97cf Merging this change closes #1509 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1509 from anuraaga:wasi-sdk-build ec9fa081609687035005dfdafd312754f31c3fbb PiperOrigin-RevId: 557166498 Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232 --- absl/base/internal/thread_identity.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'absl/base/internal/thread_identity.cc') diff --git a/absl/base/internal/thread_identity.cc b/absl/base/internal/thread_identity.cc index 252443eb..0471a25d 100644 --- a/absl/base/internal/thread_identity.cc +++ b/absl/base/internal/thread_identity.cc @@ -16,8 +16,12 @@ #if !defined(_WIN32) || defined(__MINGW32__) #include +#ifndef __wasi__ +// WASI does not provide this header, either way we disable use +// of signals with it below. #include #endif +#endif #include #include @@ -80,10 +84,12 @@ void SetCurrentThreadIdentity(ThreadIdentity* identity, absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey, reclaimer); -#if defined(__EMSCRIPTEN__) || defined(__MINGW32__) || defined(__hexagon__) - // Emscripten and MinGW pthread implementations does not support signals. - // See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html - // for more information. +#if defined(__wasi__) || defined(__EMSCRIPTEN__) || defined(__MINGW32__) || \ + defined(__hexagon__) + // Emscripten, WASI and MinGW pthread implementations does not support + // signals. See + // https://kripken.github.io/emscripten-site/docs/porting/pthreads.html for + // more information. pthread_setspecific(thread_identity_pthread_key, reinterpret_cast(identity)); #else -- cgit v1.2.3