Skip to content

Commit 1dfc420

Browse files
authored
Merge branch 'emscripten-core:main' into arm_neon_compat_native_aliases
2 parents 82c4d43 + 9d81dea commit 1dfc420

File tree

120 files changed

+2903
-1449
lines changed

Some content is hidden

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

120 files changed

+2903
-1449
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ executors:
2121
EMCC_CORES: "4"
2222
EMSDK_NOTTY: "1"
2323
EMTEST_WASI_SYSROOT: "~/wasi-sdk/wasi-sysroot"
24-
EMTEST_BUILD_VERBOSE: "2"
2524
EMTEST_DETECT_TEMPFILE_LEAKS: "1"
2625
mac-arm64:
2726
environment:

ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ to browse the changes between the tags.
1818

1919
See docs/process.md for more on how version tagging works.
2020

21-
4.0.23 (in development)
21+
4.0.24 (in development)
2222
-----------------------
23+
- compiler-rt was updated to LLVM 21.1.8. (#26405)
24+
25+
4.0.23 - 01/10/26
26+
-----------------
2327
- The inconsistency of incrementing / decrementing refcounts between Wasm EH and
2428
Emscripten EH has been fixed. See `test_EXPORT_EXCEPTION_HANDLING_HELPERS` in
2529
`test_core.py` to see the usage. (#25988)

emconfigure.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def run():
4444
return 1
4545

4646
env = building.get_building_env()
47-
# When we configure via a ./configure script, don't do config-time
48-
# compilation with emcc, but instead do builds natively with Clang. This
49-
# is a heuristic emulation that may or may not work.
5047
env['EMMAKEN_JUST_CONFIGURE'] = '1'
5148
print(f'emconfigure: {shlex.join(args)} in directory {os.getcwd()}', file=sys.stderr)
5249
os.environ.update(env)

emscripten-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.23-git
1+
4.0.24-git

src/jsifier.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,12 @@ function(${args}) {
697697
let contentText;
698698
if (isFunction) {
699699
// Emit the body of a JS library function.
700-
if (
701-
(USE_ASAN || USE_LSAN || UBSAN_RUNTIME) &&
702-
LibraryManager.library[symbol + '__noleakcheck']
703-
) {
700+
if ((USE_ASAN || USE_LSAN) && LibraryManager.library[symbol + '__noleakcheck']) {
704701
contentText = modifyJSFunction(
705702
snippet,
706-
(args, body) => `(${args}) => withBuiltinMalloc(() => {${body}})`,
703+
(args, body) => `(${args}) => noLeakCheck(() => {${body}})`,
707704
);
708-
deps.push('$withBuiltinMalloc');
705+
deps.push('$noLeakCheck');
709706
} else {
710707
contentText = snippet; // Regular JS function that will be executed in the context of the calling thread.
711708
}

src/lib/libcore.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,32 +1464,16 @@ addToLibrary({
14641464
},
14651465

14661466
#if USE_ASAN || USE_LSAN || UBSAN_RUNTIME
1467-
// When lsan or asan is enabled withBuiltinMalloc temporarily replaces calls
1468-
// to malloc, calloc, free, and memalign.
1469-
$withBuiltinMalloc__deps: [
1470-
'malloc', 'calloc', 'free', 'memalign', 'realloc',
1471-
'emscripten_builtin_malloc', 'emscripten_builtin_free', 'emscripten_builtin_memalign', 'emscripten_builtin_calloc', 'emscripten_builtin_realloc'
1472-
],
1473-
$withBuiltinMalloc__docs: '/** @suppress{checkTypes} */',
1474-
$withBuiltinMalloc: (func) => {
1475-
var prev_malloc = typeof _malloc != 'undefined' ? _malloc : undefined;
1476-
var prev_calloc = typeof _calloc != 'undefined' ? _calloc : undefined;
1477-
var prev_memalign = typeof _memalign != 'undefined' ? _memalign : undefined;
1478-
var prev_free = typeof _free != 'undefined' ? _free : undefined;
1479-
var prev_realloc = typeof _realloc != 'undefined' ? _realloc : undefined;
1480-
_malloc = _emscripten_builtin_malloc;
1481-
_calloc = _emscripten_builtin_calloc;
1482-
_memalign = _emscripten_builtin_memalign;
1483-
_free = _emscripten_builtin_free;
1484-
_realloc = _emscripten_builtin_realloc;
1467+
// When lsan is enabled noLeakCheck will temporarily disable leak checking
1468+
// for the duration of the function.
1469+
$noLeakCheck__deps: ['__lsan_enable', '__lsan_disable'],
1470+
$noLeakCheck__docs: '/** @suppress{checkTypes} */',
1471+
$noLeakCheck: (func) => {
1472+
if (runtimeInitialized) ___lsan_disable();
14851473
try {
14861474
return func();
14871475
} finally {
1488-
_malloc = prev_malloc;
1489-
_calloc = prev_calloc;
1490-
_memalign = prev_memalign;
1491-
_free = prev_free;
1492-
_realloc = prev_realloc;
1476+
if (runtimeInitialized) ___lsan_enable();
14931477
}
14941478
},
14951479

@@ -1501,11 +1485,9 @@ addToLibrary({
15011485
return ENVIRONMENT_IS_NODE && process.stderr.isTTY;
15021486
},
15031487

1504-
_emscripten_sanitizer_get_option__deps: ['$withBuiltinMalloc', '$stringToNewUTF8', '$UTF8ToString'],
1488+
_emscripten_sanitizer_get_option__deps: ['$stringToNewUTF8', '$UTF8ToString'],
15051489
_emscripten_sanitizer_get_option__sig: 'pp',
1506-
_emscripten_sanitizer_get_option: (name) => {
1507-
return withBuiltinMalloc(() => stringToNewUTF8(Module[UTF8ToString(name)] || ""));
1508-
},
1490+
_emscripten_sanitizer_get_option: (name) => stringToNewUTF8(Module[UTF8ToString(name)] || ''),
15091491
#endif
15101492

15111493
$readEmAsmArgsArray: [],

src/lib/libexceptions.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,25 @@ var LibraryExceptions = {
345345
},
346346

347347
#elif !DISABLE_EXCEPTION_CATCHING
348-
$incrementExceptionRefcount__deps: ['__cxa_increment_exception_refcount'],
349-
$incrementExceptionRefcount: (ptr) => ___cxa_increment_exception_refcount(ptr),
348+
// When EXCEPTION_STACK_TRACES is set, the exception is an instance of
349+
// CppException, whereas EXCEPTION_STACK_TRACES is unset it is a raw pointer.
350+
$exnToPtr: (exn) => {
351+
#if EXCEPTION_STACK_TRACES
352+
if (exn instanceof CppException) {
353+
return exn.excPtr;
354+
}
355+
#endif
356+
return exn;
357+
},
358+
359+
$incrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_increment_exception_refcount'],
360+
$incrementExceptionRefcount: (exn) => ___cxa_increment_exception_refcount(exnToPtr(exn)),
350361

351-
$decrementExceptionRefcount__deps: ['__cxa_decrement_exception_refcount'],
352-
$decrementExceptionRefcount: (ptr) => ___cxa_decrement_exception_refcount(ptr),
362+
$decrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_decrement_exception_refcount'],
363+
$decrementExceptionRefcount: (exn) => ___cxa_decrement_exception_refcount(exnToPtr(exn)),
353364

354-
$getExceptionMessage__deps: ['$getExceptionMessageCommon'],
355-
$getExceptionMessage: (ptr) => getExceptionMessageCommon(ptr),
365+
$getExceptionMessage__deps: ['$exnToPtr', '$getExceptionMessageCommon'],
366+
$getExceptionMessage: (exn) => getExceptionMessageCommon(exnToPtr(exn)),
356367

357368
#endif
358369
};

system/lib/compiler-rt/lib/asan/asan_activation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static struct AsanDeactivatedFlags {
5858
cf.verbosity = Verbosity();
5959
cf.help = false; // this is activation-specific help
6060

61-
// Check if activation flags need to be overriden.
61+
// Check if activation flags need to be overridden.
6262
if (const char *env = GetEnv("ASAN_ACTIVATION_OPTIONS")) {
6363
parser.ParseString(env);
6464
}

system/lib/compiler-rt/lib/asan/asan_allocator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,15 @@ struct Allocator {
424424
PoisonShadow(chunk, allocated_size, kAsanHeapLeftRedzoneMagic);
425425
}
426426

427-
void ReInitialize(const AllocatorOptions &options) {
427+
// Apply provided AllocatorOptions to an Allocator
428+
void ApplyOptions(const AllocatorOptions &options) {
428429
SetAllocatorMayReturnNull(options.may_return_null);
429430
allocator.SetReleaseToOSIntervalMs(options.release_to_os_interval_ms);
430431
SharedInitCode(options);
432+
}
433+
434+
void ReInitialize(const AllocatorOptions &options) {
435+
ApplyOptions(options);
431436

432437
// Poison all existing allocation's redzones.
433438
if (CanPoisonMemory()) {
@@ -977,6 +982,11 @@ void ReInitializeAllocator(const AllocatorOptions &options) {
977982
instance.ReInitialize(options);
978983
}
979984

985+
// Apply provided AllocatorOptions to an Allocator
986+
void ApplyAllocatorOptions(const AllocatorOptions &options) {
987+
instance.ApplyOptions(options);
988+
}
989+
980990
void GetAllocatorOptions(AllocatorOptions *options) {
981991
instance.GetOptions(options);
982992
}

system/lib/compiler-rt/lib/asan/asan_allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct AllocatorOptions {
4747
void InitializeAllocator(const AllocatorOptions &options);
4848
void ReInitializeAllocator(const AllocatorOptions &options);
4949
void GetAllocatorOptions(AllocatorOptions *options);
50+
void ApplyAllocatorOptions(const AllocatorOptions &options);
5051

5152
class AsanChunkView {
5253
public:
@@ -238,7 +239,7 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
238239
typedef CompactSizeClassMap SizeClassMap;
239240
template <typename AddressSpaceViewTy>
240241
struct AP32 {
241-
static const uptr kSpaceBeg = 0;
242+
static const uptr kSpaceBeg = SANITIZER_MMAP_BEGIN;
242243
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
243244
static const uptr kMetadataSize = 0;
244245
typedef __asan::SizeClassMap SizeClassMap;

0 commit comments

Comments
 (0)