-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Update musl to 1.1.15 #4813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update musl to 1.1.15 #4813
Conversation
Nice work! We also need to run the We will also need to bump the version number when landing this, so libc gets auto-rebuilt for people. |
@juj, please take a look at the pthreads parts here when you can. |
src/library_syscall.js
Outdated
@@ -227,7 +227,7 @@ var SyscallsLibrary = { | |||
}, | |||
__syscall5: function(which, varargs) { // open | |||
var pathname = SYSCALLS.getStr(), flags = SYSCALLS.get(), mode = SYSCALLS.get() // optional TODO | |||
var stream = FS.open(pathname, flags, mode); | |||
var stream = FS.open(pathname, flags | {{{ cDefine('O_LARGEFILE') }}}, mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because https://github.com/kripken/emscripten/pull/4813/files#diff-cffbb10ecdf95ae5cfcc9a524a924a75R246 : sys_open
calls changed to automatically | O_LARGEFILE
, and calls to sys_open
that explicitly set that flag now do so implicitly (https://github.com/kripken/emscripten/pull/4813/files/b34ee72dd065960805c911ea10bd4d1ce30c8b09#diff-3042107f3f2299532432901f2c0200ffL13)
This seemed like the right place to do this because we previously forwarded syscall_cp
as just syscall
(https://github.com/kripken/emscripten/blob/incoming/system/lib/libc/musl/src/internal/syscall.h#L60), so it seemed sane to forward sys_open
directly to syscall
as well.
The better place to do this is probably in the syscall.h
file itself, rewriting __sys_open2
and __sys_open3
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like musl started to default to largefile, so you changed emscripten to as well?
I wonder if that affects performance, does it change all offsets to 64-bit? Seems like in asm.js and wasm32, we don't need largefile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the behavior is the same; previously the open()
wrapper around sys_open
would always add the flag, so this just changes where the flag is added, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the flag back to libc in 2c36bf0
That required some shenaniganry to get around cyclical macro expansions, but overall I think that makes the change clearer.
src/library_syscall.js
Outdated
@@ -660,7 +666,9 @@ var SyscallsLibrary = { | |||
__syscall140: function(which, varargs) { // llseek | |||
var stream = SYSCALLS.getStreamFromFD(), offset_high = SYSCALLS.get(), offset_low = SYSCALLS.get(), result = SYSCALLS.get(), whence = SYSCALLS.get(); | |||
var offset = offset_low; | |||
#if WASM_BACKEND == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because https://github.com/kripken/emscripten/blob/incoming/system/lib/libc/musl/src/unistd/lseek.c calls this with an off_t
shifted right by 32, to split what it assumes is a 64bit value into high and low bits. Because asmjs doesn't handle 64bit integers, we define off_t
as just an int
(3aa7fde#diff-f5c20f80e42860c7a8b52346283d5048R226), making the rightshift undefined behavior.
I don't remember what specifically about the wasm backend makes the value be garbage here (because it gets the same definition of off_t
as an int
), but it tripped this assert a bunch. Now I thought I remembered lseek.c
changed in this PR to introduce the undefined shift, but it didn't so I'm not entirely sure why this assert gets hit now when it didn't previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for asm.js and wasm32 in general we don't need the higher bits anyhow, so how about making the assert unconditional? less differences between the wasm backend and others is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the high bits are assumed to be unset and unused, hence the assert. I'll need to investigate more I think and figure out why wasm_backend has a value here, as opposed to just writing it off as undefined behavior misbehaving.
It might be equally sane to explicitly pass 0
for the high bits #ifdef __EMSCRIPTEN__
in the C source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7fd78fb
This was due to undefined behavior: asm2wasm was compiling offset >> 32
to (i32.const 0)
, s2wasm was compiling it to a no-op, thus it wasn't writing to the vararg buffer that we pass to the syscalls, thus it was getting a garbage value from whatever was on the stack there first.
Fixed it by always just passing 0
.
@@ -138,3 +138,4 @@ long __syscall333(int which, ...); | |||
long __syscall334(int which, ...); | |||
long __syscall340(int which, ...); | |||
|
|||
#undef SYS_futimesat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/kripken/emscripten/pull/4813/files#diff-49e70a6cdbc6da14094b7d6d57f11789R10 calls out to syscall(SYS_futimesat
if it's been defined, and we don't have an implementation for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can't be the only syscall we lack an impl for though, I think? :) is something special about this one? how did you notice this was needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure.
Seems like because the implementation of utimensat
, which we actually use, changed to include this reference. The other syscalls we don't use presumably get stripped by DCE before causing compile errors.
I still think undefining SYS_futimesat
here is reasonable, because it eliminates a new codepath in utimensat
that we don't support yet.
@@ -1,4 +1,4 @@ | |||
CODESET: "UTF-8" | |||
CODESET: "ASCII" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting change, hmm. Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so: bpowers/musl@2d51c4a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. Hopefully users won't be affected by this.
Should I read the commits one by one? I see some apply/revert stuff which suggests not, i.e., they are temp commits that will be removed before merge? If it's practical to have each commit be useful though, that might be nice. |
I ran the I am under no illusions that this gets merged before January :P In general reviewing this one-by-one is probably fine; there's only a handful of small things that go back and forth (I think just the |
Ping @juj for a look at pthreads |
system/include/libc/assert.h
Outdated
@@ -16,6 +16,9 @@ | |||
extern "C" { | |||
#endif | |||
|
|||
#if __EMSCRIPTEN__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be #ifdef
instead of #if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be done across the whole project in this PR, or just this one in libc for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the only place in libc, so just this one for now. Doesn't look like there are too many others in the project, but yeah, not in this PR.
lgtm for the parts I reviewed and commented on, thanks. |
LGTM too. Might be a good time to resolve the conflicts. |
4e01d95
to
05f2c3f
Compare
Rebased, ran test_core against asm2 and binaryen2 (asm2wasm), which passed modulo V8 failures on incoming (https://wasm-stat.us/builders/linux/builds/14988/steps/Execute%20emscripten%20testsuite%20%28asm2wasm%29/logs/stdio) Will run browser tests this afternoon. @kripken, did you want to run more comprehensive tests on this before merging, or should we let the Emscripten buildbots handle it? |
Bots sound ok. But I would like to get @juj's feedback here first. I pinged him on irc now. |
#undef iswdigit | ||
#define iswdigit(a) ((unsigned)(a)-'0' < 10) | ||
#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I wonder what this is all about? iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
... looks really odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it's about better compile-time diagnostics for misuse: bpowers/musl@2ca55a9
The functions (including iswdigit
) are declared, but only defined in terms of macros, and then the (unsigned)
cast loses type information. So if someone calls them with an invalid argument type the frontend doesn't complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that makes sense, thanks!
@@ -5,6 +5,7 @@ | |||
#include <emscripten.h> | |||
#include <emscripten/threading.h> | |||
|
|||
#define a_ctz_l a_ctz_l |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale here in defining these to point to themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because bpowers/musl@1315596#diff-4c18db28385d6925bd8462b3a13fbce1 changed atomic.h
to expect the archs to #define
these, and if not it will provide the implementation. a_cas
in particular raises an #error
if not #define
d
@@ -86,9 +86,9 @@ typedef long suseconds_t; | |||
#ifdef __EMSCRIPTEN__ | |||
// For canvas transfer implementation in Emscripten, use an extra 10th control field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this comment to say "extra 11th control field", so that it is clear that the extra variable is at index [10], and not the second to last element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the source of where this added field comes from, see this commit: 1b27891 and in particular, search for the string _a_transferredcanvases
. That has the value
// Extra pthread_attr_t field:
#define _a_transferredcanvases __u.__s[9]
in system/lib/pthread/library_pthread.c
, which I believe should be updated to __u.__s[10]
because musl added one field of their own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -97,28 +97,31 @@ typedef struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t; | |||
#ifdef __EMSCRIPTEN__ | |||
// For mutex implementation in Emscripten, need to use an extra seventh control field | |||
// to hold a temporary futex wait & wake location, designated as mutex->_m_addr. | |||
typedef struct { union { int __i[7]; void *__p[7]; } __u; } pthread_mutex_t; | |||
typedef struct { union { int __i[8]; volatile int __vi[8]; volatile void *__p[8]; } __u; } pthread_mutex_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since also here musl has added one field, then the Emscripten-specific field needs to also be bumped up by one:
#ifdef __EMSCRIPTEN__
#define _m_addr __u.__i[6]
#endif
should now be __i[7]
I think. See this commit which originally introduced it: e4d3138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d08eb3d
system/lib/libc/musl/src/aio/aio.c
Outdated
.si_pid = getpid(), | ||
.si_uid = getuid() | ||
}; | ||
#ifndef __EMSCRIPTEN__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of #ifndeffing
these out, let's just have them in, and create a no-op syscall for these, which would in #if ASSERTIONS
mode console.log()
out a warning of a no-op syscall being called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -20,7 +20,9 @@ static void notify_signal(struct sigevent *sev) | |||
.si_pid = __pthread_self()->pid, | |||
.si_uid = getuid() | |||
}; | |||
#ifndef __EMSCRIPTEN__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, we don't need to #ifndef
this out, but let's have a no-op stub syscall for this.
struct __libc { | ||
void *main_thread; | ||
int can_do_threads; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks interesting. Perhaps we want to make sure that this gets initialized appropriately in -s USE_PTHREADS=0/1/2
builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On further inspection, not sure if that's worth doing. Currently, and when the field was added (bpowers/musl@dab441a), it only serves to return ENOSYS
from pthread_create
, which gets provided by library JS code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, makes sense.
#ifdef __EMSCRIPTEN__ | ||
// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, so use an extra field | ||
// _rw_wr_owner to record which thread owns the write lock in order to avoid hangs. | ||
// Points to the pthread that currently has the write lock. | ||
#define _rw_wr_owner __u.__i[2] | ||
#define _rw_wr_owner __u.__vi[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now incorrect. It looks like musl has added one field to the rwlock structure, old fields were _rw_lock
at index 0, and _rw_waiters
at index 1. In new musl there's _rw_lock
and _rw_waiters
at indices 0 and 1 as before, but a new field _rw_shared
at index 2, so our Emscripten-specific deadlock detection control field at index 2 now conflicts with _rw_shared
. We need to change _rw_wr_owner
to index 3, and make sure that the size of that field is appropriate in Emscripten builds as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d08eb3d
#ifdef __EMSCRIPTEN__ | ||
#define __wake(addr, cnt, priv) emscripten_futex_wake((void*)addr, (cnt)<0?INT_MAX:(cnt)) | ||
emscripten_futex_wake((void*)addr, (cnt)<0?INT_MAX:(cnt)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you changed the signature of emscripten_futex_wake
to take in a volatile void*
instead of just a void*
. Doesn't that cause this to give a build error, if anything calls __wake
, because here the cast is still to void*
. Should cast to volatile void *
then?
Btw, what was the rationale to change to volatile void*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I seem to have resolved my issues building the browser tests, and do indeed see lots of breakage. I imagine this is in there.
Re: rationale, bpowers/musl@56fbaa3 is the musl commit that changed the pthread structs to be volatile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's switch to volatile void*
then. This will break all code that uses futexes, but there shouldn't be too many users of these low level objects out there, as everyone is using mutexes mainly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I dropped the cast in ff131dc
I also learned that C doesn't much care about CV-qualifiers, which is why this cast worked in the first place.
#define __ATTRP_C11_THREAD ((void*)(uintptr_t)-1) | ||
|
||
#if !__EMSCRIPTEN_PTHREADS__ | ||
void __emscripten_init_pthread_stub(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the pthread_t
structure for main thread is now unconditionally needed in all builds, I think we want to have a machinery that initializes the pthread control field in main thread identical to whether we are building with threads or not. Is it possible to reuse the same code and avoid these pthread_stub
fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we weren't initializing locale in non-stub versions. Added a browser test to verify that both stub and non-stub versions have nonzero locale fields, and made the initialization consistent here d01f14d
@@ -5,9 +5,25 @@ | |||
#include <math.h> | |||
#include <assert.h> | |||
|
|||
void printFloat(float n) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume the print format changed here somehow, and printf("%f", nan);
no longer prints the string "nan"? What does it print now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it will include the sign for negative nan, and prints "-nan"
. asmjs and wasm have different ideas of which nans to use when, so this just normalizes them all the time, because the tests don't really care about which nan exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what is the root cause of the divergence? Looks ok to have this then, but I'm surprised that this even differs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally sure, my rough-cut guess is that it's due to wasm not being strictly IEEE 754 compliant with respect to NaN values (https://github.com/WebAssembly/design/blob/master/Semantics.md#floating-point-operators and https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#full-ieee-754-2008-conformance), in particular with respect to NaN signs.
Testing out
|
Ran the
|
We previously statically allocated a single locale in the event that we needed to dynamically allocate one during startup. musl changed their implementation to statically allocate C_LOCALE and UTF8_LOCALE, so we already get that behavior. In addition this was causing invalid locales to get allocated instead of returning NULL, because the preceding logic changed. That was caught by other.test_locale_wrong
a701f8e
to
49756ca
Compare
Thanks, and I added tags in the other 2 repos. Interestingly, I got an email notification about the 2 tags you created. I don't think I've ever seen that before. Did you create them in some other way than |
Yeah, I made them through the GitHub interface, which probably has deeper notification hooks? Haven't worked with tags before, didn't think to check the command line. Thanks for tagging fastcomp&clang by the way! |
When musl was updated to version 1.1.5 in #4813 it looks like files that were removed upstream were not removed locally. Because we recursively build some directories this means we were build old files. For example the src/locale/is*.c family of functions were removed from musl in d89fdec51b5849ebdf8000ff1c2fb49878004f39 but remained in our tree after the update. This fixes some strange failures we've been seeing on the CI builders where the name of a symbol alternates between __isxdigit_l (the new name) and isxdigit_l (the old name). This is due to the fact that this symbol was defined in two different object files and filesystem ordering was determining which object was included first by the linker.
When musl was updated to version 1.1.5 in #4813 it looks like files that were removed upstream were not removed locally. Because we recursively build some directories this means we were build old files. For example the src/locale/is*.c family of functions were removed from musl in d89fdec51b5849ebdf8000ff1c2fb49878004f39 but remained in our tree after the update. This fixes some strange failures we've been seeing on the CI builders where the name of a symbol alternates between __isxdigit_l (the new name) and isxdigit_l (the old name). This is due to the fact that this symbol was defined in two different object files and filesystem ordering was determining which object was included first by the linker. This change was automatically generated by checking out musl at v1.1.15 and running: `for f in $(find . -type f); do if [[ ! -e ../../../../../musl/$f ]]; then echo $f; fi; done | grep -v emscripten | xargs git rm`
When musl was updated to version 1.1.5 in #4813 it looks like files that were removed upstream were not removed locally. Because we recursively build some directories this means we were build old files. For example the src/locale/is*.c family of functions were removed from musl in d89fdec51b5849ebdf8000ff1c2fb49878004f39 but remained in our tree after the update. This fixes some strange failures we've been seeing on the CI builders where the name of a symbol alternates between __isxdigit_l (the new name) and isxdigit_l (the old name). This is due to the fact that this symbol was defined in two different object files and filesystem ordering was determining which object was included first by the linker. This change was automatically generated by checking out musl at v1.1.15 and running: `for f in $(find . -type f); do if [[ ! -e ../../../../../musl/$f ]]; then echo $f; fi; done | grep -v emscripten | xargs git rm`
When musl was last upgraded this malloc line was silently removed.
When musl was last upgraded this malloc line removed from newlocale.c, perhaps by accident. This restores the behaviour of musl which is to allow `newlocale` with arbitrary names to succeed. I verified that this is the case using musl on my desktop.
When musl was last upgraded this malloc line removed from newlocale.c, perhaps by accident. This restores the behaviour of musl which is to allow `newlocale` with arbitrary names to succeed. I verified that this is the case using musl on my desktop. Its not clear to me if/how test_locale_wrong passed prior to #4813 given that this test seems to expect `newlocale` to fail in way that musl does not.
When musl was last upgraded this malloc line removed from newlocale.c, perhaps by accident. This restores the behaviour of musl which is to allow `newlocale` with arbitrary names to succeed. I verified that this is the case using musl on my desktop. The reason that test_locale_wrong was passing prior to #4813 is that the musl older version of musl we were using prior to #4813 rejected all locales except for "C" and "POSIX". Upstream version that we are currently based on: https://github.com/emscripten-core/musl/blob/v1.1.15/src/locale/newlocale.c#L44 Upstream version of musl that we were previously using: https://github.com/emscripten-core/musl/blob/0b44a0315b47dd8eced9f3b7f31580cf14bbfc01/src/locale/newlocale.c#L5
When musl was last upgraded this malloc line removed from newlocale.c, perhaps by accident. This restores the behaviour of musl which is to allow `newlocale` with arbitrary names to succeed. I verified that this is the case using musl on my desktop. The reason that test_locale_wrong was passing prior to #4813 is that the musl older version of musl we were using prior to #4813 rejected all locales except for "C" and "POSIX". Upstream version that we are currently based on: https://github.com/emscripten-core/musl/blob/v1.1.15/src/locale/newlocale.c#L44 Upstream version of musl that we were previously using: https://github.com/emscripten-core/musl/blob/0b44a0315b47dd8eced9f3b7f31580cf14bbfc01/src/locale/newlocale.c#L5
This updates Emscripten's musl libc from 1.0.5 to 1.1.15
This was done by copying 1.0.5 into the emscripten source in order to revert all emscripten-specific changes (jgravelle-google@6993081), copying the new 1.1.15 in (jgravelle-google@3f0a2b4), and then reverting the first commit to reapply all emscripten changes at once (jgravelle-google@60dacbf). After that, all that was left to do was fix merge conflicts, and change any emscripten-specific workarounds to apply to new musl.
Of note is the assumption in newer versions of musl that
__pthread_self
always exists. bpowers/musl@19a1fe6 makes this explicit, and caused problems when compiling without-s USE_PTHREADS=1
, because that would uselibrary_pthread_stub.js
, which used to stub__pthread_self
at 0. Now we need to explicitly allocate apthread
(jgravelle-google@cc078e5) and initialize its dynamic fields (jgravelle-google@cce0512). We'd also like to make sure the whole thing is available entirely in the asm module (jgravelle-google@db9ce62) so that-s EVAL_CTORS=1
can handle calls that use it, in particular most iostream constructors rely onCURRENT_LOCALE
, which is thread-specific.This passes the entire core testsuite on my machine (for asmjs, asm2wasm, and s2wasm).