diff --git a/emcc b/emcc index 7e38b8964..7059c73b6 100755 --- a/emcc +++ b/emcc @@ -187,9 +187,13 @@ CMAKE_CONFIG = 'CMakeFiles/cmTryCompileExec.dir' in ' '.join(sys.argv)# or 'CMak if CONFIGURE_CONFIG or CMAKE_CONFIG: debug_configure = 0 # XXX use this to debug configure stuff. ./configure's generally hide our normal output including stderr so we write to a file - # whether we fake configure tests using clang - the local, native compiler - or not. if not we generate JS and use node with a shebang - # neither approach is perfect, you can try both, but may need to edit configure scripts in some cases - # by default we configure in js, which can break on local filesystem access, etc., but is otherwise accurate + # Whether we fake configure tests using clang - the local, native compiler - or not. if not we generate JS and use node with a shebang + # Beither approach is perfect, you can try both, but may need to edit configure scripts in some cases + # By default we configure in js, which can break on local filesystem access, etc., but is otherwise accurate so we + # disable this if we think we have to. A value of '2' here will force JS checks in all cases. In summary: + # 0 - use native compilation for configure checks + # 1 - use js when we think it will work + # 2 - always use js for configure checks use_js = int(os.environ.get('EMCONFIGURE_JS') or 1) if debug_configure: @@ -199,7 +203,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: src = None for arg in sys.argv: - if arg.endswith('.c'): + if arg.endswith(SOURCE_ENDINGS): try: src = open(arg).read() if debug_configure: open(tempout, 'a').write('============= ' + arg + '\n' + src + '\n=============\n\n') @@ -207,13 +211,13 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: pass elif arg.endswith('.s'): if debug_configure: open(tempout, 'a').write('(compiling .s assembly, must use clang\n') - use_js = 0 + if use_js == 1: use_js = 0 elif arg == '-E': - use_js = 0 + if use_js == 1: use_js = 0 if src: if 'fopen' in src and '"w"' in src: - use_js = 0 # we cannot write to files from js! + if use_js == 1: use_js = 0 # we cannot write to files from js! if debug_configure: open(tempout, 'a').write('Forcing clang since uses fopen to write\n') compiler = os.environ.get('CONFIGURE_CC') or (shared.CLANG if not use_js else shared.EMCC) # if CONFIGURE_CC is defined, use that. let's you use local gcc etc. if you need that diff --git a/tests/test_other.py b/tests/test_other.py index 8d883dfb4..c75cd56e3 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -4647,19 +4647,27 @@ int main(void) { def test_emconfigure_js_o(self): # issue 2994 - for i in [0, 1]: - print i - try: - os.environ['EMCONFIGURE_JS'] = str(i) - self.clear() - Popen([PYTHON, path_from_root('emconfigure'), PYTHON, EMCC, '-c', '-o', 'a.o', path_from_root('tests', 'hello_world.c')]).communicate() - Popen([PYTHON, EMCC, 'a.o']).communicate() - if i == 0: - assert not os.path.exists('a.out.js') # native .o, not bitcode! - else: - assert 'hello, world!' in run_js(self.in_dir('a.out.js')) - finally: - del os.environ['EMCONFIGURE_JS'] + for i in [0, 1, 2]: + for f in ['hello_world.c', 'files.cpp']: + print i, f + try: + os.environ['EMCONFIGURE_JS'] = str(i) + self.clear() + Popen([PYTHON, path_from_root('emconfigure'), PYTHON, EMCC, '-c', '-o', 'a.o', path_from_root('tests', f)]).communicate() + Popen([PYTHON, EMCC, 'a.o']).communicate() + if f == 'hello_world.c': + if i == 0: + assert not os.path.exists('a.out.js') # native .o, not bitcode! + else: + assert 'hello, world!' in run_js(self.in_dir('a.out.js')) + else: + # file access, need 2 to force js + if i == 0 or i == 1: + assert not os.path.exists('a.out.js') # native .o, not bitcode! + else: + assert os.path.exists('a.out.js') + finally: + del os.environ['EMCONFIGURE_JS'] def test_emcc_c_multi(self): def test(args, llvm_opts=None):