88
88
sys .path .insert (1 , os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
89
89
90
90
from tools import shared
91
+ from tools import system_libs
91
92
92
93
QUIET = (__name__ != '__main__' )
93
94
DEBUG = False
@@ -231,15 +232,20 @@ def inspect_headers(headers, cpp_opts):
231
232
232
233
js_file = tempfile .mkstemp ('.js' )
233
234
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
+
234
245
# Close all unneeded FDs.
235
246
os .close (src_file [0 ])
236
247
os .close (js_file [0 ])
237
248
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
-
243
249
info = []
244
250
# Compile the program.
245
251
show ('Compiling generated code...' )
@@ -248,6 +254,8 @@ def inspect_headers(headers, cpp_opts):
248
254
'-O0' ,
249
255
'-Werror' ,
250
256
'-Wno-format' ,
257
+ '-nostdlib' ,
258
+ compiler_rt ,
251
259
'-I' , shared .path_from_root (),
252
260
'-s' , 'BOOTSTRAPPING_STRUCT_INFO=1' ,
253
261
'-s' , 'STRICT' ,
@@ -267,7 +275,7 @@ def inspect_headers(headers, cpp_opts):
267
275
268
276
show (shared .shlex_join (cmd ))
269
277
try :
270
- subprocess .check_call (cmd , env = env )
278
+ subprocess .check_call (cmd )
271
279
except subprocess .CalledProcessError as e :
272
280
sys .stderr .write ('FAIL: Compilation failed!: %s\n ' % e .cmd )
273
281
sys .exit (1 )
0 commit comments