diff options
Diffstat (limited to 'tools/system_libs.py')
-rw-r--r-- | tools/system_libs.py | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/tools/system_libs.py b/tools/system_libs.py index 3723a5c3..50910a8a 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -28,10 +28,10 @@ def calculate(temp_files, in_temp, stdout, stderr): o_s = [] prev_cxx = os.environ.get('EMMAKEN_CXX') if prev_cxx: os.environ['EMMAKEN_CXX'] = '' - musl_internal_includes = shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal') + musl_internal_includes = ['-I', shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal'), '-I', shared.path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'js')] for src in files: o = in_temp(os.path.basename(src) + '.o') - execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes] + lib_opts, stdout=stdout, stderr=stderr) + execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o] + musl_internal_includes + lib_opts, stdout=stdout, stderr=stderr) o_s.append(o) if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx shared.Building.link(o_s, in_temp(lib_filename)) @@ -71,6 +71,8 @@ def calculate(temp_files, in_temp, stdout, stderr): ]], ['stdlib', [ 'atof.c', + 'atoi.c', + 'atol.c', 'strtod.c', ]], ['string', [ @@ -221,22 +223,44 @@ def calculate(temp_files, in_temp, stdout, stderr): 'fputws.c', ]], ['stdlib', [ + 'atoll.c', + 'bsearch.c', 'ecvt.c', 'fcvt.c', 'gcvt.c', + 'qsort.c', 'wcstod.c', 'wcstol.c', ]], ['string', [ + 'bcmp.c', + 'bcopy.c', + 'bzero.c', + 'index.c', 'memccpy.c', 'memmem.c', 'mempcpy.c', + 'memchr.c', 'memrchr.c', + 'rindex.c', + 'stpcpy.c', 'strcasestr.c', + 'strchr.c', 'strchrnul.c', + 'strcspn.c', + 'strdup.c', 'strlcat.c', 'strlcpy.c', + 'strncat.c', + 'strndup.c', + 'strnlen.c', + 'strpbrk.c', + 'strrchr.c', 'strsep.c', + 'strspn.c', + 'strstr.c', + 'strtok.c', + 'strtok_r.c', 'strverscmp.c', 'wcpcpy.c', 'wcpncpy.c', @@ -335,8 +359,10 @@ def calculate(temp_files, in_temp, stdout, stderr): # Settings this in the environment will avoid checking dependencies and make building big projects a little faster # 1 means include everything; otherwise it can be the name of a lib (libcxx, etc.) + # You can provide 1 to include everything, or a comma-separated list with the ones you want force = os.environ.get('EMCC_FORCE_STDLIBS') force_all = force == '1' + force = set((force or '').split(',')) # Scan symbols symbolses = map(lambda temp_file: shared.Building.llvm_nm(temp_file), temp_files) @@ -364,15 +390,14 @@ def calculate(temp_files, in_temp, stdout, stderr): all_needed.difference_update(symbols.defs) # Go over libraries to figure out which we must include - # If we have libcxx, we must force inclusion of libc, since libcxx uses new internally. Note: this is kind of hacky. ret = [] has = need = None - for name, create, apply_, library_symbols in [('libcxx', create_libcxx, apply_libcxx, libcxx_symbols), - ('libcextra', create_libcextra, lambda x: True, libcextra_symbols), - ('libcxxabi', create_libcxxabi, apply_libcxxabi, libcxxabi_symbols), - ('gl', create_gl, lambda x: True, gl_symbols), - ('libc', create_libc, apply_libc, libc_symbols)]: - force_this = force_all or force == name + for name, create, apply_, library_symbols, deps in [('libcxx', create_libcxx, apply_libcxx, libcxx_symbols, ['libcextra', 'libcxxabi']), + ('libcextra', create_libcextra, lambda x: True, libcextra_symbols, ['libc']), + ('libcxxabi', create_libcxxabi, apply_libcxxabi, libcxxabi_symbols, ['libc']), + ('gl', create_gl, lambda x: True, gl_symbols, ['libc']), + ('libc', create_libc, apply_libc, libc_symbols, [])]: + force_this = force_all or name in force if not force_this: need = set() has = set() @@ -387,11 +412,11 @@ def calculate(temp_files, in_temp, stdout, stderr): need.remove(haz) if shared.Settings.VERBOSE: logging.debug('considering %s: we need %s and have %s' % (name, str(need), str(has))) if force_this or len(need) > 0: - force_all = True if apply_(need): # We need to build and link the library in logging.debug('including %s' % name) libfile = shared.Cache.get(name, create) ret.append(libfile) + force = force.union(deps) return ret |