From 564d239939fdd212d47c63adf02b5e0de31f3701 Mon Sep 17 00:00:00 2001 From: InfiniteSnow <3xplosive.g@gmail.com> Date: Sun, 12 May 2024 22:07:39 +0100 Subject: [PATCH] Disable undesired attempts at opening file descriptors When building for a web target, there is no stderr. However, the abort implementation in the current CXXABI runtime is implemented with writes to stderr. Since the constructors for default objects call abort, these are rightfully not optimised out from the compiler. However, it is hardly sensible in my opinion to have to include a whole WASI runtime implementation in the browser just to handle more informative aborts by default. To prevent this, compile the cxxabi runtime with NDEBUG and CXXABI_BAREMETAL flags. This is not enough though, as the compiler will still try to instantiate __libcpp_verbose_abort from the stdcxx library. To prevent the compiler from instantiating __libcpp_verbose_abort, clean fix for this is to consistently set _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT=0 in the __availability header. This requires forking or patching LLVM. --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eeac2dbff..e96c53eef 100644 --- a/Makefile +++ b/Makefile @@ -185,6 +185,7 @@ build/compiler-rt.BUILT: build/llvm.BUILT # $(3): the name of the target being built for # $(4): extra compiler flags to pass LIBCXX_CMAKE_FLAGS = \ + -DNDEBUG=1 \ -DCMAKE_C_COMPILER_WORKS=ON \ -DCMAKE_CXX_COMPILER_WORKS=ON \ -DCMAKE_AR=$(BUILD_PREFIX)/bin/ar \ @@ -205,7 +206,8 @@ LIBCXX_CMAKE_FLAGS = \ -DLIBCXX_ENABLE_SHARED:BOOL=$(2) \ -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL=OFF \ -DLIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF \ - -DLIBCXX_ENABLE_FILESYSTEM:BOOL=ON \ + -DLIBCXX_ENABLE_FILESYSTEM:BOOL=OFF \ + -DLIBCXXABI_BAREMETAL=1\ -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL=OFF \ -DLIBCXX_CXX_ABI=libcxxabi \ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=$(LLVM_PROJ_DIR)/libcxxabi/include \