Skip to content

Commit 2a9cef1

Browse files
authored
Avoid use of EMCC_FORCE_STDLIBS in gen_struct_info.py (#13422)
Using `-nostdlib` instead means we can remove the special handling in system_libs.py too.
1 parent c90497b commit 2a9cef1

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

tools/gen_struct_info.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8989

9090
from tools import shared
91+
from tools import system_libs
9192

9293
QUIET = (__name__ != '__main__')
9394
DEBUG = False
@@ -231,15 +232,20 @@ def inspect_headers(headers, cpp_opts):
231232

232233
js_file = tempfile.mkstemp('.js')
233234

235+
# Check sanity early on before populating the cache with libcompiler_rt
236+
# If we don't do this the parallel build of compiler_rt will run while holding the cache
237+
# lock and with EM_EXCLUSIVE_CACHE_ACCESS set causing N processes to race to run sanity checks.
238+
# While this is not in itself serious problem it is wasteful and noise on stdout.
239+
# For the same reason we run this early in embuilder.py and emcc.py.
240+
# TODO(sbc): If we can remove EM_EXCLUSIVE_CACHE_ACCESS then this would not longer be needed.
241+
shared.check_sanity()
242+
243+
compiler_rt = system_libs.Library.get_usable_variations()['libcompiler_rt'].get_path()
244+
234245
# Close all unneeded FDs.
235246
os.close(src_file[0])
236247
os.close(js_file[0])
237248

238-
# TODO(sbc): Switch to '-nostdlib -lcompiler_rt'
239-
env = os.environ.copy()
240-
env['EMCC_FORCE_STDLIBS'] = 'libcompiler_rt'
241-
env['EMCC_ONLY_FORCED_STDLIBS'] = '1'
242-
243249
info = []
244250
# Compile the program.
245251
show('Compiling generated code...')
@@ -248,6 +254,8 @@ def inspect_headers(headers, cpp_opts):
248254
'-O0',
249255
'-Werror',
250256
'-Wno-format',
257+
'-nostdlib',
258+
compiler_rt,
251259
'-I', shared.path_from_root(),
252260
'-s', 'BOOTSTRAPPING_STRUCT_INFO=1',
253261
'-s', 'STRICT',
@@ -267,7 +275,7 @@ def inspect_headers(headers, cpp_opts):
267275

268276
show(shared.shlex_join(cmd))
269277
try:
270-
subprocess.check_call(cmd, env=env)
278+
subprocess.check_call(cmd)
271279
except subprocess.CalledProcessError as e:
272280
sys.stderr.write('FAIL: Compilation failed!: %s\n' % e.cmd)
273281
sys.exit(1)

tools/system_libs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ def handle_reverse_deps(input_files, only_forced):
13631363
# If we are only doing forced stdlibs, then we don't know the actual
13641364
# symbols we need, and must assume all of deps_info must be exported.
13651365
# Note that this might cause warnings on exports that do not exist.
1366-
if only_forced and not shared.Settings.BOOTSTRAPPING_STRUCT_INFO:
1366+
if only_forced:
13671367
for key, value in deps_info.deps_info.items():
13681368
for dep in value:
13691369
shared.Settings.EXPORTED_FUNCTIONS.append(mangle_c_symbol_name(dep))
@@ -1453,8 +1453,7 @@ def add_library(lib):
14531453
add_library(system_libs_map[forced])
14541454

14551455
if only_forced:
1456-
if not shared.Settings.BOOTSTRAPPING_STRUCT_INFO:
1457-
add_library(system_libs_map['libc_rt_wasm'])
1456+
add_library(system_libs_map['libc_rt_wasm'])
14581457
add_library(system_libs_map['libcompiler_rt'])
14591458
else:
14601459
if shared.Settings.AUTO_NATIVE_LIBRARIES:

0 commit comments

Comments
 (0)