@@ -220,7 +220,6 @@ def processDeps(self, deps):
220
220
"_benchmarkSetupEach" ,
221
221
"_benchmarkTeardownEach" ,
222
222
"_benchmarkRun" ,
223
- "_main"
224
223
]
225
224
226
225
@@ -469,7 +468,7 @@ def build(self):
469
468
include_flags = []
470
469
if hasattr (self .project , "includeset" ):
471
470
include_flags = ["-I" , os .path .join (_suite .dir , "includes" , self .project .includeset )]
472
- emcc_flags = ["-s" , "EXIT_RUNTIME=1" , "-s" , " STANDALONE_WASM" , "-s" , "WASM_BIGINT" ] + cc_flags
471
+ emcc_flags = ["-s" , "STANDALONE_WASM" , "-s" , "WASM_BIGINT" ] + cc_flags
473
472
if self .project .isBenchmarkProject ():
474
473
emcc_flags = emcc_flags + ["-s" , "EXPORTED_FUNCTIONS=" + str (self .benchmark_methods ()).replace ("'" , "\" " ) + "" ]
475
474
subdir_program_names = defaultdict (lambda : [])
@@ -489,12 +488,23 @@ def build(self):
489
488
timestampedOutput = mx .TimeStampFile (output_wasm_path )
490
489
mustRebuild = timestampedSource .isNewerThan (timestampedOutput ) or not timestampedOutput .exists ()
491
490
491
+ source_cc_flags = []
492
+ native_bench = True
493
+ if filename .endswith (".c" ):
494
+ with open (source_path ) as f :
495
+ source_file = f .read ()
496
+ for flags in re .findall (r'//\s*CFLAGS\s*=\s*(.*)\n' , source_file ):
497
+ source_cc_flags .extend (flags .split ())
498
+ native_bench_option = re .search (r'//\s*NATIVE_BENCH\s*=\s*(.*)\n' , source_file )
499
+ if native_bench_option :
500
+ native_bench = native_bench_option .group (1 ).lower () == "true"
501
+
492
502
# Step 1: build the .wasm binary.
493
503
if mustRebuild :
494
504
if filename .endswith (".c" ):
495
505
# This generates both a js file and a wasm file.
496
506
# See https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone
497
- build_cmd_line = [emcc_cmd ] + emcc_flags + [source_path , "-o" , output_js_path ] + include_flags
507
+ build_cmd_line = [emcc_cmd ] + emcc_flags + source_cc_flags + [source_path , "-o" , output_js_path ] + include_flags
498
508
if mx .run (build_cmd_line , nonZeroIsFatal = False ) != 0 :
499
509
mx .abort ("Could not build the wasm-only output of " + filename + " with emcc." )
500
510
elif filename .endswith (".wat" ):
@@ -533,11 +543,11 @@ def build(self):
533
543
534
544
# Step 5: if this is a benchmark project, create native binaries too.
535
545
if mustRebuild :
536
- if filename .endswith (".c" ):
546
+ if filename .endswith (".c" ) and native_bench :
537
547
mx_util .ensure_dir_exists (os .path .join (output_dir , subdir , NATIVE_BENCH_DIR ))
538
548
output_path = os .path .join (output_dir , subdir , NATIVE_BENCH_DIR , mx .exe_suffix (basename ))
539
549
link_flags = ["-lm" ]
540
- gcc_cmd_line = [gcc_cmd ] + cc_flags + [source_path , "-o" , output_path ] + include_flags + link_flags
550
+ gcc_cmd_line = [gcc_cmd ] + cc_flags + source_cc_flags + [source_path , "-o" , output_path ] + include_flags + link_flags
541
551
if mx .run (gcc_cmd_line , nonZeroIsFatal = False ) != 0 :
542
552
mx .abort ("Could not build the native binary of " + filename + "." )
543
553
os .chmod (output_path , stat .S_IRUSR | stat .S_IWUSR | stat .S_IXUSR )
@@ -666,7 +676,7 @@ def find_executable(exe_name):
666
676
llvm_root = os .path .join (emsdk_path , "upstream" , "bin" )
667
677
binaryen_root = os .path .join (emsdk_path , "upstream" , "lib" )
668
678
emscripten_root = os .path .join (emsdk_path , "upstream" , "emscripten" )
669
- node_js = os .path .join (emsdk_path , "node" , "14.15.5_64bit " , "bin" , "node" )
679
+ node_js = os .path .join (emsdk_path , "node" , "22.16.0_64bit " , "bin" , "node" )
670
680
671
681
mx .log ("Generating Emscripten configuration..." )
672
682
mx .log ("Config file path: " + str (config_path ))
0 commit comments