diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-30 12:30:10 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-30 12:30:10 -0700 |
commit | 9cd0580f3ce92daec90a0bf0fbdca5034a7929f3 (patch) | |
tree | a5b82f16eeba7e6984674182cffa6e8d373895e9 | |
parent | 0cbf3f44082077c2ed2afe7f91db68dc53a4c922 (diff) |
add support for changing the llvm target using EMCC_LLVM_TARGET in the env
-rwxr-xr-x | emcc | 13 | ||||
-rwxr-xr-x | tests/runner.py | 16 | ||||
-rw-r--r-- | tools/shared.py | 5 |
3 files changed, 26 insertions, 8 deletions
@@ -1033,8 +1033,17 @@ try: if minify_whitespace is None: minify_whitespace = opt_level >= 2 and not keep_js_debug - if shared.Settings.TARGET_X86: assert 'i386-pc-linux-gnu' in shared.COMPILER_OPTS - if shared.Settings.TARGET_LE32: assert 'le32-unknown-nacl' in shared.COMPILER_OPTS + assert shared.LLVM_TARGET in shared.COMPILER_OPTS + if shared.LLVM_TARGET == 'i386-pc-linux-gnu': + shared.Settings.TARGET_X86 = 1 + shared.Settings.TARGET_LE32 = 0 + assert 'le32-unknown-nacl' not in shared.COMPILER_OPTS + elif shared.LLVM_TARGET == 'le32-unknown-nacl': + shared.Settings.TARGET_LE32 = 1 + shared.Settings.TARGET_X86 = 0 + assert 'i386-pc-linux-gnu' not in shared.COMPILER_OPTS + else: + raise Exception('unknown llvm target: ' + str(shared.LLVM_TARGET)) ## Compile source code to bitcode diff --git a/tests/runner.py b/tests/runner.py index ea6608d6..3eadafda 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -455,7 +455,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows if len(sys.argv) == 2 and 'ALL.' in sys.argv[1]: ignore, test = sys.argv[1].split('.') print 'Running all test modes on test "%s"' % test - sys.argv = [sys.argv[0], 'default.'+test, 'o1.'+test, 'o2.'+test, 'asm1.'+test, 'asm2.'+test, 'asm2g.'+test, 's_0_0.'+test, 's_0_1.'+test, 's_1_0.'+test, 's_1_1.'+test] + sys.argv = [sys.argv[0], 'default.'+test, 'o1.'+test, 'o2.'+test, 'asm1.'+test, 'asm2.'+test, 'asm2g.'+test, 'asm2le32.'+test, 's_0_0.'+test, 's_0_1.'+test, 's_1_0.'+test, 's_1_1.'+test] class T(RunnerCore): # Short name, to make it more fun to use manually on the commandline ## Does a complete test - builds, runs, checks output, etc. @@ -9252,15 +9252,24 @@ finalizing 3 (global == 0) ''') # Generate tests for everything - def make_run(fullname, name=-1, compiler=-1, llvm_opts=0, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None): + def make_run(fullname, name=-1, compiler=-1, llvm_opts=0, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None, env='{}'): exec(''' class %s(T): + env = %s + def tearDown(self): super(%s, self).tearDown() + for k, v in self.env.iteritems(): + del os.environ[k] + def setUp(self): super(%s, self).setUp() + for k, v in self.env.iteritems(): + assert k not in os.environ, k + ' should not be in environment' + os.environ[k] = v + Building.COMPILER_TEST_OPTS = ['-g'] os.chdir(self.get_dir()) # Ensure the directory exists and go there Building.COMPILER = %r @@ -9304,7 +9313,7 @@ class %s(T): Building.pick_llvm_opts(3) TT = %s -''' % (fullname, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname)) +''' % (fullname, env, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname)) return TT # Make one run with the defaults @@ -9320,6 +9329,7 @@ TT = %s exec('asm1 = make_run("asm1", compiler=CLANG, emcc_args=["-O1", "-s", "CHECK_HEAP_ALIGN=1"])') exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2"])') exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1"])') + exec('''asm2le32 = make_run("asm2le32", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "CHECK_HEAP_ALIGN=1"], env='{"EMCC_LLVM_TARGET": "le32-unknown-nacl"}')''') # Make custom runs with various options for compiler, quantum, embetter, typed_arrays, llvm_opts in [ diff --git a/tools/shared.py b/tools/shared.py index 6aa20872..a33f16a5 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -397,9 +397,8 @@ except: # Additional compiler options -# Target choice. Only one of these must be enabled, and synced with src/settings.js (TARGET_*) -#LLVM_TARGET = 'le32-unknown-nacl' -LLVM_TARGET = 'i386-pc-linux-gnu' +# Target choice. Must be synced with src/settings.js (TARGET_*) +LLVM_TARGET = os.environ.get('EMCC_LLVM_TARGET') or 'i386-pc-linux-gnu' # 'le32-unknown-nacl' try: COMPILER_OPTS # Can be set in EM_CONFIG, optionally |