Skip to content

Avoid use of EMCC_FORCE_STDLIBS in gen_struct_info.py #13422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2021
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
20 changes: 14 additions & 6 deletions tools/gen_struct_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from tools import shared
from tools import system_libs

QUIET = (__name__ != '__main__')
DEBUG = False
Expand Down Expand Up @@ -231,15 +232,20 @@ def inspect_headers(headers, cpp_opts):

js_file = tempfile.mkstemp('.js')

# Check sanity early on before populating the cache with libcompiler_rt
# If we don't do this the parallel build of compiler_rt will run while holding the cache
# lock and with EM_EXCLUSIVE_CACHE_ACCESS set causing N processes to race to run sanity checks.
# While this is not in itself serious problem it is wasteful and noise on stdout.
# For the same reason we run this early in embuilder.py and emcc.py.
# TODO(sbc): If we can remove EM_EXCLUSIVE_CACHE_ACCESS then this would not longer be needed.
shared.check_sanity()

compiler_rt = system_libs.Library.get_usable_variations()['libcompiler_rt'].get_path()

# Close all unneeded FDs.
os.close(src_file[0])
os.close(js_file[0])

# TODO(sbc): Switch to '-nostdlib -lcompiler_rt'
env = os.environ.copy()
env['EMCC_FORCE_STDLIBS'] = 'libcompiler_rt'
env['EMCC_ONLY_FORCED_STDLIBS'] = '1'

info = []
# Compile the program.
show('Compiling generated code...')
Expand All @@ -248,6 +254,8 @@ def inspect_headers(headers, cpp_opts):
'-O0',
'-Werror',
'-Wno-format',
'-nostdlib',
compiler_rt,
'-I', shared.path_from_root(),
'-s', 'BOOTSTRAPPING_STRUCT_INFO=1',
'-s', 'STRICT',
Expand All @@ -267,7 +275,7 @@ def inspect_headers(headers, cpp_opts):

show(shared.shlex_join(cmd))
try:
subprocess.check_call(cmd, env=env)
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
sys.stderr.write('FAIL: Compilation failed!: %s\n' % e.cmd)
sys.exit(1)
Expand Down
5 changes: 2 additions & 3 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ def handle_reverse_deps(input_files, only_forced):
# If we are only doing forced stdlibs, then we don't know the actual
# symbols we need, and must assume all of deps_info must be exported.
# Note that this might cause warnings on exports that do not exist.
if only_forced and not shared.Settings.BOOTSTRAPPING_STRUCT_INFO:
if only_forced:
for key, value in deps_info.deps_info.items():
for dep in value:
shared.Settings.EXPORTED_FUNCTIONS.append(mangle_c_symbol_name(dep))
Expand Down Expand Up @@ -1453,8 +1453,7 @@ def add_library(lib):
add_library(system_libs_map[forced])

if only_forced:
if not shared.Settings.BOOTSTRAPPING_STRUCT_INFO:
add_library(system_libs_map['libc_rt_wasm'])
add_library(system_libs_map['libc_rt_wasm'])
add_library(system_libs_map['libcompiler_rt'])
else:
if shared.Settings.AUTO_NATIVE_LIBRARIES:
Expand Down