diff options
-rwxr-xr-x | emcc | 8 | ||||
-rw-r--r-- | tests/hello_libcxx.cpp | 8 | ||||
-rw-r--r-- | tests/runner.py | 3 | ||||
-rw-r--r-- | tools/shared.py | 11 |
4 files changed, 22 insertions, 8 deletions
@@ -469,8 +469,8 @@ try: # libcxx def create_libcxx(): print >> sys.stderr, 'emcc: building libcxx for cache' - shared.Building.build_library('libcxx', EMSCRIPTEN_TEMP_DIR, EMSCRIPTEN_TEMP_DIR, ['libcxx.bc'], configure=None, copy_project=True) - return in_temp('libcxx.bc') + shared.Building.build_library('libcxx', shared.EMSCRIPTEN_TEMP_DIR, shared.EMSCRIPTEN_TEMP_DIR, ['libcxx.bc'], configure=None, copy_project=True, source_dir=shared.path_from_root('system', 'lib', 'libcxx')) + return os.path.join(shared.EMSCRIPTEN_TEMP_DIR, 'libcxx', 'libcxx.bc') def fix_libcxx(): # libcxx probably needs sign correction. # If we are in mode 0, switch to 2. We will add our lines shared.Settings.CORRECT_SIGNS = 1 @@ -479,8 +479,8 @@ try: libcxx_symbols = filter(lambda symbol: symbol not in dlmalloc_symbols, libcxx_symbols) libcxx_symbols = set(libcxx_symbols) - for name, create, fix, library_symbols in [('dlmalloc', create_dlmalloc, fix_dlmalloc, dlmalloc_symbols)]: - #('libcxx', create_libcxx, fix_libcxx, libcxx_symbols)]: + for name, create, fix, library_symbols in [('dlmalloc', create_dlmalloc, fix_dlmalloc, dlmalloc_symbols), + ('libcxx', create_libcxx, fix_libcxx, libcxx_symbols)]: need = False has = False for input_file in input_files: diff --git a/tests/hello_libcxx.cpp b/tests/hello_libcxx.cpp new file mode 100644 index 00000000..445c5513 --- /dev/null +++ b/tests/hello_libcxx.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +int main() +{ + std::cout << "hello, world!" << std::endl; + return 0; +} + diff --git a/tests/runner.py b/tests/runner.py index 74868844..3cd0e2b9 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -6017,10 +6017,11 @@ elif 'sanity' in str(sys.argv): try_delete('a.out.js') # Building a file that *does* need dlmalloc *should* trigger cache generation, but only the first time - for filename, libname in [('hello_malloc.cpp', 'dlmalloc')]: + for filename, libname, otherlibname in [('hello_malloc.cpp', 'dlmalloc', 'libcxx'), ('hello_libcxx.cpp', 'libcxx', 'dlmalloc')]: for i in range(3): output = self.do([EMCC, path_from_root('tests', filename)]) assert INCLUDING_MESSAGE.replace('X', libname) in output + assert INCLUDING_MESSAGE.replace('X', otherlibname) not in output assert (BUILDING_MESSAGE.replace('X', libname) in output) == (i == 0), 'Must only build the first time' self.assertContained('hello, world!', run_js('a.out.js')) assert os.path.exists(EMCC_CACHE) diff --git a/tools/shared.py b/tools/shared.py index c869d4f5..d8ccad90 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -378,20 +378,21 @@ class Building: Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] @staticmethod - def build_library(name, build_dir, output_dir, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}): + def build_library(name, build_dir, output_dir, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None): ''' 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. Note that we cache separately for different compilers). This cache is just during the test runner. There is a different concept of caching as well, see |Cache|. ''' if type(generated_libs) is not list: generated_libs = [generated_libs] + if source_dir is None: source_dir = path_from_root('tests', name) temp_dir = build_dir if copy_project: project_dir = os.path.join(temp_dir, name) if os.path.exists(project_dir): shutil.rmtree(project_dir) - shutil.copytree(path_from_root('tests', name), project_dir) # Useful in debugging sometimes to comment this out, and two lines above + shutil.copytree(source_dir, project_dir) # Useful in debugging sometimes to comment this out, and two lines above else: project_dir = build_dir try: @@ -489,15 +490,19 @@ class Building: class ret: defs = [] undefs = [] + commons = [] for line in output.split('\n'): if len(line) == 0: continue status, symbol = filter(lambda seg: len(seg) > 0, line.split(' ')) if status == 'U': ret.undefs.append(symbol) - else: + elif status != 'C': ret.defs.append(symbol) + else: + ret.commons.append(symbol) ret.defs = set(ret.defs) ret.undefs = set(ret.undefs) + ret.commons = set(ret.commons) return ret @staticmethod |