Skip to content

Update musl to v1.2.6#26860

Merged
sbc100 merged 32 commits into
emscripten-core:mainfrom
kleisauke:musl-1.2.6
May 21, 2026
Merged

Update musl to v1.2.6#26860
sbc100 merged 32 commits into
emscripten-core:mainfrom
kleisauke:musl-1.2.6

Conversation

@kleisauke
Copy link
Copy Markdown
Collaborator

No description provided.

kleisauke added 14 commits May 5, 2026 11:25
This is an automatic change generated with:
```
./system/lib/update_musl.py ~/Downloads/musl-1.2.5
```
In preparation for the next commit.
This is an automatic change generated with:
```
./system/lib/update_musl.py ~/Downloads/musl-1.2.6
```
Done via:
```
./tools/gen_struct_info.py
./tools/gen_struct_info.py --wasm64
```
Details:
```
wasm-ld: error: --shared-memory is disallowed by exit.o because it was not compiled with 'atomics' or 'bulk-memory' features.
```
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (25) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_ctors1.json: 151887 => 151940 [+53 bytes / +0.03%]
codesize/test_codesize_cxx_ctors2.json: 151292 => 151346 [+54 bytes / +0.04%]
codesize/test_codesize_cxx_except.json: 195766 => 195851 [+85 bytes / +0.04%]
codesize/test_codesize_cxx_except_wasm.json: 167018 => 167109 [+91 bytes / +0.05%]
codesize/test_codesize_cxx_except_wasm_legacy.json: 164898 => 164989 [+91 bytes / +0.06%]
codesize/test_codesize_cxx_lto.json: 120587 => 120608 [+21 bytes / +0.02%]
codesize/test_codesize_cxx_mangle.json: 262245 => 262330 [+85 bytes / +0.03%]
codesize/test_codesize_cxx_noexcept.json: 153917 => 153956 [+39 bytes / +0.03%]
codesize/test_codesize_cxx_wasmfs.json: 179773 => 179812 [+39 bytes / +0.02%]
codesize/test_codesize_file_preload.json: 23855 => 23873 [+18 bytes / +0.08%]
codesize/test_codesize_hello_O0.json: 39070 => 39335 [+265 bytes / +0.68%]
codesize/test_codesize_hello_O1.json: 8875 => 8889 [+14 bytes / +0.16%]
codesize/test_codesize_hello_O2.json: 6221 => 6235 [+14 bytes / +0.23%]
codesize/test_codesize_hello_O3.json: 5913 => 5931 [+18 bytes / +0.30%]
codesize/test_codesize_hello_Os.json: 5903 => 5919 [+16 bytes / +0.27%]
codesize/test_codesize_hello_Oz.json: 5072 => 5088 [+16 bytes / +0.32%]
codesize/test_codesize_hello_dylink.json: 43922 => 44112 [+190 bytes / +0.43%]
codesize/test_codesize_hello_dylink_all.json: 822610 => 822562 [-48 bytes / -0.01%]
codesize/test_codesize_hello_single_file.json: 5223 => 5241 [+18 bytes / +0.34%]
codesize/test_codesize_hello_wasmfs.json: 5913 => 5931 [+18 bytes / +0.30%]
codesize/test_codesize_minimal_pthreads.json: 26370 => 26347 [-23 bytes / -0.09%]
codesize/test_codesize_minimal_pthreads_memgrowth.json: 26774 => 26751 [-23 bytes / -0.09%]
codesize/test_minimal_runtime_code_size_random_printf_wasm.json: 10815 => 11057 [+242 bytes / +2.24%]
codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json: 17114 => 17417 [+303 bytes / +1.77%]
codesize/test_unoptimized_code_size.json: 180144 => 180893 [+749 bytes / +0.42%]

