Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def __init__(self):
self.shell_path = shared.path_from_root('src', 'shell.html')
self.source_map_base = ''
self.js_libraries = []
self.bind = False
self.emrun = False
self.cpu_profiler = False
self.thread_profiler = False
Expand Down Expand Up @@ -1077,13 +1076,6 @@ def check(input_file):
# Note the exports the user requested
shared.Building.user_requested_exports = shared.Settings.EXPORTED_FUNCTIONS[:]

if options.bind:
shared.Settings.EMBIND = 1
# If we are using embind and generating JS, now is the time to link in bind.cpp
if final_suffix in JS_CONTAINING_ENDINGS:
input_files.append((next_arg_index, shared.path_from_root('system', 'lib', 'embind', 'bind.cpp')))
next_arg_index += 1

# -s ASSERTIONS=1 implies the heaviest stack overflow check mode. Set the implication here explicitly to avoid having to
# do preprocessor "#if defined(ASSERTIONS) || defined(STACK_OVERFLOW_CHECK)" in .js files, which is not supported.
if shared.Settings.ASSERTIONS:
Expand Down Expand Up @@ -1183,8 +1175,10 @@ def check(input_file):
# stb_image 2.x need to have STB_IMAGE_IMPLEMENTATION defined to include the implementation when compiling
newargs.append('-DSTB_IMAGE_IMPLEMENTATION')

forced_stdlibs = []

if shared.Settings.ASMFS and final_suffix in JS_CONTAINING_ENDINGS:
input_files.append((next_arg_index, shared.path_from_root('system', 'lib', 'fetch', 'asmfs.cpp')))
forced_stdlibs.append('libasmfs')
newargs.append('-D__EMSCRIPTEN_ASMFS__=1')
next_arg_index += 1
shared.Settings.FILESYSTEM = 0
Expand All @@ -1193,16 +1187,18 @@ def check(input_file):
options.js_libraries.append(shared.path_from_root('src', 'library_asmfs.js'))

if shared.Settings.FETCH and final_suffix in JS_CONTAINING_ENDINGS:
input_files.append((next_arg_index, shared.path_from_root('system', 'lib', 'fetch', 'emscripten_fetch.cpp')))
forced_stdlibs.append('libfetch')
next_arg_index += 1
options.js_libraries.append(shared.path_from_root('src', 'library_fetch.js'))
if shared.Settings.USE_PTHREADS:
shared.Settings.FETCH_WORKER_FILE = unsuffixed(os.path.basename(target)) + '.fetch.js'

forced_stdlibs = []
if shared.Settings.DEMANGLE_SUPPORT:
shared.Settings.EXPORTED_FUNCTIONS += ['___cxa_demangle']
forced_stdlibs += ['libc++abi']
forced_stdlibs.append('libc++abi')

if shared.Settings.EMBIND:
forced_stdlibs.append('libembind')

if not shared.Settings.ONLY_MY_CODE and not shared.Settings.MINIMAL_RUNTIME:
# Always need malloc and free to be kept alive and exported, for internal use and other modules
Expand Down Expand Up @@ -2503,7 +2499,7 @@ def check_bad_eq(arg):
shared.Settings.EMIT_SYMBOL_MAP = 1
newargs[i] = ''
elif newargs[i] == '--bind':
options.bind = True
shared.Settings.EMBIND = 1
newargs[i] = ''
options.js_libraries.append(shared.path_from_root('src', 'embind', 'emval.js'))
options.js_libraries.append(shared.path_from_root('src', 'embind', 'embind.js'))
Expand Down
46 changes: 38 additions & 8 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ def get_ext(self):
"""
Return the appropriate file extension for this library.
"""
return 'a' if shared.Settings.WASM_BACKEND and shared.Settings.WASM_OBJECT_FILES else 'bc'
return '.a' if shared.Settings.WASM_BACKEND and shared.Settings.WASM_OBJECT_FILES else '.bc'

def get_name(self):
"""
Return the full name of the library file, including the file extension.
"""
return self.get_base_name() + '.' + self.get_ext()
return self.get_base_name() + self.get_ext()

def get_symbols(self):
"""
Expand Down Expand Up @@ -549,7 +549,7 @@ class NoBCLibrary(Library):
# libraries, only the object files, and by extension, their contained global constructors, that are actually needed
# will be linked in.
def get_ext(self):
return 'a'
return '.a'


class libcompiler_rt(Library):
Expand Down Expand Up @@ -907,6 +907,34 @@ def get_default_variation(cls, **kwargs):
)


class libembind(CXXLibrary):
name = 'libembind'
cflags = ['-std=c++11']
depends = ['libc++abi']
never_force = True

def get_files(self):
return [shared.path_from_root('system', 'lib', 'embind', 'bind.cpp')]


class libfetch(CXXLibrary, MTLibrary):
name = 'libfetch'
depends = ['libc++abi']
never_force = True

def get_files(self):
return [shared.path_from_root('system', 'lib', 'fetch', 'emscripten_fetch.cpp')]


class libasmfs(CXXLibrary, MTLibrary):
name = 'libasmfs'
depends = ['libc++abi']
never_force = True

def get_files(self):
return [shared.path_from_root('system', 'lib', 'fetch', 'asmfs.cpp')]


class libhtml5(Library):
name = 'libhtml5'
symbols = read_symbols(shared.path_from_root('system', 'lib', 'html5.symbols'))
Expand Down Expand Up @@ -1162,12 +1190,14 @@ class Dummy(object):
system_libs_map = Library.get_usable_variations()
system_libs = sorted(system_libs_map.values(), key=lambda lib: lib.name)

# Setting 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 (libc++, etc.)
# You can provide 1 to include everything, or a comma-separated list with the ones you want
# Setting 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 (libc++, 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')
if force == '1':
force = ','.join(key for key, lib in system_libs_map.items() if not lib.never_force)
force = ','.join(name for name, lib in system_libs_map.items() if not lib.never_force)
force_include = set((force.split(',') if force else []) + forced)
if force_include:
logger.debug('forcing stdlibs: ' + str(force_include))
Expand All @@ -1186,7 +1216,7 @@ def add_library(lib):

logger.debug('including %s (%s)' % (lib.name, lib.get_name()))

need_whole_archive = lib.name in force_include and lib.get_ext() != 'bc'
need_whole_archive = lib.name in force_include and lib.get_ext() == '.a'
libs_to_link.append((lib.get_path(), need_whole_archive))

# Recursively add dependencies
Expand Down