Skip to content

Commit 89011ee

Browse files
authored
Don't import emscripten_notify_memory_growth when building with PURE_WASI (#20112)
This adds another dimension to the build of `libstandalone.a`, but this is a pretty small library so the I think its not a big deal. Fixes: #20106
1 parent a788f15 commit 89011ee

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

system/lib/standalone/standalone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ size_t emscripten_get_heap_max() {
155155
}
156156

157157
int emscripten_resize_heap(size_t size) {
158-
#ifdef EMSCRIPTEN_MEMORY_GROWTH
158+
#if defined(EMSCRIPTEN_MEMORY_GROWTH) && !defined(EMSCRIPTEN_PURE_WASI)
159159
size_t old_size = __builtin_wasm_memory_size(0) * WASM_PAGE_SIZE;
160160
assert(old_size < size);
161161
ssize_t diff = (size - old_size + WASM_PAGE_SIZE - 1) / WASM_PAGE_SIZE;

test/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ def metafunc(self, standalone):
363363
if not can_do_standalone(self, impure):
364364
self.skipTest('Test configuration is not compatible with STANDALONE_WASM')
365365
self.set_setting('STANDALONE_WASM')
366+
if not impure:
367+
self.set_setting('PURE_WASI')
366368
# we will not legalize the JS ffi interface, so we must use BigInt
367369
# support in order for JS to have a chance to run this without trapping
368370
# when it sees an i64 on the ffi.

test/test_core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8760,6 +8760,8 @@ def test_binaryen_2170_emscripten_atomic_cas_u8(self):
87608760
@also_with_standalone_wasm()
87618761
def test_sbrk(self):
87628762
self.do_runf(test_file('sbrk_brk.cpp'), 'OK.')
8763+
self.set_setting('ALLOW_MEMORY_GROWTH')
8764+
self.do_runf(test_file('sbrk_brk.cpp'), 'OK.')
87638765

87648766
def test_brk(self):
87658767
self.emcc_args += ['-DTEST_BRK=1']

tools/system_libs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ class libstandalonewasm(MuslInternalLibrary):
20062006

20072007
def __init__(self, **kwargs):
20082008
self.is_mem_grow = kwargs.pop('is_mem_grow')
2009+
self.is_pure = kwargs.pop('is_pure')
20092010
self.nocatch = kwargs.pop('nocatch')
20102011
super().__init__(**kwargs)
20112012

@@ -2015,25 +2016,30 @@ def get_base_name(self):
20152016
name += '-nocatch'
20162017
if self.is_mem_grow:
20172018
name += '-memgrow'
2019+
if self.is_pure:
2020+
name += '-pure'
20182021
return name
20192022

20202023
def get_cflags(self):
20212024
cflags = super().get_cflags()
20222025
cflags += ['-DNDEBUG', '-DEMSCRIPTEN_STANDALONE_WASM']
20232026
if self.is_mem_grow:
20242027
cflags += ['-DEMSCRIPTEN_MEMORY_GROWTH']
2028+
if self.is_pure:
2029+
cflags += ['-DEMSCRIPTEN_PURE_WASI']
20252030
if self.nocatch:
20262031
cflags.append('-DEMSCRIPTEN_NOCATCH')
20272032
return cflags
20282033

20292034
@classmethod
20302035
def vary_on(cls):
2031-
return super().vary_on() + ['is_mem_grow', 'nocatch']
2036+
return super().vary_on() + ['is_mem_grow', 'is_pure', 'nocatch']
20322037

20332038
@classmethod
20342039
def get_default_variation(cls, **kwargs):
20352040
return super().get_default_variation(
20362041
is_mem_grow=settings.ALLOW_MEMORY_GROWTH,
2042+
is_pure=settings.PURE_WASI,
20372043
nocatch=settings.DISABLE_EXCEPTION_CATCHING and not settings.WASM_EXCEPTIONS,
20382044
**kwargs
20392045
)

0 commit comments

Comments
 (0)