Skip to content

Commit dc413f8

Browse files
authored
Avoid shipping internal musl headers as part of the sysroot (#26658)
It turns out that the files in `musl/arch/generic/` and `musl/arch/emscripten/` are supposed to me internal headers even though the `bits/` subdirectories are public. This change means that `syscall_arch.h` is not longer visible outside of the musl build (e.g. when building wasmfs) so I moved the public function declarations to `emscripten/syscalls.h`.
1 parent 7b7fd47 commit dc413f8

8 files changed

Lines changed: 137 additions & 118 deletions

File tree

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ See docs/process.md for more on how version tagging works.
2222
----------------------
2323
- The minimum version of node supported by the generated code was bumped from
2424
v12.22.0 to v18.3.0. (#26604)
25-
- The DETERMINISIC settings was marked as deprecated ()
25+
- The DETERMINISIC settings was marked as deprecated (#26653)
26+
- Some musl-internal headers are no longer installed into the sysroot include
27+
directory. In particular, `syscall_arch.h` no longer exists, but can be
28+
replaced with `emscripten/syscalls.h`. (#26658)
2629

2730
5.0.5 - 04/03/26
2831
----------------
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright 2026 The Emscripten Authors. All rights reserved.
3+
* Emscripten is available under two separate licenses, the MIT license and the
4+
* University of Illinois/NCSA Open Source License. Both these licenses can be
5+
* found in the LICENSE file.
6+
*/
7+
8+
#pragma once
9+
10+
#include <stddef.h>
11+
#include <stdint.h>
12+
#include <sys/types.h>
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
int __syscall_chdir(intptr_t path);
19+
int __syscall_mknod(intptr_t path, int mode, int dev);
20+
int __syscall_chmod(intptr_t path, int mode);
21+
int __syscall_getpid(void);
22+
int __syscall_pause(void);
23+
int __syscall_access(intptr_t path, int amode);
24+
int __syscall_sync(void);
25+
int __syscall_rmdir(intptr_t path);
26+
int __syscall_dup(int fd);
27+
int __syscall_acct(intptr_t filename);
28+
int __syscall_ioctl(int fd, int request, ...);
29+
int __syscall_setpgid(int pid, int gpid);
30+
int __syscall_umask(int mask);
31+
int __syscall_getppid(void);
32+
int __syscall_getpgrp(void);
33+
int __syscall_setsid(void);
34+
int __syscall_getrusage(int who, intptr_t usage);
35+
int __syscall_munmap(intptr_t addr, size_t len);
36+
int __syscall_fchmod(int fd, int mode);
37+
int __syscall_getpriority(int which, int who);
38+
int __syscall_setpriority(int which, int who, int prio);
39+
int __syscall_socketcall(int call, intptr_t args);
40+
int __syscall_wait4(int pid, intptr_t wstatus, int options, int rusage);
41+
int __syscall_setdomainname(intptr_t name, size_t size);
42+
int __syscall_uname(intptr_t buf);
43+
int __syscall_mprotect(size_t addr, size_t len, int prot);
44+
int __syscall_getpgid(int pid);
45+
int __syscall_fchdir(int fd);
46+
int __syscall_msync(intptr_t addr, size_t len, int flags);
47+
int __syscall_getsid(int pid);
48+
int __syscall_fdatasync(int fd);
49+
int __syscall_mlock(intptr_t addr, size_t len);
50+
int __syscall_munlock(intptr_t addr, size_t len);
51+
int __syscall_mlockall(int flags);
52+
int __syscall_munlockall(void);
53+
int __syscall_mremap(intptr_t old_addr, size_t old_size, size_t new_size, int flags, intptr_t new_addr);
54+
int __syscall_poll(intptr_t fds, int nfds, int timeout);
55+
int __syscall_getcwd(intptr_t buf, size_t size);
56+
intptr_t __syscall_mmap2(intptr_t addr, size_t len, int prot, int flags, int fd, off_t offset);
57+
int __syscall_truncate64(intptr_t path, off_t length);
58+
int __syscall_ftruncate64(int fd, off_t length);
59+
int __syscall_stat64(intptr_t path, intptr_t buf);
60+
int __syscall_lstat64(intptr_t path, intptr_t buf);
61+
int __syscall_fstat64(int fd, intptr_t buf);
62+
int __syscall_getuid32(void);
63+
int __syscall_getgid32(void);
64+
int __syscall_geteuid32(void);
65+
int __syscall_getegid32(void);
66+
int __syscall_setreuid32(int ruid, int euid);
67+
int __syscall_setregid32(int rgid, int egid);
68+
int __syscall_getgroups32(int size, intptr_t list);
69+
int __syscall_fchown32(int fd, int owner, int group);
70+
int __syscall_setresuid32(int ruid, int euid, int suid);
71+
int __syscall_getresuid32(intptr_t ruid, intptr_t euid, intptr_t suid);
72+
int __syscall_setresgid32(int rgid, int egid, int sgid);
73+
int __syscall_getresgid32(intptr_t rgid, intptr_t egid, intptr_t sgid);
74+
int __syscall_setuid32(int uid);
75+
int __syscall_setgid32(int uid);
76+
int __syscall_mincore(intptr_t addr, size_t length, intptr_t vec);
77+
int __syscall_madvise(intptr_t addr, size_t length, int advice);
78+
int __syscall_getdents64(int fd, intptr_t dirp, size_t count);
79+
int __syscall_fcntl64(int fd, int cmd, ...);
80+
int __syscall_statfs64(intptr_t path, size_t size, intptr_t buf);
81+
int __syscall_fstatfs64(int fd, size_t size, intptr_t buf);
82+
int __syscall_fadvise64(int fd, off_t offset, off_t length, int advice);
83+
int __syscall_openat(int dirfd, intptr_t path, int flags, ...); // mode is optional
84+
int __syscall_mkdirat(int dirfd, intptr_t path, int mode);
85+
int __syscall_mknodat(int dirfd, intptr_t path, int mode, int dev);
86+
int __syscall_fchownat(int dirfd, intptr_t path, int owner, int group, int flags);
87+
int __syscall_newfstatat(int dirfd, intptr_t path, intptr_t buf, int flags);
88+
int __syscall_unlinkat(int dirfd, intptr_t path, int flags);
89+
int __syscall_renameat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath);
90+
int __syscall_linkat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath, int flags);
91+
int __syscall_symlinkat(intptr_t target, int newdirfd, intptr_t linkpath);
92+
int __syscall_readlinkat(int dirfd, intptr_t path, intptr_t buf, size_t bufsize);
93+
int __syscall_fchmodat2(int dirfd, intptr_t path, int mode, int flags);
94+
int __syscall_faccessat(int dirfd, intptr_t path, int amode, int flags);
95+
int __syscall_utimensat(int dirfd, intptr_t path, intptr_t times, int flags);
96+
int __syscall_fallocate(int fd, int mode, off_t offset, off_t len);
97+
int __syscall_dup3(int fd, int suggestfd, int flags);
98+
int __syscall_pipe2(intptr_t fds, int flags);
99+
int __syscall_recvmmsg(int sockfd, intptr_t msgvec, size_t vlen, int flags, ...);
100+
int __syscall_prlimit64(int pid, int resource, intptr_t new_limit, intptr_t old_limit);
101+
int __syscall_sendmmsg(int sockfd, intptr_t msgvec, size_t vlen, int flags, ...);
102+
int __syscall_socket(int domain, int type, int protocol, int dummy1, int dummy2, int dummy3);
103+
int __syscall_socketpair(int domain, int type, int protocol, intptr_t fds, int dummy, int dummy2);
104+
int __syscall_bind(int sockfd, intptr_t addr, size_t alen, int dummy, int dummy2, int dummy3);
105+
int __syscall_connect(int sockfd, intptr_t addr, size_t len, int dummy, int dummy2, int dummy3);
106+
int __syscall_listen(int sockfd, int backlog, int dummy1, int dummy2, int dummy3, int dummy4);
107+
int __syscall_accept4(int sockfd, intptr_t addr, intptr_t addrlen, int flags, int dummy1, int dummy2);
108+
int __syscall_getsockopt(int sockfd, int level, int optname, intptr_t optval, intptr_t optlen, int dummy);
109+
int __syscall_setsockopt(int sockfd, int level, int optname, intptr_t optval, size_t optlen, int dummy);
110+
int __syscall_getsockname(int sockfd, intptr_t addr, intptr_t len, int dummy, int dummy2, int dummy3);
111+
int __syscall_getpeername(int sockfd, intptr_t addr, intptr_t len, int dummy, int dummy2, int dummy3);
112+
int __syscall_sendto(int sockfd, intptr_t msg, size_t len, int flags, intptr_t addr, size_t alen);
113+
int __syscall_sendmsg(int sockfd, intptr_t msg , int flags, intptr_t addr, size_t alen, int dummy);
114+
int __syscall_recvfrom(int sockfd, intptr_t msg, size_t len, int flags, intptr_t addr, intptr_t alen);
115+
int __syscall_recvmsg(int sockfd, intptr_t msg, int flags, int dummy, int dummy2, int dummy3);
116+
int __syscall_shutdown(int sockfd, int how, int dummy, int dummy2, int dummy3, int dummy4);
117+
118+
#ifdef __cplusplus
119+
}
120+
#endif

system/lib/libc/emscripten_syscall_stubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
#include <stdio.h>
1616
#include <sys/types.h>
1717
#include <unistd.h>
18-
#include <syscall_arch.h>
1918
#include <string.h>
2019
#include <sys/resource.h>
2120
#include <sys/stat.h>
2221
#include <time.h>
2322
#include <sys/utsname.h>
23+
#include <emscripten/syscalls.h>
2424
#include <emscripten/console.h>
2525
#include <emscripten/version.h>
2626
#include <emscripten/stack.h>
Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,8 @@
1-
#include <sys/types.h>
21
#include <wasi/api.h>
32
#include <wasi/wasi-helpers.h>
3+
#include <emscripten/syscalls.h>
44

5-
// Compile as if we can pass uint64 values directly to the
6-
// host. Binaryen will take care of splitting any i64 params
7-
// into a pair of i32 values if needed.
5+
// Compile as if we can pass uint64 values directly to the host. Binaryen will
6+
// take care of splitting any i64 params into a pair of i32 values if needed.
87
#define __SYSCALL_LL_E(x) (x)
98
#define __SYSCALL_LL_O(x) (x)
10-
11-
#ifdef __cplusplus
12-
extern "C" {
13-
#endif
14-
15-
int __syscall_chdir(intptr_t path);
16-
int __syscall_mknod(intptr_t path, int mode, int dev);
17-
int __syscall_chmod(intptr_t path, int mode);
18-
int __syscall_getpid(void);
19-
int __syscall_pause(void);
20-
int __syscall_access(intptr_t path, int amode);
21-
int __syscall_sync(void);
22-
int __syscall_rmdir(intptr_t path);
23-
int __syscall_dup(int fd);
24-
int __syscall_acct(intptr_t filename);
25-
int __syscall_ioctl(int fd, int request, ...);
26-
int __syscall_setpgid(int pid, int gpid);
27-
int __syscall_umask(int mask);
28-
int __syscall_getppid(void);
29-
int __syscall_getpgrp(void);
30-
int __syscall_setsid(void);
31-
int __syscall_getrusage(int who, intptr_t usage);
32-
int __syscall_munmap(intptr_t addr, size_t len);
33-
int __syscall_fchmod(int fd, int mode);
34-
int __syscall_getpriority(int which, int who);
35-
int __syscall_setpriority(int which, int who, int prio);
36-
int __syscall_socketcall(int call, intptr_t args);
37-
int __syscall_wait4(int pid, intptr_t wstatus, int options, int rusage);
38-
int __syscall_setdomainname(intptr_t name, size_t size);
39-
int __syscall_uname(intptr_t buf);
40-
int __syscall_mprotect(size_t addr, size_t len, int prot);
41-
int __syscall_getpgid(int pid);
42-
int __syscall_fchdir(int fd);
43-
int __syscall_msync(intptr_t addr, size_t len, int flags);
44-
int __syscall_getsid(int pid);
45-
int __syscall_fdatasync(int fd);
46-
int __syscall_mlock(intptr_t addr, size_t len);
47-
int __syscall_munlock(intptr_t addr, size_t len);
48-
int __syscall_mlockall(int flags);
49-
int __syscall_munlockall(void);
50-
int __syscall_mremap(intptr_t old_addr, size_t old_size, size_t new_size, int flags, intptr_t new_addr);
51-
int __syscall_poll(intptr_t fds, int nfds, int timeout);
52-
int __syscall_getcwd(intptr_t buf, size_t size);
53-
intptr_t __syscall_mmap2(intptr_t addr, size_t len, int prot, int flags, int fd, off_t offset);
54-
int __syscall_truncate64(intptr_t path, off_t length);
55-
int __syscall_ftruncate64(int fd, off_t length);
56-
int __syscall_stat64(intptr_t path, intptr_t buf);
57-
int __syscall_lstat64(intptr_t path, intptr_t buf);
58-
int __syscall_fstat64(int fd, intptr_t buf);
59-
int __syscall_getuid32(void);
60-
int __syscall_getgid32(void);
61-
int __syscall_geteuid32(void);
62-
int __syscall_getegid32(void);
63-
int __syscall_setreuid32(int ruid, int euid);
64-
int __syscall_setregid32(int rgid, int egid);
65-
int __syscall_getgroups32(int size, intptr_t list);
66-
int __syscall_fchown32(int fd, int owner, int group);
67-
int __syscall_setresuid32(int ruid, int euid, int suid);
68-
int __syscall_getresuid32(intptr_t ruid, intptr_t euid, intptr_t suid);
69-
int __syscall_setresgid32(int rgid, int egid, int sgid);
70-
int __syscall_getresgid32(intptr_t rgid, intptr_t egid, intptr_t sgid);
71-
int __syscall_setuid32(int uid);
72-
int __syscall_setgid32(int uid);
73-
int __syscall_mincore(intptr_t addr, size_t length, intptr_t vec);
74-
int __syscall_madvise(intptr_t addr, size_t length, int advice);
75-
int __syscall_getdents64(int fd, intptr_t dirp, size_t count);
76-
int __syscall_fcntl64(int fd, int cmd, ...);
77-
int __syscall_statfs64(intptr_t path, size_t size, intptr_t buf);
78-
int __syscall_fstatfs64(int fd, size_t size, intptr_t buf);
79-
int __syscall_fadvise64(int fd, off_t offset, off_t length, int advice);
80-
int __syscall_openat(int dirfd, intptr_t path, int flags, ...); // mode is optional
81-
int __syscall_mkdirat(int dirfd, intptr_t path, int mode);
82-
int __syscall_mknodat(int dirfd, intptr_t path, int mode, int dev);
83-
int __syscall_fchownat(int dirfd, intptr_t path, int owner, int group, int flags);
84-
int __syscall_newfstatat(int dirfd, intptr_t path, intptr_t buf, int flags);
85-
int __syscall_unlinkat(int dirfd, intptr_t path, int flags);
86-
int __syscall_renameat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath);
87-
int __syscall_linkat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath, int flags);
88-
int __syscall_symlinkat(intptr_t target, int newdirfd, intptr_t linkpath);
89-
int __syscall_readlinkat(int dirfd, intptr_t path, intptr_t buf, size_t bufsize);
90-
int __syscall_fchmodat2(int dirfd, intptr_t path, int mode, int flags);
91-
int __syscall_faccessat(int dirfd, intptr_t path, int amode, int flags);
92-
int __syscall_utimensat(int dirfd, intptr_t path, intptr_t times, int flags);
93-
int __syscall_fallocate(int fd, int mode, off_t offset, off_t len);
94-
int __syscall_dup3(int fd, int suggestfd, int flags);
95-
int __syscall_pipe2(intptr_t fds, int flags);
96-
int __syscall_recvmmsg(int sockfd, intptr_t msgvec, size_t vlen, int flags, ...);
97-
int __syscall_prlimit64(int pid, int resource, intptr_t new_limit, intptr_t old_limit);
98-
int __syscall_sendmmsg(int sockfd, intptr_t msgvec, size_t vlen, int flags, ...);
99-
int __syscall_socket(int domain, int type, int protocol, int dummy1, int dummy2, int dummy3);
100-
int __syscall_socketpair(int domain, int type, int protocol, intptr_t fds, int dummy, int dummy2);
101-
int __syscall_bind(int sockfd, intptr_t addr, size_t alen, int dummy, int dummy2, int dummy3);
102-
int __syscall_connect(int sockfd, intptr_t addr, size_t len, int dummy, int dummy2, int dummy3);
103-
int __syscall_listen(int sockfd, int backlog, int dummy1, int dummy2, int dummy3, int dummy4);
104-
int __syscall_accept4(int sockfd, intptr_t addr, intptr_t addrlen, int flags, int dummy1, int dummy2);
105-
int __syscall_getsockopt(int sockfd, int level, int optname, intptr_t optval, intptr_t optlen, int dummy);
106-
int __syscall_setsockopt(int sockfd, int level, int optname, intptr_t optval, size_t optlen, int dummy);
107-
int __syscall_getsockname(int sockfd, intptr_t addr, intptr_t len, int dummy, int dummy2, int dummy3);
108-
int __syscall_getpeername(int sockfd, intptr_t addr, intptr_t len, int dummy, int dummy2, int dummy3);
109-
int __syscall_sendto(int sockfd, intptr_t msg, size_t len, int flags, intptr_t addr, size_t alen);
110-
int __syscall_sendmsg(int sockfd, intptr_t msg , int flags, intptr_t addr, size_t alen, int dummy);
111-
int __syscall_recvfrom(int sockfd, intptr_t msg, size_t len, int flags, intptr_t addr, intptr_t alen);
112-
int __syscall_recvmsg(int sockfd, intptr_t msg, int flags, int dummy, int dummy2, int dummy3);
113-
int __syscall_shutdown(int sockfd, int how, int dummy, int dummy2, int dummy3, int dummy4);
114-
115-
#ifdef __cplusplus
116-
}
117-
#endif

