Skip to content

Commit d72d722

Browse files
authored
Update musl to v1.2.5 (emscripten-core#21598)
1 parent 68855ac commit d72d722

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+533
-172
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.57 (in development)
2222
-----------------------
23+
- musl libc updated from v1.2.4 to v1.2.5. (#21598)
2324
- In `MODULARIZE` mode we no longer export the module ready promise as `ready`.
2425
This was previously exposed on the Module for historical reasons even though
2526
in `MODULARIZE` mode the only way to get access to the module is to wait on

src/library_sigs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ sigs = {
244244
__syscall_fallocate__sig: 'iiijj',
245245
__syscall_fchdir__sig: 'ii',
246246
__syscall_fchmod__sig: 'iii',
247-
__syscall_fchmodat__sig: 'iipip',
247+
__syscall_fchmodat2__sig: 'iipii',
248248
__syscall_fchown32__sig: 'iiii',
249249
__syscall_fchownat__sig: 'iipiii',
250250
__syscall_fcntl64__sig: 'iiip',

src/library_syscall.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,11 @@ var SyscallsLibrary = {
931931
HEAP8[buf+len] = endChar;
932932
return len;
933933
},
934-
__syscall_fchmodat: (dirfd, path, mode, varargs) => {
935-
#if SYSCALL_DEBUG
936-
dbg('warning: untested syscall');
937-
#endif
934+
__syscall_fchmodat2: (dirfd, path, mode, flags) => {
935+
var nofollow = flags & {{{ cDefs.AT_SYMLINK_NOFOLLOW }}};
938936
path = SYSCALLS.getStr(path);
939937
path = SYSCALLS.calculateAt(dirfd, path);
940-
FS.chmod(path, mode);
938+
FS.chmod(path, mode, nofollow);
941939
return 0;
942940
},
943941
__syscall_faccessat: (dirfd, path, amode, flags) => {

system/lib/libc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This folder contains the musl version of libc at `/musl`. The upstream version
22
can be found at http://www.musl-libc.org/.
33

4-
Most of the source comes from musl v1.2.4, with some exceptions listed below.
4+
Most of the source comes from musl v1.2.5, with some exceptions listed below.
55
We track these changes from upstream in https://github.com/emscripten-core/musl
66
and use a script (`system/lib/update_musl.py`) to pull in updates.
77

system/lib/libc/musl/INSTALL

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ and ABI combinations:
9797

9898
* OpenRISC 1000 (or1k)
9999

100-
* RISC-V 64
100+
* RISC-V
101+
* 32-bit and 64-bit
101102
* Little endian
102103
* Hard, soft, and hard-single/soft-double floating point ABIs
103104
* Standard ELF; no shared-text NOMMU support
104105

106+
* LoongArch
107+
* 64-bit ISA
108+
* Hard, soft, and hard-single/soft-double floating point ABIs
109+
105110

106111

107112
Build and Installation Procedure

system/lib/libc/musl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.4
1+
1.2.5

system/lib/libc/musl/WHATSNEW

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,3 +2396,45 @@ arch-specific bugs fixed:
23962396
- sigaction signal mask was bogus on or1k, microblaze, mips, and riscv
23972397
- powerpc-sf longjmp asm clobbered value argument
23982398
- or1k poll function passed timeout to syscall in wrong form
2399+
2400+
2401+
2402+
1.2.5 release notes
2403+
2404+
new features:
2405+
- statx function (linux extension; via syscall and fallback using fstatat)
2406+
- clone function is now usable and gives _Fork-like consistency in child
2407+
- statvfs now provides f_type result
2408+
- preadv2 and pwritev2 (linux extension) syscall wrappers
2409+
- riscv64 TLSDESC support
2410+
2411+
new ports:
2412+
- loongarch64
2413+
- riscv32
2414+
2415+
compatibility:
2416+
- DNS resolver can now handle answers with long CNAME chains
2417+
- string.h no longer provides (C23-incompat) non-prototype decl of basename
2418+
- fstatat statx backend now matches stat syscall non-automounting behavior
2419+
- mntent interfaces now handle escaped whitespace in paths/options
2420+
2421+
standards updates:
2422+
- printf %lc of nul wchar now produces output
2423+
- snprintf and swprintf no longer fail on n > INT_MAX
2424+
- ppoll is now exposed in default feature profile
2425+
2426+
bugs fixed:
2427+
- some long DNS answers were wrongly rejected despite new TCP support
2428+
- glob could wrongly return GLOB_NOMATCH if aborted before any matches
2429+
- multithreaded set*id could malfunction from thread sequencing logic bug
2430+
- certain use of threads after fork could deadlock thread-list lock
2431+
- posix_spawn child could deadlock in race with async parent death
2432+
- mbrtowc return value was wrong if argument n exceeded UINT_MAX
2433+
- 80-bit extended acoshl and powl got some corner cases wrong
2434+
- syslog incorrectly generated localized timestamps
2435+
2436+
arch-specific bugs fixed:
2437+
- arm (32-bit) TLSDESC malfunctioned due to addends being processed wrong
2438+
- riscv64 icache flush operation was non-functional
2439+
- sh sigsetjmp failed to properly restore call-saved register r8 on return
2440+
- sh dlsym RTLD_NEXT did not identify calling module correctly

system/lib/libc/musl/arch/emscripten/bits/syscall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#define SYS_linkat __syscall_linkat
6969
#define SYS_symlinkat __syscall_symlinkat
7070
#define SYS_readlinkat __syscall_readlinkat
71-
#define SYS_fchmodat __syscall_fchmodat
71+
#define SYS_fchmodat2 __syscall_fchmodat2
7272
#define SYS_faccessat __syscall_faccessat
7373
#define SYS_pselect6 __syscall_pselect6
7474
#define SYS_utimensat __syscall_utimensat

system/lib/libc/musl/arch/emscripten/syscall_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int __syscall_renameat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t ne
9292
int __syscall_linkat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath, int flags);
9393
int __syscall_symlinkat(intptr_t target, int newdirfd, intptr_t linkpath);
9494
int __syscall_readlinkat(int dirfd, intptr_t path, intptr_t buf, size_t bufsize);
95-
int __syscall_fchmodat(int dirfd, intptr_t path, int mode, ...);
95+
int __syscall_fchmodat2(int dirfd, intptr_t path, int mode, int flags);
9696
int __syscall_faccessat(int dirfd, intptr_t path, int amode, int flags);
9797
int __syscall_pselect6(int nfds, intptr_t readfds, intptr_t writefds, intptr_t exceptfds, intptr_t timeout, intptr_t sigmaks);
9898
int __syscall_utimensat(int dirfd, intptr_t path, intptr_t times, int flags);

system/lib/libc/musl/configure

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ i?86*) ARCH=i386 ;;
328328
x86_64-x32*|x32*|x86_64*x32) ARCH=x32 ;;
329329
x86_64-nt64*) ARCH=nt64 ;;
330330
x86_64*) ARCH=x86_64 ;;
331+
loongarch64*) ARCH=loongarch64 ;;
331332
m68k*) ARCH=m68k ;;
332333
mips64*|mipsisa64*) ARCH=mips64 ;;
333334
mips*) ARCH=mips ;;
@@ -336,6 +337,7 @@ or1k*) ARCH=or1k ;;
336337
powerpc64*|ppc64*) ARCH=powerpc64 ;;
337338
powerpc*|ppc*) ARCH=powerpc ;;
338339
riscv64*) ARCH=riscv64 ;;
340+
riscv32*) ARCH=riscv32 ;;
339341
sh[1-9bel-]*|sh|superh*) ARCH=sh ;;
340342
s390x*) ARCH=s390x ;;
341343
unknown) fail "$0: unable to detect target arch; try $0 --target=..." ;;
@@ -444,7 +446,20 @@ xno|x) printf "disabled\n" ; optimize=no ;;
444446
*) printf "custom\n" ;;
445447
esac
446448

