Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def uses_canonical_tmp(func):
test to satisfy the leak detector.
"""
@wraps(func)
def decorated(self):
def decorated(self, *args, **kwargs):
# Before running the test completely remove the canonical_tmp
if os.path.exists(self.canonical_temp_dir):
shutil.rmtree(self.canonical_temp_dir)
try:
func(self)
func(self, *args, **kwargs)
finally:
# Make sure the test isn't lying about the fact that it uses
# canonical_tmp
Expand Down Expand Up @@ -8194,6 +8194,25 @@ def test_binaryen_ignore_implicit_traps(self):
# sizes must be different, as the flag has an impact
self.assertEqual(len(set(sizes)), 2)

@uses_canonical_tmp
@parameterized({
# In a simple -O0 build we do not set --low-memory-unused (as the stack is
# first, which is nice for debugging but bad for code size (larger globals)
# and bad for the low-memory-unused trick.
'': ([], False),
# When we optimize, we do.
'O2': (['-O2'], True),
# But a low global base prevents it.
'O2_GB_512': (['-O2', '-sGLOBAL_BASE=512'], False),
# A large-enough global base allows it.
'O2_GB_512': (['-O2', '-sGLOBAL_BASE=1024'], True),
})
def test_binaryen_low_memory_unused(self, args, low_memory_unused):
with env_modify({'EMCC_DEBUG': '1'}):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding -v to the command line is a cleaner why to do this I think (and generates less output)

cmd = [EMCC, test_file('hello_world.c')] + args
err = self.run_process(cmd, stdout=PIPE, stderr=PIPE).stderr
self.assertContainedIf('--low-memory-unused ', err, low_memory_unused)

def test_binaryen_passes_extra(self):
def build(args):
return self.run_process([EMCC, test_file('hello_world.c'), '-O3'] + args, stdout=PIPE).stdout
Expand Down
3 changes: 3 additions & 0 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ def get_binaryen_passes(memfile):
# hardcoded value in the binaryen pass)
if optimizing and settings.GLOBAL_BASE >= 1024:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead you want to add and not settings.STACK_FIRST to this condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea, I see now that indeed we already parse this, so makes sense to read it from there. Done.

passes += ['--low-memory-unused']
# we cannot do this if the stack is first, but we only put it first if not
# optimizing
assert not settings.STACK_FIRST
if settings.AUTODEBUG:
# adding '--flatten' here may make these even more effective
passes += ['--instrument-locals']
Expand Down