Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/llvm-libc/patches/0001-emscripten-related-changes-for-llvm-libc.patch
6194 views
1
From 71c098f061e74c5214087728b028da4ff9db9679 Mon Sep 17 00:00:00 2001
2
From: google-yfyang <[email protected]>
3
Date: Wed, 18 Jun 2025 13:57:16 -0400
4
Subject: [PATCH] emscripten related changes for llvm-libc
5
6
---
7
libc/src/__support/StringUtil/platform_errors.h | 2 +-
8
libc/src/__support/StringUtil/tables/posix_errors.h | 5 +++++
9
libc/src/__support/StringUtil/tables/stdc_errors.h | 5 +++++
10
libc/src/__support/macros/properties/architectures.h | 4 ++++
11
4 files changed, 15 insertions(+), 1 deletion(-)
12
13
diff --git a/libc/src/__support/StringUtil/platform_errors.h b/libc/src/__support/StringUtil/platform_errors.h
14
index 32e8414b3e3d..5f83865482e7 100644
15
--- a/libc/src/__support/StringUtil/platform_errors.h
16
+++ b/libc/src/__support/StringUtil/platform_errors.h
17
@@ -9,7 +9,7 @@
18
#ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
19
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_PLATFORM_ERRORS_H
20
21
-#if defined(__linux__) || defined(__Fuchsia__)
22
+#if defined(__linux__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
23
#include "tables/linux_platform_errors.h"
24
#else
25
#include "tables/minimal_platform_errors.h"
26
diff --git a/libc/src/__support/StringUtil/tables/posix_errors.h b/libc/src/__support/StringUtil/tables/posix_errors.h
27
index b21f28f0b132..031886dcc5cc 100644
28
--- a/libc/src/__support/StringUtil/tables/posix_errors.h
29
+++ b/libc/src/__support/StringUtil/tables/posix_errors.h
30
@@ -63,7 +63,12 @@ LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {
31
MsgMapping(EPROTO, "Protocol error"),
32
MsgMapping(EMULTIHOP, "Multihop attempted"),
33
MsgMapping(EBADMSG, "Bad message"),
34
+#ifdef __EMSCRIPTEN__
35
+ // For now, match the musl string
36
+ MsgMapping(EOVERFLOW, "Value too large for data type"),
37
+#else
38
MsgMapping(EOVERFLOW, "Value too large for defined data type"),
39
+#endif
40
MsgMapping(ENOTSOCK, "Socket operation on non-socket"),
41
MsgMapping(EDESTADDRREQ, "Destination address required"),
42
MsgMapping(EMSGSIZE, "Message too long"),
43
diff --git a/libc/src/__support/StringUtil/tables/stdc_errors.h b/libc/src/__support/StringUtil/tables/stdc_errors.h
44
index a326616f20ef..9a23d0718ea1 100644
45
--- a/libc/src/__support/StringUtil/tables/stdc_errors.h
46
+++ b/libc/src/__support/StringUtil/tables/stdc_errors.h
47
@@ -16,7 +16,12 @@
48
namespace LIBC_NAMESPACE_DECL {
49
50
LIBC_INLINE_VAR constexpr const MsgTable<4> STDC_ERRORS = {
51
+#ifdef __EMSCRIPTEN__
52
+ // For now, match the musl name for errno 0.
53
+ MsgMapping(0, "No error information"),
54
+#else
55
MsgMapping(0, "Success"),
56
+#endif
57
MsgMapping(EDOM, "Numerical argument out of domain"),
58
MsgMapping(ERANGE, "Numerical result out of range"),
59
MsgMapping(EILSEQ, "Invalid or incomplete multibyte or wide character"),
60
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
61
index c88956ff4114..817ced4e95c2 100644
62
--- a/libc/src/__support/macros/properties/architectures.h
63
+++ b/libc/src/__support/macros/properties/architectures.h
64
@@ -41,6 +41,10 @@
65
#define LIBC_TARGET_ARCH_IS_ARM
66
#endif
67
68
+#if defined(__wasm__)
69
+#define LIBC_TARGET_ARCH_IS_WASM
70
+#endif
71
+
72
#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
73
#define LIBC_TARGET_ARCH_IS_AARCH64
74
#endif
75
--
76
2.50.0.rc2.701.gf1e915cc24-goog
77
78
79