Average change: +0.31% (-0.09% - +2.24%)
```
@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented May 5, 2026

Were you able to follow up process for updating musl in https://github.com/emscripten-core/emscripten/blob/main/docs/process.md#updating-musl?

I would expect to see some updates to https://github.com/emscripten-core/musl before the emscripten side change.

@kleisauke
Copy link
Copy Markdown
Collaborator Author

I skipped https://github.com/emscripten-core/musl because maintaining the code in two separate places feels unconventional (and I don't have contributor access there anyway). Instead, I followed a workflow similar to the one used when updating mimalloc:

  1. Replace system/lib/libc/musl/ with original musl v1.2.5 via:
    $ ./system/lib/update_musl.py ~/Downloads/musl-1.2.5
  2. Commit those changes (see 8afc084).
  3. Replace system/lib/libc/musl/ with musl v1.2.6 via:
    $ ./system/lib/update_musl.py ~/Downloads/musl-1.2.6
  4. Commit those changes (see fa6d187).
  5. Revert the changes from step 2 (see a67d130).

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented May 5, 2026

If you think the instructions in https://github.com/emscripten-core/emscripten/blob/main/docs/process.md#updating-musl are too complex then perhaps we should update them?

I find it kind of convenient to be able to see the emscripten changes as a git diff, and it means we can follow the same pattern for llvm and musl.

Another option, if we are look into changing things up is what wasi-libc recently did suing git subtree: WebAssembly/wasi-libc#797.

But for this update would you mind updating the emscripten/musl fork? Even if we end up landing this PR, I'd still like the result reflected there.. unless we want to deprecate that repo.

@kleisauke
Copy link
Copy Markdown
Collaborator Author

But for this update would you mind updating the emscripten/musl fork?

Sure, I'll look into this tomorrow (as I'm in UTC+2).

@kleisauke
Copy link
Copy Markdown
Collaborator Author

kleisauke commented May 6, 2026

See companion PR emscripten-core/musl#3 for a diff that includes only the musl-specific changes.

Comment thread system/lib/libc/musl/include/setjmp.h Outdated
typedef jmp_buf sigjmp_buf;
/* XXX EMSCRIPTEN: No signals support, alias sigsetjmp and siglongjmp to their non-signals counterparts. */
#if __EMSCRIPTEN__ && !defined(LLVM_LIBC)
#if defined(__EMSCRIPTEN__) && !defined(LLVM_LIBC)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind splitting out a PR for all the places where we should have done ifdef rather then if like this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, reverted with commit a499fc2.

#ifdef __EMSCRIPTEN__
#define _POSIX_SPAWN -1
#else
#define _POSIX_SPAWN _POSIX_VERSION
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can include this kind of refactor in the split-out PR too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted with commit 1f05268.

* that is not fdpic-aware. We can assume normal fixed-
* displacement ELF loading was performed, but when ldso was
* run as a command, finding the Ehdr is a heursitic: we
* run as a command, finding the Ehdr is a heuristic: we
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a spelling fix from upstream of from you?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread system/lib/libc/musl/src/internal/syscall.h Outdated
kleisauke added a commit to emscripten-core/musl that referenced this pull request May 6, 2026
This change is the result of running ./system/lib/push_musl_changes.py
@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented May 6, 2026

I created and emscripten branch update emscripten-core/musl#4.

Hopefully if we land this first it will make this PR more precise/concise?

kleisauke added a commit to emscripten-core/musl that referenced this pull request May 6, 2026
This change was generated by running ./system/lib/push_musl_changes.py.
kleisauke added a commit to emscripten-core/musl that referenced this pull request May 6, 2026
This change was generated by running ./system/lib/push_musl_changes.py
within the Emscripten repo.
kleisauke added 2 commits May 20, 2026 16:44
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (23) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_ctors1.json: 151949 => 152002 [+53 bytes / +0.03%]
codesize/test_codesize_cxx_ctors2.json: 151352 => 151408 [+56 bytes / +0.04%]
codesize/test_codesize_cxx_except.json: 195817 => 195902 [+85 bytes / +0.04%]
codesize/test_codesize_cxx_except_wasm.json: 167044 => 167135 [+91 bytes / +0.05%]
codesize/test_codesize_cxx_except_wasm_legacy.json: 164924 => 165015 [+91 bytes / +0.06%]
codesize/test_codesize_cxx_lto.json: 120826 => 120848 [+22 bytes / +0.02%]
codesize/test_codesize_cxx_mangle.json: 262296 => 262381 [+85 bytes / +0.03%]
codesize/test_codesize_cxx_noexcept.json: 153965 => 154004 [+39 bytes / +0.03%]
codesize/test_codesize_cxx_wasmfs.json: 179712 => 179751 [+39 bytes / +0.02%]
codesize/test_codesize_file_preload.json: 23872 => 23890 [+18 bytes / +0.08%]
codesize/test_codesize_hello_O0.json: 39104 => 39369 [+265 bytes / +0.68%]
codesize/test_codesize_hello_O1.json: 8908 => 8922 [+14 bytes / +0.16%]
codesize/test_codesize_hello_O2.json: 6242 => 6256 [+14 bytes / +0.22%]
codesize/test_codesize_hello_O3.json: 5934 => 5952 [+18 bytes / +0.30%]
codesize/test_codesize_hello_Os.json: 5924 => 5940 [+16 bytes / +0.27%]
codesize/test_codesize_hello_Oz.json: 5093 => 5109 [+16 bytes / +0.31%]
codesize/test_codesize_hello_dylink.json: 44104 => 44294 [+190 bytes / +0.43%]
codesize/test_codesize_hello_dylink_all.json: 855794 => 855865 [+71 bytes / +0.01%]
codesize/test_codesize_hello_single_file.json: 5244 => 5262 [+18 bytes / +0.34%]
codesize/test_codesize_hello_wasmfs.json: 5934 => 5952 [+18 bytes / +0.30%]
codesize/test_minimal_runtime_code_size_random_printf_wasm.json: 10815 => 11057 [+242 bytes / +2.24%]
codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json: 17114 => 17417 [+303 bytes / +1.77%]
codesize/test_unoptimized_code_size.json: 180220 => 180969 [+749 bytes / +0.42%]

Average change: +0.34% (+0.01% - +2.24%)
```
@kleisauke
Copy link
Copy Markdown
Collaborator Author