system/lib/wasmfs/js_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// found in the LICENSE file.
55

66
#include <dirent.h>
7-
#include <syscall_arch.h>
87
#include <unistd.h>
98
#include <emscripten/wasmfs.h>
9+
#include <emscripten/syscalls.h>
1010

1111
#include "backend.h"
1212
#include "file.h"

system/lib/wasmfs/syscalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <emscripten/emscripten.h>
1212
#include <emscripten/heap.h>
1313
#include <emscripten/html5.h>
14+
#include <emscripten/syscalls.h>
1415
#include <errno.h>
1516
#include <mutex>
1617
#include <poll.h>
@@ -20,7 +21,6 @@
2021
#include <sys/mman.h>
2122
#include <sys/stat.h>
2223
#include <sys/statfs.h>
23-
#include <syscall_arch.h>
2424
#include <unistd.h>
2525
#include <utility>
2626
#include <vector>

tools/gen_struct_info.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
]
7979

8080
INTERNAL_CFLAGS = [
81+
'-I' + utils.path_from_root('system/lib/libc/musl/arch/emscripten'),
82+
'-I' + utils.path_from_root('system/lib/libc/musl/arch/generic'),
8183
'-I' + utils.path_from_root('system/lib/libc/musl/src/internal'),
8284
'-I' + utils.path_from_root('system/lib/libc/musl/src/include'),
8385
'-I' + utils.path_from_root('system/lib/pthread/'),

tools/system_libs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,8 @@ def get_default_variation(cls, **kwargs):
905905

906906
class MuslInternalLibrary(Library):
907907
includes = [
908+
'system/lib/libc/musl/arch/emscripten',
909+
'system/lib/libc/musl/arch/generic',
908910
'system/lib/libc/musl/src/internal',
909911
'system/lib/libc/musl/src/include',
910912
'system/lib/libc/musl/include',
@@ -918,6 +920,7 @@ class MuslInternalLibrary(Library):
918920
'-Wno-unused-result', # system call results are often ignored in musl, and in wasi that warns
919921
'-Wno-bitwise-op-parentheses',
920922
'-Wno-shift-op-parentheses',
923+
'-Wno-constant-conversion',
921924
]
922925

923926

@@ -2500,10 +2503,10 @@ def install_system_headers(stamp):
25002503
'system/lib/compiler-rt/include': '',
25012504
'system/lib/libunwind/include': '',
25022505
# Copy the generic arch files first then
2503-
'system/lib/libc/musl/arch/generic': '',
2506+
'system/lib/libc/musl/arch/generic/bits': 'bits',
25042507
# Then overlay the emscripten directory on top.
25052508
# This mimics how musl itself installs its headers.
2506-
'system/lib/libc/musl/arch/emscripten': '',
2509+
'system/lib/libc/musl/arch/emscripten/bits': 'bits',
25072510
'system/lib/libc/musl/include': '',
25082511
'system/lib/libcxx/include': 'c++/v1',
25092512
'system/lib/libcxxabi/include': 'c++/v1',

0 commit comments

Comments
 (0)