447-
test "$optimize" = no || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
449+
if test "$optimize" = no ; then :
450+
else
451+
tryflag CFLAGS_AUTO -O2
452+
tryflag CFLAGS_AUTO -fno-align-jumps
453+
tryflag CFLAGS_AUTO -fno-align-functions
454+
tryflag CFLAGS_AUTO -fno-align-loops
455+
tryflag CFLAGS_AUTO -fno-align-labels
456+
tryflag CFLAGS_AUTO -fira-region=one
457+
tryflag CFLAGS_AUTO -fira-hoist-pressure
458+
tryflag CFLAGS_AUTO -freorder-blocks-algorithm=simple \
459+
|| tryflag CFLAGS_AUTO -fno-reorder-blocks
460+
tryflag CFLAGS_AUTO -fno-prefetch-loop-arrays
461+
tryflag CFLAGS_AUTO -fno-tree-ch
462+
fi
448463
test "$optimize" = yes && optimize="internal,malloc,string"
449464

450465
if fnmatch 'no|size' "$optimize" ; then :
@@ -658,6 +673,19 @@ if test "$ARCH" = "aarch64" ; then
658673
trycppif __AARCH64EB__ "$t" && SUBARCH=${SUBARCH}_be
659674
fi
660675

676+
if test "$ARCH" = "loongarch64" ; then
677+
trycppif __loongarch_soft_float "$t" && SUBARCH=${SUBARCH}-sf
678+
trycppif __loongarch_single_float "$t" && SUBARCH=${SUBARCH}-sp
679+
printf "checking whether assembler support FCSRs... "
680+
echo "__asm__(\"movfcsr2gr \$t0,\$fcsr0\");" > "$tmpc"
681+
if $CC -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
682+
printf "yes\n"
683+
else
684+
printf "no\n"
685+
CFLAGS_AUTO="$CFLAGS_AUTO -DBROKEN_LOONGARCH_FCSR_ASM"
686+
fi
687+
fi
688+
661689
if test "$ARCH" = "m68k" ; then
662690
if trycppif "__HAVE_68881__" ; then : ;
663691
elif trycppif "__mcffpu__" ; then SUBARCH="-fp64"
@@ -700,7 +728,7 @@ trycppif __LITTLE_ENDIAN__ "$t" && SUBARCH=${SUBARCH}le
700728
trycppif _SOFT_FLOAT "$t" && fail "$0: error: soft-float not supported on powerpc64"
701729
fi
702730

