From 66c4e1d839368ef8dbd089d057a3db7bda84e166 Mon Sep 17 00:00:00 2001 From: Sylvain Beucler Date: Sun, 10 Feb 2019 15:33:53 +0100 Subject: [PATCH] emterpreter: support wildcards in EMTERPRETIFY_WHITELIST (#7988) --- ChangeLog.md | 4 ++++ tools/emterpretify.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1b3f5172f00ff..ba13219861357 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -23,6 +23,10 @@ Current Trunk ad hoc constructed rules around default Emscripten uses. The old behavior will be deprecated and removed in the future. Build with -s ASSERTIONS=1 to get diagnostics messages related to this transition. + + - Option -s EMTERPRETIFY_WHITELIST now accepts shell-style wildcards; + this allows matching static functions with conflicting names that + the linker distinguishes by appending a random suffix. v1.38.26: 02/04/2019 -------------------- diff --git a/tools/emterpretify.py b/tools/emterpretify.py index 45b87cd7e8184..5335badb4ea09 100755 --- a/tools/emterpretify.py +++ b/tools/emterpretify.py @@ -11,7 +11,7 @@ ''' from __future__ import print_function -import os, sys, re, json, shutil +import os, sys, re, json, shutil, fnmatch sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -50,6 +50,12 @@ def handle_arg(arg): return False return True +def wildcards_match(func, whitelist): + for w in whitelist: + if fnmatch.fnmatch(func, w): + return True + return False + DEBUG = os.environ.get('EMCC_DEBUG') config = shared.Configuration() @@ -782,7 +788,7 @@ def process(code): if len(WHITELIST): # we are using a whitelist: fill the blacklist with everything not whitelisted - BLACKLIST = set([func for func in asm.funcs if func not in WHITELIST]) + BLACKLIST = set([func for func in asm.funcs if not wildcards_match(func, WHITELIST)]) # decide which functions will be emterpreted, and find which are externally reachable (from outside other emterpreted code; those will need trampolines)