Skip to content

Commit 7cefa59

Browse files
committed
Remove obsolete pthread_getattr_np workaround
1 parent 8a5e24a commit 7cefa59

4 files changed

Lines changed: 8 additions & 72 deletions

File tree

‎Platforms/emscripten/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ await createEmscriptenModule({
138138

139139
- Threading is disabled by default. The ``configure`` option
140140
``--enable-wasm-pthreads`` adds compiler flag ``-pthread`` and
141-
linker flags ``-sUSE_PTHREADS -sPROXY_TO_PTHREAD``.
141+
linker flags ``-pthread -sPROXY_TO_PTHREAD``.
142142
- pthread support requires WASM threads and SharedArrayBuffer (bulk memory).
143143
The Node.JS runtime keeps a pool of web workers around. Each web worker
144144
uses several file descriptors (eventfd, epoll, pipe).

‎Python/ceval.c‎

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -70,70 +70,6 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count)
7070
# define Py_C_STACK_SIZE 4000000
7171
#endif
7272

73-
#if defined(__EMSCRIPTEN__)
74-
75-
// Temporary workaround to make `pthread_getattr_np` work on Emscripten.
76-
// Emscripten 4.0.6 will contain a fix:
77-
// https://github.com/emscripten-core/emscripten/pull/23887
78-
79-
#include "emscripten/stack.h"
80-
81-
#define pthread_attr_t workaround_pthread_attr_t
82-
#define pthread_attr_init workaround_pthread_attr_init
83-
#define pthread_getattr_np workaround_pthread_getattr_np
84-
#define pthread_attr_getguardsize workaround_pthread_attr_getguardsize
85-
#define pthread_attr_getstack workaround_pthread_attr_getstack
86-
#define pthread_attr_destroy workaround_pthread_attr_destroy
87-
88-
typedef struct {
89-
void *_a_stackaddr;
90-
size_t _a_stacksize, _a_guardsize;
91-
} pthread_attr_t;
92-
93-
extern __attribute__((__visibility__("hidden"))) unsigned __default_guardsize;
94-
95-
int pthread_attr_init(pthread_attr_t *a)
96-
{
97-
return 0;
98-
}
99-
100-
// Modified version of pthread_getattr_np from the upstream PR.
101-
102-
int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) {
103-
attr->_a_stackaddr = (void*)emscripten_stack_get_base();
104-
attr->_a_stacksize = emscripten_stack_get_base() - emscripten_stack_get_end();
105-
attr->_a_guardsize = __default_guardsize;
106-
return 0;
107-
}
108-
109-
// These three functions copied without any changes from Emscripten libc.
110-
111-
int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size)
112-
{
113-
*size = a->_a_guardsize;
114-
return 0;
115-
}
116-
117-
int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size)
118-
{
119-
/// XXX musl is not standard-conforming? It should not report EINVAL if _a_stackaddr is zero, and it should
120-
/// report EINVAL if a is null: http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getstack.html
121-
if (!a) return EINVAL;
122-
// if (!a->_a_stackaddr)
123-
// return EINVAL;
124-
125-
*size = a->_a_stacksize;
126-
*addr = (void *)(a->_a_stackaddr - *size);
127-
return 0;
128-
}
129-
130-
int pthread_attr_destroy(pthread_attr_t *a)
131-
{
132-
return 0;
133-
}
134-
135-
#endif
136-
13773
static void
13874
hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
13975
{

‎configure‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,12 +1153,12 @@ if test -z "$CFLAGS"; then
11531153
fi
11541154

11551155
dnl Emscripten SDK and WASI SDK default to wasm32.
1156-
dnl On Emscripten use MEMORY64 setting to build target wasm64-emscripten.
1156+
dnl On Emscripten use -m64 to build target wasm64-emscripten.
11571157
dnl for wasm64.
11581158
AS_CASE([$host],
11591159
[wasm64-*-emscripten], [
1160-
AS_VAR_APPEND([CFLAGS], [" -sMEMORY64=1"])
1161-
AS_VAR_APPEND([LDFLAGS], [" -sMEMORY64=1"])
1160+
AS_VAR_APPEND([CFLAGS], [" -m64"])
1161+
AS_VAR_APPEND([LDFLAGS], [" -m64"])
11621162
],
11631163
)
11641164

@@ -2659,7 +2659,7 @@ AS_CASE([$ac_sys_system],
26592659
26602660
AS_VAR_IF([enable_wasm_pthreads], [yes], [
26612661
AS_VAR_APPEND([CFLAGS_NODIST], [" -pthread"])
2662-
AS_VAR_APPEND([LDFLAGS_NODIST], [" -sUSE_PTHREADS"])
2662+
AS_VAR_APPEND([LDFLAGS_NODIST], [" -pthread"])
26632663
AS_VAR_APPEND([LINKFORSHARED], [" -sPROXY_TO_PTHREAD"])
26642664
])
26652665
dnl not completely sure whether or not we want -sEXIT_RUNTIME, keeping it for now.

0 commit comments

Comments
 (0)