53
53
class NativeBenchmarker(Benchmarker):
54
def __init__(self, name, cc, cxx):
54
def __init__(self, name, cc, cxx, args=['-O2']):
59
60
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
60
61
self.parent = parent
61
62
if lib_builder: native_args = native_args + lib_builder(self.name, native=True, env_init={ 'CC': self.cc, 'CXX': self.cxx })
62
63
if not native_exec:
63
64
compiler = self.cxx if filename.endswith('cpp') else self.cc
64
process = Popen([compiler, '-O2', '-fno-math-errno', filename, '-o', filename+'.native'] + shared_args + native_args, stdout=PIPE, stderr=parent.stderr_redirect)
65
process = Popen([compiler, '-fno-math-errno', filename, '-o', filename+'.native'] + self.args + shared_args + native_args, stdout=PIPE, stderr=parent.stderr_redirect)
65
66
output = process.communicate()
66
67
if process.returncode is not 0:
67
print >> sys.stderr, "Building native executable with command '%s' failed with a return code %d!" % (' '.join([compiler, '-O2', filename, '-o', filename+'.native']), process.returncode)
68
print >> sys.stderr, "Building native executable with command failed"
68
69
print "Output: " + output[0]
70
71
shutil.copyfile(native_exec, filename + '.native')
106
107
final = os.path.dirname(filename) + os.path.sep + self.name+'_' + os.path.basename(filename) + '.js'
107
108
try_delete(final)
108
109
output = Popen([PYTHON, EMCC, filename, #'-O3',
109
'-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
110
'-O3', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
110
111
'--memory-init-file', '0', '--js-transform', 'python hardcode.py',
111
112
'-s', 'TOTAL_MEMORY=128*1024*1024',
112
113
#'--closure', '1',
125
126
#NativeBenchmarker('clang', CLANG_CC, CLANG),
126
127
NativeBenchmarker('clang-3.2', os.path.join(LLVM_3_2, 'clang'), os.path.join(LLVM_3_2, 'clang++')),
128
#NativeBenchmarker('clang-3.2-O3', os.path.join(LLVM_3_2, 'clang'), os.path.join(LLVM_3_2, 'clang++'), ['-O3']),
127
129
#NativeBenchmarker('clang-3.3', os.path.join(LLVM_3_3, 'clang'), os.path.join(LLVM_3_3, 'clang++')),
128
130
#NativeBenchmarker('clang-3.4', os.path.join(LLVM_3_4, 'clang'), os.path.join(LLVM_3_4, 'clang++')),
129
131
#NativeBenchmarker('gcc', 'gcc', 'g++'),
472
474
def lua(self, benchmark, expected, output_parser=None, args_processor=None):
473
475
shutil.copyfile(path_from_root('tests', 'lua', benchmark + '.lua'), benchmark + '.lua')
474
476
def lib_builder(name, native, env_init):
475
ret = self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=native, cache_name_extra=name, env_init=env_init)
477
ret = self.get_library('lua_native' if native else 'lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=native, cache_name_extra=name, env_init=env_init)
476
478
if native: return ret
477
479
shutil.copyfile(ret[0], ret[0] + '.bc')