mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
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. Mergeec9fa08160into861e53c8f0Merging this change closes #1509 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1509 from anuraaga:wasi-sdk-buildec9fa08160PiperOrigin-RevId: 557166498 Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232
This commit is contained in:
committed by
Copybara-Service
parent
32f414f4f7
commit
79f3dec06e
@@ -332,8 +332,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
||||
#error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
|
||||
#elif defined(__SIZEOF_INT128__)
|
||||
#if (defined(__clang__) && !defined(_WIN32)) || \
|
||||
(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
|
||||
#if (defined(__clang__) && !defined(_WIN32)) || \
|
||||
(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
|
||||
#define ABSL_HAVE_INTRINSIC_INT128 1
|
||||
#elif defined(__CUDACC__)
|
||||
@@ -395,7 +395,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
// Windows _WIN32
|
||||
// NaCL __native_client__
|
||||
// AsmJS __asmjs__
|
||||
// WebAssembly __wasm__
|
||||
// WebAssembly (Emscripten) __EMSCRIPTEN__
|
||||
// Fuchsia __Fuchsia__
|
||||
//
|
||||
// Note that since Android defines both __ANDROID__ and __linux__, one
|
||||
@@ -407,11 +407,11 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
// POSIX.1-2001.
|
||||
#ifdef ABSL_HAVE_MMAP
|
||||
#error ABSL_HAVE_MMAP cannot be directly set
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||
defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
|
||||
defined(__asmjs__) || defined(__wasm__) || defined(__Fuchsia__) || \
|
||||
defined(__sun) || defined(__ASYLO__) || defined(__myriad2__) || \
|
||||
defined(__HAIKU__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||
defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
|
||||
defined(__asmjs__) || defined(__EMSCRIPTEN__) || defined(__Fuchsia__) || \
|
||||
defined(__sun) || defined(__ASYLO__) || defined(__myriad2__) || \
|
||||
defined(__HAIKU__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
|
||||
defined(__QNX__) || defined(__VXWORKS__) || defined(__hexagon__)
|
||||
#define ABSL_HAVE_MMAP 1
|
||||
#endif
|
||||
@@ -484,6 +484,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
// https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
// emscripten doesn't support signals
|
||||
#elif defined(__wasi__)
|
||||
// WASI doesn't support signals
|
||||
#elif defined(__Fuchsia__)
|
||||
// Signals don't exist on fuchsia.
|
||||
#elif defined(__native_client__)
|
||||
@@ -536,14 +538,14 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
// and
|
||||
// https://github.com/llvm/llvm-project/commit/0bc451e7e137c4ccadcd3377250874f641ca514a
|
||||
// The second has the actually correct versions, thus, is what we copy here.
|
||||
#if defined(__APPLE__) && \
|
||||
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
|
||||
#if defined(__APPLE__) && \
|
||||
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
|
||||
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
|
||||
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))
|
||||
#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
|
||||
#else
|
||||
@@ -566,7 +568,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
// Checks whether C++17 std::optional is available.
|
||||
#ifdef ABSL_HAVE_STD_OPTIONAL
|
||||
#error "ABSL_HAVE_STD_OPTIONAL cannot be directly set."
|
||||
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
|
||||
#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
|
||||
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
|
||||
!ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
|
||||
#define ABSL_HAVE_STD_OPTIONAL 1
|
||||
@@ -933,8 +935,8 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
|
||||
#if __EMSCRIPTEN_tiny__ >= 1000
|
||||
#error __EMSCRIPTEN_tiny__ is too big to fit in ABSL_INTERNAL_EMSCRIPTEN_VERSION
|
||||
#endif
|
||||
#define ABSL_INTERNAL_EMSCRIPTEN_VERSION \
|
||||
((__EMSCRIPTEN_major__)*1000000 + (__EMSCRIPTEN_minor__)*1000 + \
|
||||
#define ABSL_INTERNAL_EMSCRIPTEN_VERSION \
|
||||
((__EMSCRIPTEN_major__) * 1000000 + (__EMSCRIPTEN_minor__) * 1000 + \
|
||||
(__EMSCRIPTEN_tiny__))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
|
||||
#if !defined(_WIN32) || defined(__MINGW32__)
|
||||
#include <pthread.h>
|
||||
#ifndef __wasi__
|
||||
// WASI does not provide this header, either way we disable use
|
||||
// of signals with it below.
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
@@ -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<void*>(identity));
|
||||
#else
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "absl/debugging/internal/examine_stack.h"
|
||||
#include "absl/debugging/stacktrace.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32) && !defined(__wasi__)
|
||||
#define ABSL_HAVE_SIGACTION
|
||||
// Apple WatchOS and TVOS don't allow sigaltstack
|
||||
// Apple macOS has sigaltstack, but using it makes backtrace() unusable.
|
||||
|
||||
Reference in New Issue
Block a user