kleisauke commented May 20, 2026

See companion PR emscripten-core/musl#3 for a diff that includes only the musl-specific changes.

PR emscripten-core/musl#7 includes only the Emscripten-specific changes (+ changes that were not synced yet).

kleisauke added a commit to emscripten-core/musl that referenced this pull request May 20, 2026
This change was generated by running ./system/lib/push_musl_changes.py
within the Emscripten repo.
kleisauke added a commit to emscripten-core/musl that referenced this pull request May 20, 2026
This change was generated by running ./system/lib/push_musl_changes.py
within the Emscripten repo.
@kleisauke
Copy link
Copy Markdown
Collaborator Author

I'm not sure why browser64_4gb.test_pthread_hello_thread is failing on CI, it seems to work locally.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented May 20, 2026

Thats a known flake that started showing up with recent chrome releases.

This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (5) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_libcxxabi_message_O3_standalone.json: 3727 => 3817 [+90 bytes / +2.41%]
codesize/test_codesize_mem_O3_grow_standalone.json: 9675 => 9768 [+93 bytes / +0.96%]
codesize/test_codesize_mem_O3_standalone.json: 9532 => 9625 [+93 bytes / +0.98%]
codesize/test_codesize_mem_O3_standalone_narg.json: 8860 => 8949 [+89 bytes / +1.00%]
codesize/test_codesize_mem_O3_standalone_narg_flto.json: 7796 => 7880 [+84 bytes / +1.08%]

Average change: +1.29% (+0.96% - +2.41%)
```
#define PTRDIFF_MIN INT64_MIN
#define PTRDIFF_MAX INT64_MAX
#define SIZE_MAX UINT64_MAX
#endif
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified stdint.h to not depend on bits/stdint.h at all, so maybe we can just skip this file? (i.e. delete it).

See #26689

Copy link
Copy Markdown
Collaborator Author

@kleisauke kleisauke May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Removed with commit ae38f6f.

FWIW, I had to make update_musl.py more precise in commit 4289e41, otherwise, include/stdint.h would have been removed as well.

kleisauke added 4 commits May 21, 2026 10:47
In preparation for the next commit.
It's no longer needed.
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (2) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_hello_dylink_all.json: 855671 => 855742 [+71 bytes / +0.01%]
codesize/test_minimal_runtime_code_size_audio_worklet.json: 16226 => 16399 [+173 bytes / +1.07%]

Average change: +0.54% (+0.01% - +1.07%)
```
Comment thread src/lib/libsyscall.js
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_nsec, '(mtime % 1000) * 1000 * 1000', SIZE_TYPE) }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_sec, 'Math.floor(ctime / 1000)', 'i64') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_nsec, '(ctime % 1000) * 1000 * 1000', SIZE_TYPE) }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i64') }}};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like just a re-ordering? Revert this file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was re-ordered to match the stat struct, see commit 7378ee6.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... though I can revert this, I need to resolve the merge conflicts anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's revert this stat struct field reordering. I forgot that changing the layout breaks Rust compatibility, see for example:
https://github.com/rust-lang/libc/blob/0.2.186/src/unix/linux_like/linux/musl/b32/x86/mod.rs#L9-L48
versus:
https://github.com/rust-lang/libc/blob/0.2.186/src/unix/linux_like/emscripten/mod.rs#L217-L240

See also rust-lang/rust#131467, where a similar change caused a significant amount of churn.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordering of assignments in JS doesn't not need to match the ordering in native code necessarily.

I don't really care of we keep the old ordering on the native side but it seems very bad if rust depends on this ..

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted with commit d7aeb05 and 29fc8dd to be on the safe side.

Comment thread src/lib/libwasmfs.js Outdated
mtime: {{{ makeGetValue('statBuf', C_STRUCTS.stat.st_mtim.tv_sec, "i53") }}},
ctime: {{{ makeGetValue('statBuf', C_STRUCTS.stat.st_ctim.tv_sec, "i53") }}},
ino: {{{ makeGetValue('statBuf', C_STRUCTS.stat.st_ino, "u53") }}}
ctime: {{{ makeGetValue('statBuf', C_STRUCTS.stat.st_ctim.tv_sec, "i53") }}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

"a.out.nodebug.wasm": 102186,
"a.out.nodebug.wasm.gz": 39572,
"total": 120848,
"total_gz": 47263,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endless creep of progress :)

kleisauke added 4 commits May 21, 2026 19:02
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (1) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_hello_dylink_all.json: 855738 => 855809 [+71 bytes / +0.01%]

Average change: +0.01% (+0.01% - +0.01%)
```
@sbc100 sbc100 merged commit 4bf5fb7 into emscripten-core:main May 21, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants