Skip to content

Commit 870e53a

Browse files
committed
Update musl to v1.2.2
1 parent 64398b6 commit 870e53a

File tree

882 files changed

+18477
-9411
lines changed

Some content is hidden

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

882 files changed

+18477
-9411
lines changed

src/library_pthread.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ var LibraryPThread = {
364364
} else if (cmd === 'alert') {
365365
alert('Thread ' + d['threadId'] + ': ' + d['text']);
366366
} else if (cmd === 'exit') {
367-
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detached }}}) >> 2);
367+
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detach_state }}}) >> 2);
368368
if (detached) {
369369
PThread.returnWorkerToPool(worker);
370370
}
@@ -536,10 +536,11 @@ var LibraryPThread = {
536536
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.threadStatus }}} >> 2), 0); // threadStatus <- 0, meaning not yet exited.
537537
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.threadExitCode }}} >> 2), 0); // threadExitCode <- 0.
538538
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.profilerBlock }}} >> 2), 0); // profilerBlock <- 0.
539-
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detached }}} >> 2), threadParams.detached);
539+
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detach_state }}} >> 2), threadParams.detached);
540540
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tsd }}} >> 2), tlsMemory); // Init thread-local-storage memory array.
541541
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tsd_used }}} >> 2), 0); // Mark initial status to unused.
542542
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tid }}} >> 2), pthread.threadInfoStruct); // Main thread ID.
543+
543544
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack_size }}} >> 2), threadParams.stackSize);
544545
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack }}} >> 2), stackHigh);
545546
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.attr }}} >> 2), threadParams.stackSize);
@@ -862,7 +863,7 @@ var LibraryPThread = {
862863
return ERRNO_CODES.ESRCH;
863864
}
864865

865-
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2);
866+
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2);
866867
if (detached) {
867868
err('Attempted to join thread ' + thread + ', which was already detached!');
868869
return ERRNO_CODES.EINVAL; // The thread is already detached, can no longer join it!
@@ -879,7 +880,7 @@ var LibraryPThread = {
879880
if (threadStatus == 1) { // Exited?
880881
var threadExitCode = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2);
881882
if (status) {{{ makeSetValue('status', 0, 'threadExitCode', 'i32') }}};
882-
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 1); // Mark the thread as detached.
883+
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 1); // Mark the thread as detached.
883884

884885
if (!ENVIRONMENT_IS_PTHREAD) cleanupThread(thread);
885886
else postMessage({ 'cmd': 'cleanupThread', 'thread': thread });
@@ -968,7 +969,7 @@ var LibraryPThread = {
968969
// Follow musl convention: detached:0 means not detached, 1 means the thread
969970
// was created as detached, and 2 means that the thread was detached via
970971
// pthread_detach.
971-
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 0, 2);
972+
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 0, 2);
972973

973974
return wasDetached ? ERRNO_CODES.EINVAL : 0;
974975
},

src/library_pthread_stub.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ var LibraryPThreadStub = {
1717
#endif
1818
},
1919

20-
pthread_cleanup_push__sig: 'vii',
21-
pthread_cleanup_push: function(routine, arg) {
20+
_pthread_cleanup_push__sig: 'viii',
21+
_pthread_cleanup_push: function(ptr, routine, arg) {
2222
__ATEXIT__.push({ func: routine, arg: arg });
23-
_pthread_cleanup_push.level = __ATEXIT__.length;
23+
__pthread_cleanup_push.level = __ATEXIT__.length;
2424
},
2525

26-
pthread_cleanup_pop__sig: 'vi',
27-
pthread_cleanup_pop: function(execute) {
28-
assert(_pthread_cleanup_push.level == __ATEXIT__.length, 'cannot pop if something else added meanwhile!');
26+
_pthread_cleanup_pop__deps: ['_pthread_cleanup_push'],
27+
_pthread_cleanup_pop__sig: 'vii',
28+
_pthread_cleanup_pop: function(ptr, execute) {
29+
assert(__pthread_cleanup_push.level == __ATEXIT__.length, 'cannot pop if something else added meanwhile!');
2930
callback = __ATEXIT__.pop();
3031
if (execute) {
3132
{{{ makeDynCall('vi', 'callback.func') }}}(callback.arg)
3233
}
33-
_pthread_cleanup_push.level = __ATEXIT__.length;
34+
__pthread_cleanup_push.level = __ATEXIT__.length;
3435
},
3536

3637
{{{ USE_LSAN || USE_ASAN ? 'emscripten_builtin_' : '' }}}pthread_create: function() {

src/struct_info.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@
208208
"tv_sec",
209209
"tv_usec"
210210
]
211-
},
212-
"defines": []
211+
}
213212
},
214213
{
215214
"file": "time.h",

system/include/compat/sys/random.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
// syscall which is unnecessary indirection for us.
1010
int getentropy(void *buffer, size_t length);
1111

12+
#include_next <sys/random.h>
13+
1214
#ifdef __cplusplus
1315
}
1416
#endif

system/lib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ extern struct ps_strings *__ps_strings;
102102
#endif
103103

104104
#if SANITIZER_EMSCRIPTEN
105+
#define weak __attribute__(__weak__)
106+
#define hidden __attribute__((__visibility__("hidden")))
105107
#include <syscall.h>
108+
#undef weak
109+
#undef hidden
106110
#include <emscripten/threading.h>
107111
#include <math.h>
108112
#include <wasi/api.h>

system/lib/libc/compat/aligned_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Musl has an aligned_alloc routine, but that builds on top of standard malloc(). We are using dlmalloc, so
44
// can route to its implementation instead.
5-
void * __attribute__((weak)) aligned_alloc(size_t alignment, size_t size)
5+
void * weak aligned_alloc(size_t alignment, size_t size)
66
{
77
void *ptr;
88
if ((alignment % sizeof(void *) != 0) || (size % alignment) != 0)

system/lib/libc/crt1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <stdlib.h>
1313
#include <wasi/api.h>
1414

15-
__attribute__((weak)) void __wasm_call_ctors(void);
15+
__attribute__((__weak__)) void __wasm_call_ctors(void);
1616

1717
int __original_main(void);
1818

system/lib/libc/emscripten_asan_strchrnul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ char *__strchrnul(const char *s, int c)
1212
return (char *) s;
1313
}
1414

15-
extern __typeof(__strchrnul) strchrnul __attribute__((weak, alias("__strchrnul")));
15+
extern __typeof(__strchrnul) strchrnul __attribute__((__weak__, alias("__strchrnul")));

system/lib/libc/musl/COPYRIGHT

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
musl as a whole is licensed under the following standard MIT license:
22

33
----------------------------------------------------------------------
4-
Copyright © 2005-2014 Rich Felker, et al.
4+
Copyright © 2005-2020 Rich Felker, et al.
55

66
Permission is hereby granted, free of charge, to any person obtaining
77
a copy of this software and associated documentation files (the
@@ -25,22 +25,39 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525

2626
Authors/contributors include:
2727

28+
A. Wilcox
29+
Ada Worcester
2830
Alex Dowad
31+
Alex Suykov
2932
Alexander Monakov
33+
Andre McCurdy
34+
Andrew Kelley
3035
Anthony G. Basile
36+
Aric Belsito
3137
Arvid Picciani
38+
Bartosz Brachaczek
39+
Benjamin Peterson
3240
Bobby Bingham
3341
Boris Brezillon
3442
Brent Cook
3543
Chris Spiegel
3644
Clément Vasseur
3745
Daniel Micay
46+
Daniel Sabogal
47+
Daurnimator
48+
David Carlier
49+
David Edelsohn
3850
Denys Vlasenko
51+
Dmitry Ivanov
52+
Dmitry V. Levin
53+
Drew DeVault
3954
Emil Renner Berthing
55+
Fangrui Song
4056
Felix Fietkau
4157
Felix Janda
4258
Gianluca Anzolin
4359
Hauke Mehrtens
60+
He X
4461
Hiltjo Posthuma
4562
Isaac Dunham
4663
Jaydeep Patil
@@ -49,32 +66,47 @@ Jeremy Huntwork
4966
Jo-Philipp Wich
5067
Joakim Sindholt
5168
John Spencer
52-
Josiah Worcester
69+
Julien Ramseier
5370
Justin Cormack
71+
Kaarle Ritvanen
5472
Khem Raj
5573
Kylie McClain
74+
Leah Neukirchen
5675
Luca Barbato
5776
Luka Perkov
5877
M Farkas-Dyck (Strake)
5978
Mahesh Bodapati
79+
Markus Wichmann
80+
Masanori Ogino
81+
Michael Clark
6082
Michael Forney
83+
Mikhail Kremnyov
6184
Natanael Copa
6285
Nicholas J. Kain
6386
orc
6487
Pascal Cuoq
88+
Patrick Oppenlander
6589
Petr Hosek
90+
Petr Skocik
6691
Pierre Carrier
92+
Reini Urban
6793
Rich Felker
6894
Richard Pennington
95+
Ryan Fairfax
96+
Samuel Holland
97+
Segev Finer
6998
Shiz
7099
sin
71100
Solar Designer
72101
Stefan Kristiansson
102+
Stefan O'Rear
73103
Szabolcs Nagy
74104
Timo Teräs
75105
Trutz Behn
76106
Valentin Ochs
107+
Will Dietz
77108
William Haddon
109+
William Pitcock
78110

79111
Portions of this software are derived from third-party works licensed
80112
under terms compatible with the above MIT license:
@@ -90,14 +122,18 @@ Copyright © 1993,2004 Sun Microsystems or
90122
Copyright © 2003-2011 David Schultz or
91123
Copyright © 2003-2009 Steven G. Kargl or
92124
Copyright © 2003-2009 Bruce D. Evans or
93-
Copyright © 2008 Stephen L. Moshier
125+
Copyright © 2008 Stephen L. Moshier or
126+
Copyright © 2017-2018 Arm Limited
94127
and labelled as such in comments in the individual source files. All
95128
have been licensed under extremely permissive terms.
96129

97-
The ARM memcpy code (src/string/arm/memcpy_el.S) is Copyright © 2008
130+
The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
98131
The Android Open Source Project and is licensed under a two-clause BSD
99132
license. It was taken from Bionic libc, used on Android.
100133

134+
The AArch64 memcpy and memset code (src/string/aarch64/*) are
135+
Copyright © 1999-2019, Arm Limited.
136+
101137
The implementation of DES for crypt (src/crypt/crypt_des.c) is
102138
Copyright © 1994 David Burren. It is licensed under a BSD license.
103139

@@ -109,12 +145,6 @@ in jurisdictions that may not recognize the public domain.
109145
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
110146
Valentin Ochs and is licensed under an MIT-style license.
111147

112-
The BSD PRNG implementation (src/prng/random.c) and XSI search API
113-
(src/search/*.c) functions are Copyright © 2011 Szabolcs Nagy and
114-
licensed under following terms: "Permission to use, copy, modify,
115-
and/or distribute this code for any purpose with or without fee is
116-
hereby granted. There is no warranty."
117-
118148
The x86_64 port was written by Nicholas J. Kain and is licensed under
119149
the standard MIT terms.
120150

system/lib/libc/musl/INSTALL

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,35 @@ and ABI combinations:
5555
* Little-endian default; big-endian variants also supported
5656

5757
* MIPS
58-
* ABI is o32
58+
* ABI is o32, fp32/fpxx (except on r6 which is fp64)
5959
* Big-endian default; little-endian variants also supported
6060
* Default ABI variant uses FPU registers; alternate soft-float ABI
6161
that does not use FPU registers or instructions is available
6262
* MIPS2 or later, or kernel emulation of ll/sc (standard in Linux)
6363
is required
64+
* MIPS32r6, an incompatible ISA, is supported as a variant "mipsr6"
6465

6566
* MIPS64
66-
* ABI is n64 (LP64)
67+
* ABI is n64 (LP64) or n32 (ILP32)
6768
* Big-endian default; little-endian variants also supported
6869
* Default ABI variant uses FPU registers; alternate soft-float ABI
6970
that does not use FPU registers or instructions is available
7071

7172
* PowerPC
72-
* Only 32-bit is supported
7373
* Compiler toolchain must provide 64-bit long double, not IBM
7474
double-double or IEEE quad
7575
* For dynamic linking, compiler toolchain must be configured for
7676
"secure PLT" variant
7777

78+
* PowerPC64
79+
* Both little and big endian variants are supported
80+
* Compiler toolchain must provide 64-bit long double, not IBM
81+
double-double or IEEE quad
82+
* Compiler toolchain must use the new (ELFv2) ABI regardless of
83+
whether it is for little or big endian
84+
85+
* S390X (64-bit S390)
86+
7887
* SuperH (SH)
7988
* Standard ELF ABI or FDPIC ABI (shared-text without MMU)
8089
* Little-endian by default; big-engian variant also supported
@@ -88,6 +97,11 @@ and ABI combinations:
8897

8998
* OpenRISC 1000 (or1k)
9099

100+
* RISC-V 64
101+
* Little endian
102+
* Hard, soft, and hard-single/soft-double floating point ABIs
103+
* Standard ELF; no shared-text NOMMU support
104+
91105

92106

93107
Build and Installation Procedure

system/lib/libc/musl/Makefile

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ includedir = $(prefix)/include
1717
libdir = $(prefix)/lib
1818
syslibdir = /lib
1919

20-
SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso)
20+
MALLOC_DIR = mallocng
21+
SRC_DIRS = $(addprefix $(srcdir)/,src/* src/malloc/$(MALLOC_DIR) crt ldso $(COMPAT_SRC_DIRS))
2122
BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS))
2223
ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS))
2324
BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS)))
@@ -27,15 +28,15 @@ ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS)))
2728
REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS)))
2829
ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS))))
2930

30-
LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS))
31+
LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS)) $(filter obj/compat/%,$(ALL_OBJS))
3132
LDSO_OBJS = $(filter obj/ldso/%,$(ALL_OBJS:%.o=%.lo))
3233
CRT_OBJS = $(filter obj/crt/%,$(ALL_OBJS))
3334

3435
AOBJS = $(LIBC_OBJS)
3536
LOBJS = $(LIBC_OBJS:.o=.lo)
3637
GENH = obj/include/bits/alltypes.h obj/include/bits/syscall.h
3738
GENH_INT = obj/src/internal/version.h
38-
IMPH = $(addprefix $(srcdir)/, src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/libc.h)
39+
IMPH = $(addprefix $(srcdir)/, src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/locale_impl.h src/internal/libc.h)
3940

4041
LDFLAGS =
4142
LDFLAGS_AUTO =
@@ -46,7 +47,7 @@ CFLAGS_AUTO = -Os -pipe
4647
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
4748

4849
CFLAGS_ALL = $(CFLAGS_C99FSE)
49-
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
50+
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
5051
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
5152

5253
LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
@@ -75,6 +76,7 @@ WRAPCC_CLANG = clang
7576
LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1
7677

7778
-include config.mak
79+
-include $(srcdir)/arch/$(ARCH)/arch.mak
7880

7981
ifeq ($(ARCH),)
8082

@@ -113,24 +115,17 @@ obj/crt/rcrt1.o: $(srcdir)/ldso/dlstart.c
113115

114116
obj/crt/Scrt1.o obj/crt/rcrt1.o: CFLAGS_ALL += -fPIC
115117

116-
obj/crt/$(ARCH)/crti.o: $(srcdir)/crt/$(ARCH)/crti.s
117-
118-
obj/crt/$(ARCH)/crtn.o: $(srcdir)/crt/$(ARCH)/crtn.s
119-
120118
OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(srcdir)/src/%))
121119
$(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.lo): CFLAGS += -O3
122120

123-
MEMOPS_SRCS = src/string/memcpy.c src/string/memmove.c src/string/memcmp.c src/string/memset.c
124-
$(MEMOPS_SRCS:%.c=obj/%.o) $(MEMOPS_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_MEMOPS)
125-
126-
NOSSP_SRCS = $(wildcard crt/*.c) \
127-
src/env/__libc_start_main.c src/env/__init_tls.c \
128-
src/env/__stack_chk_fail.c \
129-
src/thread/__set_thread_area.c src/thread/$(ARCH)/__set_thread_area.c \
130-
src/string/memset.c src/string/$(ARCH)/memset.c \
131-
src/string/memcpy.c src/string/$(ARCH)/memcpy.c \
132-
ldso/dlstart.c ldso/dynlink.c
133-
$(NOSSP_SRCS:%.c=obj/%.o) $(NOSSP_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP)
121+
MEMOPS_OBJS = $(filter %/memcpy.o %/memmove.o %/memcmp.o %/memset.o, $(LIBC_OBJS))
122+
$(MEMOPS_OBJS) $(MEMOPS_OBJS:%.o=%.lo): CFLAGS_ALL += $(CFLAGS_MEMOPS)
123+
124+
NOSSP_OBJS = $(CRT_OBJS) $(LDSO_OBJS) $(filter \
125+
%/__libc_start_main.o %/__init_tls.o %/__stack_chk_fail.o \
126+
%/__set_thread_area.o %/memset.o %/memcpy.o \
127+
, $(LIBC_OBJS))
128+
$(NOSSP_OBJS) $(NOSSP_OBJS:%.o=%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP)
134129

135130
$(CRT_OBJS): CFLAGS_ALL += -DCRT
136131

system/lib/libc/musl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.15
1+
1.2.1

0 commit comments

Comments
 (0)