703-
if test "$ARCH" = "riscv64" ; then
731+
if test "$ARCH" = "riscv64" -o "$ARCH" = "riscv32" ; then
704732
trycppif __riscv_float_abi_soft "$t" && SUBARCH=${SUBARCH}-sf
705733
trycppif __riscv_float_abi_single "$t" && SUBARCH=${SUBARCH}-sp
706734
fi

system/lib/libc/musl/include/elf.h

Lines changed: 120 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ typedef struct {
315315
#define EM_RISCV 243
316316
#define EM_BPF 247
317317
#define EM_CSKY 252
318-
#define EM_NUM 253
318+
#define EM_LOONGARCH 258
319+
#define EM_NUM 259
319320

320321
#define EM_ALPHA 0x9026
321322

@@ -558,6 +559,11 @@ typedef struct {
558559

559560

560561

562+
typedef Elf32_Word Elf32_Relr;
563+
typedef Elf64_Xword Elf64_Relr;
564+
565+
566+
561567
#define ELF32_R_SYM(val) ((val) >> 8)
562568
#define ELF32_R_TYPE(val) ((val) & 0xff)
563569
#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
@@ -698,7 +704,14 @@ typedef struct {
698704
#define NT_MIPS_DSP 0x800
699705
#define NT_MIPS_FP_MODE 0x801
700706
#define NT_MIPS_MSA 0x802
707+
#define NT_RISCV_CSR 0x900
708+
#define NT_RISCV_VECTOR 0x901
701709
#define NT_VERSION 1
710+
#define NT_LOONGARCH_CPUCFG 0xa00
711+
#define NT_LOONGARCH_CSR 0xa01
712+
#define NT_LOONGARCH_LSX 0xa02
713+
#define NT_LOONGARCH_LASX 0xa03
714+
#define NT_LOONGARCH_LBT 0xa04
702715

703716

704717

@@ -3249,6 +3262,7 @@ enum
32493262
#define R_RISCV_TLS_DTPREL64 9
32503263
#define R_RISCV_TLS_TPREL32 10
32513264
#define R_RISCV_TLS_TPREL64 11
3265+
#define R_RISCV_TLSDESC 12
32523266

32533267
#define R_RISCV_BRANCH 16
32543268
#define R_RISCV_JAL 17
@@ -3275,23 +3289,122 @@ enum
32753289
#define R_RISCV_SUB16 38
32763290
#define R_RISCV_SUB32 39
32773291
#define R_RISCV_SUB64 40
3278-
#define R_RISCV_GNU_VTINHERIT 41
3279-
#define R_RISCV_GNU_VTENTRY 42
3292+
#define R_RISCV_GOT32_PCREL 41
32803293
#define R_RISCV_ALIGN 43
32813294
#define R_RISCV_RVC_BRANCH 44
32823295
#define R_RISCV_RVC_JUMP 45
32833296
#define R_RISCV_RVC_LUI 46
3284-
#define R_RISCV_GPREL_I 47
3285-
#define R_RISCV_GPREL_S 48
3286-
#define R_RISCV_TPREL_I 49
3287-
#define R_RISCV_TPREL_S 50
32883297
#define R_RISCV_RELAX 51
32893298
#define R_RISCV_SUB6 52
32903299
#define R_RISCV_SET6 53
32913300
#define R_RISCV_SET8 54
32923301
#define R_RISCV_SET16 55
32933302
#define R_RISCV_SET32 56
32943303
#define R_RISCV_32_PCREL 57
3304+
#define R_RISCV_IRELATIVE 58
3305+
#define R_RISCV_PLT32 59
3306+
#define R_RISCV_SET_ULEB128 60
3307+
#define R_RISCV_SUB_ULEB128 61
3308+
#define R_RISCV_TLSDESC_HI20 62
3309+
#define R_RISCV_TLSDESC_LOAD_LO12 63
3310+
#define R_RISCV_TLSDESC_ADD_LO12 64
3311+
#define R_RISCV_TLSDESC_CALL 65
3312+
3313+
#define EF_LARCH_ABI_MODIFIER_MASK 0x07
3314+
#define EF_LARCH_ABI_SOFT_FLOAT 0x01
3315+
#define EF_LARCH_ABI_SINGLE_FLOAT 0x02
3316+
#define EF_LARCH_ABI_DOUBLE_FLOAT 0x03
3317+
#define EF_LARCH_OBJABI_V1 0x40
3318+
3319+
#define R_LARCH_NONE 0
3320+
#define R_LARCH_32 1
3321+
#define R_LARCH_64 2
3322+
#define R_LARCH_RELATIVE 3
3323+
#define R_LARCH_COPY 4
3324+
#define R_LARCH_JUMP_SLOT 5
3325+
#define R_LARCH_TLS_DTPMOD32 6
3326+
#define R_LARCH_TLS_DTPMOD64 7
3327+
#define R_LARCH_TLS_DTPREL32 8
3328+
#define R_LARCH_TLS_DTPREL64 9
3329+
#define R_LARCH_TLS_TPREL32 10
3330+
#define R_LARCH_TLS_TPREL64 11
3331+
#define R_LARCH_IRELATIVE 12
3332+
#define R_LARCH_MARK_LA 20
3333+
#define R_LARCH_MARK_PCREL 21
3334+
#define R_LARCH_SOP_PUSH_PCREL 22
3335+
#define R_LARCH_SOP_PUSH_ABSOLUTE 23
3336+
#define R_LARCH_SOP_PUSH_DUP 24
3337+
#define R_LARCH_SOP_PUSH_GPREL 25
3338+
#define R_LARCH_SOP_PUSH_TLS_TPREL 26
3339+
#define R_LARCH_SOP_PUSH_TLS_GOT 27
3340+
#define R_LARCH_SOP_PUSH_TLS_GD 28
3341+
#define R_LARCH_SOP_PUSH_PLT_PCREL 29
3342+
#define R_LARCH_SOP_ASSERT 30
3343+
#define R_LARCH_SOP_NOT 31
3344+
#define R_LARCH_SOP_SUB 32
3345+
#define R_LARCH_SOP_SL 33
3346+
#define R_LARCH_SOP_SR 34
3347+
#define R_LARCH_SOP_ADD 35
3348+
#define R_LARCH_SOP_AND 36
3349+
#define R_LARCH_SOP_IF_ELSE 37
3350+
#define R_LARCH_SOP_POP_32_S_10_5 38
3351+
#define R_LARCH_SOP_POP_32_U_10_12 39
3352+
#define R_LARCH_SOP_POP_32_S_10_12 40
3353+
#define R_LARCH_SOP_POP_32_S_10_16 41
3354+
#define R_LARCH_SOP_POP_32_S_10_16_S2 42
3355+
#define R_LARCH_SOP_POP_32_S_5_20 43
3356+
#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2 44
3357+
#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2 45
3358+
#define R_LARCH_SOP_POP_32_U 46
3359+
#define R_LARCH_ADD8 47
3360+
#define R_LARCH_ADD16 48
3361+
#define R_LARCH_ADD24 49
3362+
#define R_LARCH_ADD32 50
3363+
#define R_LARCH_ADD64 51
3364+
#define R_LARCH_SUB8 52
3365+
#define R_LARCH_SUB16 53
3366+
#define R_LARCH_SUB24 54
3367+
#define R_LARCH_SUB32 55
3368+
#define R_LARCH_SUB64 56
3369+
#define R_LARCH_GNU_VTINHERIT 57
3370+
#define R_LARCH_GNU_VTENTRY 58
3371+
#define R_LARCH_B16 64
3372+
#define R_LARCH_B21 65
3373+
#define R_LARCH_B26 66
3374+
#define R_LARCH_ABS_HI20 67
3375+
#define R_LARCH_ABS_LO12 68
3376+
#define R_LARCH_ABS64_LO20 69
3377+
#define R_LARCH_ABS64_HI12 70
3378+
#define R_LARCH_PCALA_HI20 71
3379+
#define R_LARCH_PCALA_LO12 72
3380+
#define R_LARCH_PCALA64_LO20 73
3381+
#define R_LARCH_PCALA64_HI12 74
3382+
#define R_LARCH_GOT_PC_HI20 75
3383+
#define R_LARCH_GOT_PC_LO12 76
3384+
#define R_LARCH_GOT64_PC_LO20 77
3385+
#define R_LARCH_GOT64_PC_HI12 78
3386+
#define R_LARCH_GOT_HI20 79
3387+
#define R_LARCH_GOT_LO12 80
3388+
#define R_LARCH_GOT64_LO20 81
3389+
#define R_LARCH_GOT64_HI12 82
3390+
#define R_LARCH_TLS_LE_HI20 83
3391+
#define R_LARCH_TLS_LE_LO12 84
3392+
#define R_LARCH_TLS_LE64_LO20 85
3393+
#define R_LARCH_TLS_LE64_HI12 86
3394+
#define R_LARCH_TLS_IE_PC_HI20 87
3395+
#define R_LARCH_TLS_IE_PC_LO12 88
3396+
#define R_LARCH_TLS_IE64_PC_LO20 89
3397+
#define R_LARCH_TLS_IE64_PC_HI12 90
3398+
#define R_LARCH_TLS_IE_HI20 91
3399+
#define R_LARCH_TLS_IE_LO12 92
3400+
#define R_LARCH_TLS_IE64_LO20 93
3401+
#define R_LARCH_TLS_IE64_HI12 94
3402+
#define R_LARCH_TLS_LD_PC_HI20 95
3403+
#define R_LARCH_TLS_LD_HI20 96
3404+
#define R_LARCH_TLS_GD_PC_HI20 97
3405+
#define R_LARCH_TLS_GD_HI20 98
3406+
#define R_LARCH_32_PCREL 99
3407+
#define R_LARCH_RELAX 100
32953408

32963409
#ifdef __cplusplus
32973410
}

system/lib/libc/musl/include/fcntl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ struct f_owner_ex {
194194
#define SPLICE_F_MORE 4
195195
#define SPLICE_F_GIFT 8
196196
int fallocate(int, int, off_t, off_t);
197-
#define fallocate64 fallocate
198197
int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
199198
int open_by_handle_at(int, struct file_handle *, int);
200199
ssize_t readahead(int, off_t, size_t);
@@ -217,6 +216,9 @@ ssize_t tee(int, int, size_t, unsigned);
217216
#define posix_fadvise64 posix_fadvise
218217
#define posix_fallocate64 posix_fallocate
219218
#define off64_t off_t
219+
#if defined(_GNU_SOURCE)
220+
#define fallocate64 fallocate
221+
#endif
220222
#endif
221223

222224
#ifdef __cplusplus

0 commit comments

Comments
 (0)