aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/runner.py20
-rwxr-xr-xtools/emmaken.py18
-rw-r--r--tools/shared.py14
3 files changed, 27 insertions, 25 deletions
diff --git a/tests/runner.py b/tests/runner.py
index ed589ca8..a9de9b51 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -27,11 +27,10 @@ EMSCRIPTEN = path_from_root('emscripten.py')
DEMANGLER = path_from_root('third_party', 'demangler.py')
NAMESPACER = path_from_root('tools', 'namespacer.py')
EMMAKEN = path_from_root('tools', 'emmaken.py')
-LLVM_LINK=os.path.join(LLVM_ROOT, 'llvm-link')
# Global cache for tests (we have multiple TestCase instances; this object lets them share data)
-class GlobalCache: pass
+GlobalCache = {}
# Core test runner class, shared between normal tests and benchmarks
@@ -200,7 +199,7 @@ if 'benchmark' not in sys.argv:
if force_c or (main_file is not None and main_file[-2:]) == '.c':
basename = 'src.c'
global COMPILER
- COMPILER = COMPILER.replace('clang++', 'clang').replace('g++', 'gcc')
+ COMPILER = to_cc(COMPILER)
dirname = self.get_dir()
filename = os.path.join(dirname, basename)
@@ -1525,12 +1524,14 @@ if 'benchmark' not in sys.argv:
output_nicerizer=lambda string: string.replace('\n\n', '\n').replace('\n\n', '\n'))
# Build a library into a .bc file. We build the .bc file once and cache it for all our tests. (We cache in
- # memory since the test directory is destroyed and recreated for each test.)
+ # memory since the test directory is destroyed and recreated for each test. Note that we cache separately
+ # for different compilers)
def get_library(self, name, generated_lib, make_args=[]):
- if hasattr(GlobalCache, 'cached_lib' + name):
+ cache_name = name + '|' + COMPILER
+ if GlobalCache.get(cache_name):
bc_file = os.path.join(self.get_dir(), 'lib' + name + '.bc')
f = open(bc_file, 'wb')
- f.write(getattr(GlobalCache, 'cached_lib' + name))
+ f.write(GlobalCache[cache_name])
f.close()
return bc_file
@@ -1540,16 +1541,16 @@ if 'benchmark' not in sys.argv:
os.chdir(ft_dir)
env = os.environ.copy()
env['RANLIB'] = env['AR'] = env['CXX'] = env['CC'] = EMMAKEN
+ env['EMMAKEN_COMPILER'] = COMPILER
output = Popen(['./configure'], stdout=PIPE, stderr=STDOUT, env=env).communicate()[0]
- Popen(['make', '-j', '2'] + make_args, stdout=PIPE, stderr=STDOUT).communicate()[0]
+ Popen(['make', '-j', '2'] + make_args, stdout=PIPE, stderr=STDOUT, env=env).communicate()[0]
bc_file = os.path.join(ft_dir, generated_lib)
shutil.copyfile(bc_file, bc_file + '.bc')
bc_file += '.bc'
- setattr(GlobalCache, 'cached_lib' + name, open(bc_file, 'rb').read())
+ GlobalCache[cache_name] = open(bc_file, 'rb').read()
return bc_file
def test_freetype(self):
- if COMPILER != LLVM_GCC: return # TODO: Build in both clang and llvm-gcc. emmaken currently only does llvm-gcc
if LLVM_OPTS: global RELOOP; RELOOP = 0 # Too slow; we do care about typed arrays and OPTIMIZE though
global GUARD_SIGNS; GUARD_SIGNS = 1 # Not sure why, but needed
@@ -1572,7 +1573,6 @@ if 'benchmark' not in sys.argv:
post_build=post)
def test_zlib(self):
- if COMPILER != LLVM_GCC: return # TODO: Build in both clang and llvm-gcc. emmaken currently only does llvm-gcc
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1 # Overflows in inflate_table() getelementptr (in phi)
global GUARD_SIGNS; GUARD_SIGNS = 1
diff --git a/tools/emmaken.py b/tools/emmaken.py
index ef392849..f100255f 100755
--- a/tools/emmaken.py
+++ b/tools/emmaken.py
@@ -48,29 +48,17 @@ def path_from_root(*pathelems):
return os.path.join(os.path.sep, *(abspath.split(os.sep)[:-1] + list(pathelems)))
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
-CONFIG_FILE = os.path.expanduser('~/.emscripten')
-assert os.path.exists(CONFIG_FILE)
-exec(open(CONFIG_FILE, 'r').read())
-
try:
print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv)
- CC='/home/alon/Dev/llvm-gcc-4.2-2.8.source/cbuild/install/bin/llvm-gcc'
- CXX='/home/alon/Dev/llvm-gcc-4.2-2.8.source/cbuild/install/bin/llvm-g++'
+ CXX = os.environ.get('EMMAKEN_COMPILER') or LLVM_GCC
+ CC = to_cc(CXX)
+
CC_ARG_SKIP = ['-g', '-O1', '-O2', '-O3']
CC_ADDITIONAL_ARGS = ['-m32', '-U__i386__', '-U__x86_64__', '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87']
-
- #CC='llvm-gcc'
- #CC_ARG_SKIP = ['-g', '-O1', '-O2', '-O3']
- #CC_ADDITIONAL_ARGS = ['-U__i386__', '-U__x86_64__']
-
- LLVM_LINK = '/home/alon/Dev/llvm-2.8/cbuild/Release/bin/llvm-link'
- LLVM_DIS = '/home/alon/Dev/llvm-2.8/cbuild/Release/bin/llvm-dis'
ALLOWED_LINK_ARGS = ['-f', '-help', '-o', '-print-after', '-print-after-all', '-print-before',
'-print-before-all', '-time-passes', '-v', '-verify-dom-info', '-version' ]
DISALLOWED_LINK_ARGS = []#['rc']
- #LINK_ARG_SKIP = ['-pthread', '-DNDEBUG', '-g', '-O3', '-Wall', '-Wstrict-prototypes',
- # '-lpthread', '-ldl', '-lutil', '-Xlinker', '-export-dynamic', '-lm', '-shared']
# ---------------- End configs -------------
diff --git a/tools/shared.py b/tools/shared.py
index f6594af2..668e609b 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -7,6 +7,16 @@ if not os.path.exists(CONFIG_FILE):
shutil.copy(path_from_root('tests', 'settings.py'), CONFIG_FILE)
exec(open(CONFIG_FILE, 'r').read())
+# Tools
+
+LLVM_LINK=os.path.join(LLVM_ROOT, 'llvm-link')
+LLVM_OPT=os.path.expanduser(os.path.join(LLVM_ROOT, 'opt'))
+LLVM_AS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-as'))
+LLVM_DIS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-dis'))
+LLVM_DIS_OPTS = ['-show-annotations'] # For LLVM 2.8+. For 2.7, you may need to do just []
+
+# Utilities
+
def timeout_run(proc, timeout, note):
start = time.time()
if timeout is not None:
@@ -21,3 +31,7 @@ def run_js(engine, filename, args, check_timeout=False):
return timeout_run(Popen(engine + [filename] + (['--'] if 'v8' in engine[0] else []) + args,
stdout=PIPE, stderr=STDOUT), 120 if check_timeout else None, 'Execution')
+def to_cc(cxx):
+ # By default, LLVM_GCC and CLANG are really the C++ versions. This gets an explicit C version
+ return cxx.replace('clang++', 'clang').replace('g++', 'gcc')
+