You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also adds support for testing with wasm in addition to JS+SAB. To enable testing, set `EMCC_BROWSER_ALSO_WASM=1` and run `browser.test_pthread*`.
Works with EMSCRIPTEN_BROWSER='/path/to/chrome --user-data-dir=clean_dir --js-flags=--experimental-wasm-threads --enable-features=WebAssembly --disable-features=WebAssemblyTrapHandler' with recent (canary) chrome, and also with firefox nightly.
Copy file name to clipboardExpand all lines: emcc.py
+38-43
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,10 @@
101
101
final=None
102
102
103
103
104
+
defexit_with_error(message):
105
+
logging.error(message)
106
+
exit(1)
107
+
104
108
classIntermediate(object):
105
109
counter=0
106
110
defsave_intermediate(name=None, suffix='js'):
@@ -737,8 +741,7 @@ def setting_sub(s):
737
741
738
742
ifnotarg.startswith('-'):
739
743
ifnotos.path.exists(arg):
740
-
logging.error('%s: No such file or directory ("%s" was expected to be an input file, based on the commandline arguments provided)', arg, arg)
741
-
exit(1)
744
+
exit_with_error('%s: No such file or directory ("%s" was expected to be an input file, based on the commandline arguments provided)', arg, arg)
742
745
743
746
arg_ending=filename_type_ending(arg)
744
747
ifarg_ending.endswith(SOURCE_ENDINGS+BITCODE_ENDINGS+DYNAMICLIB_ENDINGS+ASSEMBLY_ENDINGS+HEADER_ENDINGS) orshared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
@@ -766,18 +769,17 @@ def setting_sub(s):
766
769
elifarg_ending.endswith(STATICLIB_ENDINGS):
767
770
ifnotshared.Building.is_ar(arg):
768
771
ifshared.Building.is_bitcode(arg):
769
-
logging.error(arg+': File has a suffix of a static library '+str(STATICLIB_ENDINGS) +', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes '+str(BITCODE_ENDINGS))
772
+
message=arg+': File has a suffix of a static library '+str(STATICLIB_ENDINGS) +', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes '+str(BITCODE_ENDINGS)
770
773
else:
771
-
logging.error(arg+': Unknown format, not a static library!')
772
-
exit(1)
774
+
message=arg+': Unknown format, not a static library!'
775
+
exit_with_error(message)
773
776
else:
774
777
ifhas_fixed_language_mode:
775
778
newargs[i] =''
776
779
input_files.append((i, arg))
777
780
has_source_inputs=True
778
781
else:
779
-
logging.error(arg+": Input file has an unknown suffix, don't know what to do with it!")
780
-
exit(1)
782
+
exit_with_error(arg+": Input file has an unknown suffix, don't know what to do with it!")
781
783
elifarg.startswith('-L'):
782
784
lib_dirs.append(arg[2:])
783
785
newargs[i] =''
@@ -862,8 +864,7 @@ def check(input_file):
862
864
input_files= [(i, input_file) for (i, input_file) ininput_filesifcheck(input_file)]
863
865
864
866
iflen(input_files) ==0:
865
-
logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: '+str(SOURCE_ENDINGS+BITCODE_ENDINGS+DYNAMICLIB_ENDINGS+STATICLIB_ENDINGS+ASSEMBLY_ENDINGS+HEADER_ENDINGS))
866
-
exit(1)
867
+
exit_with_error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: '+str(SOURCE_ENDINGS+BITCODE_ENDINGS+DYNAMICLIB_ENDINGS+STATICLIB_ENDINGS+ASSEMBLY_ENDINGS+HEADER_ENDINGS))
867
868
868
869
newargs=CC_ADDITIONAL_ARGS+newargs
869
870
@@ -933,8 +934,7 @@ def check(input_file):
933
934
assertshared.Settings.PGO==0, 'pgo not supported in fastcomp'
934
935
assertshared.Settings.QUANTUM_SIZE==4, 'altering the QUANTUM_SIZE is not supported'
935
936
exceptExceptionase:
936
-
logging.error('Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html')
937
-
raisee
937
+
exit_with_error('Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html')
938
938
939
939
assertnotshared.Settings.PGO, 'cannot run PGO in ASM_JS mode'
shared.WarningManager.warn('ALMOST_ASM', 'not all asm.js optimizations are possible with --closure 2, disabling those - your code will be run more slowly')
956
955
shared.Settings.ASM_JS=2
@@ -1007,8 +1006,7 @@ def check(input_file):
1007
1006
shared.Settings.NO_FILESYSTEM=1
1008
1007
shared.Settings.FETCH=1
1009
1008
ifnotshared.Settings.USE_PTHREADS:
1010
-
logging.error('-s ASMFS=1 requires either -s USE_PTHREADS=1 or -s USE_PTHREADS=2 to be set!')
1011
-
sys.exit(1)
1009
+
exit_with_error('-s ASMFS=1 requires either -s USE_PTHREADS=1 or -s USE_PTHREADS=2 to be set!')
logging.error('-s LINKABLE=1 is not supported with -s USE_PTHREADS>0!')
1087
-
exit(1)
1084
+
exit_with_error('-s LINKABLE=1 is not supported with -s USE_PTHREADS>0!')
1088
1085
ifshared.Settings.SIDE_MODULE:
1089
-
logging.error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1090
-
exit(1)
1086
+
exit_with_error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1091
1087
ifshared.Settings.MAIN_MODULE:
1092
-
logging.error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1093
-
exit(1)
1088
+
exit_with_error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1094
1089
ifshared.Settings.EMTERPRETIFY:
1095
-
logging.error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
1096
-
exit(1)
1090
+
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
1097
1091
ifshared.Settings.PROXY_TO_WORKER:
1098
-
logging.error('--proxy-to-worker is not supported with -s USE_PTHREADS>0! Use the option -s PROXY_TO_PTHREAD=1 if you want to run the main thread of a multithreaded application in a web worker.')
1099
-
exit(1)
1092
+
exit_with_error('--proxy-to-worker is not supported with -s USE_PTHREADS>0! Use the option -s PROXY_TO_PTHREAD=1 if you want to run the main thread of a multithreaded application in a web worker.')
1100
1093
else:
1101
1094
ifshared.Settings.PROXY_TO_PTHREAD:
1102
-
logging.error('-s PROXY_TO_PTHREAD=1 requires -s USE_PTHREADS to work!')
1103
-
exit(1)
1095
+
exit_with_error('-s PROXY_TO_PTHREAD=1 requires -s USE_PTHREADS to work!')
1104
1096
1105
1097
ifshared.Settings.OUTLINING_LIMIT:
1106
1098
ifnotoptions.js_opts:
@@ -1120,13 +1112,20 @@ def check(input_file):
1120
1112
ifnotDEBUG:
1121
1113
misc_temp_files.note(asm_target)
1122
1114
1123
-
assertshared.Settings.TOTAL_MEMORY>=16*1024*1024, 'TOTAL_MEMORY must be at least 16MB, was '+str(shared.Settings.TOTAL_MEMORY)
1115
+
ifshared.Settings.TOTAL_MEMORY<16*1024*1024:
1116
+
exit_with_error('TOTAL_MEMORY must be at least 16MB, was '+str(shared.Settings.TOTAL_MEMORY))
1124
1117
ifshared.Settings.BINARYEN:
1125
-
assertshared.Settings.TOTAL_MEMORY%65536==0, 'For wasm, TOTAL_MEMORY must be a multiple of 64KB, was '+str(shared.Settings.TOTAL_MEMORY)
1118
+
ifshared.Settings.TOTAL_MEMORY%65536!=0:
1119
+
exit_with_error('For wasm, TOTAL_MEMORY must be a multiple of 64KB, was '+str(shared.Settings.TOTAL_MEMORY))
1126
1120
else:
1127
-
assertshared.Settings.TOTAL_MEMORY% (16*1024*1024) ==0, 'For asm.js, TOTAL_MEMORY must be a multiple of 16MB, was '+str(shared.Settings.TOTAL_MEMORY)
1128
-
assertshared.Settings.TOTAL_MEMORY>=shared.Settings.TOTAL_STACK, 'TOTAL_MEMORY must be larger than TOTAL_STACK, was '+str(shared.Settings.TOTAL_MEMORY) +' (TOTAL_STACK='+str(shared.Settings.TOTAL_STACK) +')'
1129
-
assertshared.Settings.WASM_MEM_MAX==-1orshared.Settings.WASM_MEM_MAX%65536==0, 'WASM_MEM_MAX must be a multiple of 64KB, was '+str(shared.Settings.WASM_MEM_MAX)
exit_with_error('TOTAL_MEMORY must be larger than TOTAL_STACK, was '+str(shared.Settings.TOTAL_MEMORY) +' (TOTAL_STACK='+str(shared.Settings.TOTAL_STACK) +')')
logging.debug("running: "+' '.join(shared.Building.doublequote_spaces(args))) # NOTE: Printing this line here in this specific format is important, it is parsed to implement the "emcc --cflags" command
1338
1336
execute(args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
1339
1337
ifnotos.path.exists(output_file):
1340
-
logging.error('compiler frontend failed to generate LLVM bitcode, halting')
1341
-
sys.exit(1)
1338
+
exit_with_error('compiler frontend failed to generate LLVM bitcode, halting')
1342
1339
1343
1340
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
logging.error('Unrecognized BINARYEN_METHOD "'+m.strip() +'" specified! Please pass a comma-delimited list containing one or more of: '+','.join(valid_methods))
2234
-
sys.exit(1)
2228
+
exit_with_error('Unrecognized BINARYEN_METHOD "'+m.strip() +'" specified! Please pass a comma-delimited list containing one or more of: '+','.join(valid_methods))
cmd+= ['--wasm-only'] # this asm.js is code not intended to run as asm.js, it is only ever going to be wasm, an can contain special fastcomp-wasm support
0 commit comments