diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 21:22:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 21:22:46 -0800 |
commit | cb046b74b3777846786dcee96d282efaedb4f800 (patch) | |
tree | 04ae0961c2c30e3824a7d031b77ec9462a7141c3 | |
parent | 821316d6173441fc02f3d49a5b430b179e1f302a (diff) |
do not link in dynamic libraries when compiling to bitcode in intermediate stages, only link them in when building to js or html. closes #1886
-rwxr-xr-x | emcc | 17 | ||||
-rw-r--r-- | tests/test_other.py | 5 |
2 files changed, 12 insertions, 10 deletions
@@ -1109,11 +1109,6 @@ try: target = target_basename + '.o' final_suffix = 'o' - # do not link in libs when just generating object code (not an 'executable', i.e. JS, or a library) - if ('.' + final_suffix) in BITCODE_SUFFIXES and len(libs) > 0: - logging.warning('not linking against libraries since only compiling to bitcode') - libs = [] - # Find library files for lib in libs: logging.debug('looking for library "%s"' % lib) @@ -1131,8 +1126,16 @@ try: if found: break if found: break - if ignore_dynamic_linking: - input_files = filter(lambda input_file: not input_file.endswith(DYNAMICLIB_SUFFIXES), input_files) + # If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so + # ignore dynamic linking, since multiple dynamic linkings can interfere with each other + if not filename_type_suffix(target)[1:] in JS_CONTAINING_SUFFIXES or ignore_dynamic_linking: + def check(input_file): + if input_file.endswith(DYNAMICLIB_SUFFIXES): + if not ignore_dynamic_linking: logging.warning('ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end' % os.path.basename(input_file)) + return False + else: + return True + input_files = filter(lambda input_file: check(input_file), input_files) if len(input_files) == 0: logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + STATICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)) diff --git a/tests/test_other.py b/tests/test_other.py index a6e8b533..c26052a3 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1414,12 +1414,11 @@ f.close() } ''') - # This lets us link the same dynamic lib twice. We will need to link it in manually at the end. - compiler = [PYTHON, EMCC, '--ignore-dynamic-linking'] + compiler = [PYTHON, EMCC] # Build libfile normally into an .so Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), '-o', os.path.join(self.get_dir(), 'libdir', 'libfile.so')]).communicate() - # Build libother and dynamically link it to libfile - but add --ignore-dynamic-linking + # Build libother and dynamically link it to libfile Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libother.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile', '-o', os.path.join(self.get_dir(), 'libdir', 'libother.so')]).communicate() # Build the main file, linking in both the libs Popen(compiler + [os.path.join(self.get_dir(), 'main.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile', '-lother', '-c']).communicate() |