Path: blob/main/system/lib/llvm-libc/patches/0001-emscripten-related-changes-for-llvm-libc.patch
6194 views
From 71c098f061e74c5214087728b028da4ff9db9679 Mon Sep 17 00:00:00 20011From: google-yfyang <[email protected]>2Date: Wed, 18 Jun 2025 13:57:16 -04003Subject: [PATCH] emscripten related changes for llvm-libc45---6libc/src/__support/StringUtil/platform_errors.h | 2 +-7libc/src/__support/StringUtil/tables/posix_errors.h | 5 +++++8libc/src/__support/StringUtil/tables/stdc_errors.h | 5 +++++9libc/src/__support/macros/properties/architectures.h | 4 ++++104 files changed, 15 insertions(+), 1 deletion(-)1112diff --git a/libc/src/__support/StringUtil/platform_errors.h b/libc/src/__support/StringUtil/platform_errors.h13index 32e8414b3e3d..5f83865482e7 10064414--- a/libc/src/__support/StringUtil/platform_errors.h15+++ b/libc/src/__support/StringUtil/platform_errors.h16@@ -9,7 +9,7 @@17#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H18#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H1920-#if defined(__linux__) || defined(__Fuchsia__)21+#if defined(__linux__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)22#include "tables/linux_platform_errors.h"23#else24#include "tables/minimal_platform_errors.h"25diff --git a/libc/src/__support/StringUtil/tables/posix_errors.h b/libc/src/__support/StringUtil/tables/posix_errors.h26index b21f28f0b132..031886dcc5cc 10064427--- a/libc/src/__support/StringUtil/tables/posix_errors.h28+++ b/libc/src/__support/StringUtil/tables/posix_errors.h29@@ -63,7 +63,12 @@ LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {30MsgMapping(EPROTO, "Protocol error"),31MsgMapping(EMULTIHOP, "Multihop attempted"),32MsgMapping(EBADMSG, "Bad message"),33+#ifdef __EMSCRIPTEN__34+ // For now, match the musl string35+ MsgMapping(EOVERFLOW, "Value too large for data type"),36+#else37MsgMapping(EOVERFLOW, "Value too large for defined data type"),38+#endif39MsgMapping(ENOTSOCK, "Socket operation on non-socket"),40MsgMapping(EDESTADDRREQ, "Destination address required"),41MsgMapping(EMSGSIZE, "Message too long"),42diff --git a/libc/src/__support/StringUtil/tables/stdc_errors.h b/libc/src/__support/StringUtil/tables/stdc_errors.h43index a326616f20ef..9a23d0718ea1 10064444--- a/libc/src/__support/StringUtil/tables/stdc_errors.h45+++ b/libc/src/__support/StringUtil/tables/stdc_errors.h46@@ -16,7 +16,12 @@47namespace LIBC_NAMESPACE_DECL {4849LIBC_INLINE_VAR constexpr const MsgTable<4> STDC_ERRORS = {50+#ifdef __EMSCRIPTEN__51+ // For now, match the musl name for errno 0.52+ MsgMapping(0, "No error information"),53+#else54MsgMapping(0, "Success"),55+#endif56MsgMapping(EDOM, "Numerical argument out of domain"),57MsgMapping(ERANGE, "Numerical result out of range"),58MsgMapping(EILSEQ, "Invalid or incomplete multibyte or wide character"),59diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h60index c88956ff4114..817ced4e95c2 10064461--- a/libc/src/__support/macros/properties/architectures.h62+++ b/libc/src/__support/macros/properties/architectures.h63@@ -41,6 +41,10 @@64#define LIBC_TARGET_ARCH_IS_ARM65#endif6667+#if defined(__wasm__)68+#define LIBC_TARGET_ARCH_IS_WASM69+#endif70+71#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)72#define LIBC_TARGET_ARCH_IS_AARCH6473#endif74--752.50.0.rc2.701.gf1e915cc24-goog76777879