170
170
}
171
171
172
172
173
- class Intermediate (object ):
174
- counter = 0
175
-
176
-
177
173
# this function uses the global 'final' variable, which contains the current
178
174
# final output file. if a method alters final, and calls this method, then it
179
175
# must modify final globally (i.e. it can't receive final as a param and
@@ -183,20 +179,17 @@ class Intermediate(object):
183
179
def save_intermediate (name , suffix = 'js' ):
184
180
if not DEBUG :
185
181
return
186
- name = os .path .join (shared .get_emscripten_temp_dir (), 'emcc-%d-%s.%s' % (Intermediate .counter , name , suffix ))
187
182
if isinstance (final , list ):
188
183
logger .debug ('(not saving intermediate %s because deferring linking)' % name )
189
184
return
190
- shutil .copyfile (final , name )
191
- Intermediate .counter += 1
185
+ shared .Building .save_intermediate (final , name + '.' + suffix )
192
186
193
187
194
188
def save_intermediate_with_wasm (name , wasm_binary ):
195
189
if not DEBUG :
196
190
return
197
191
save_intermediate (name ) # save the js
198
- name = os .path .join (shared .get_emscripten_temp_dir (), 'emcc-%d-%s.wasm' % (Intermediate .counter - 1 , name ))
199
- shutil .copyfile (wasm_binary , name )
192
+ shared .Building .save_intermediate (wasm_binary , name + '.wasm' )
200
193
201
194
202
195
class TimeLogger (object ):
@@ -2000,8 +1993,6 @@ def compile_source_file(i, input_file):
2000
1993
if file_ending .endswith (SOURCE_ENDINGS ):
2001
1994
temp_file = temp_files [pos ][1 ]
2002
1995
logger .debug ('optimizing %s' , input_file )
2003
- # if DEBUG:
2004
- # shutil.copyfile(temp_file, os.path.join(shared.configuration.CANONICAL_TEMP_DIR, 'to_opt.bc')) # useful when LLVM opt aborts
2005
1996
new_temp_file = in_temp (unsuffixed (uniquename (temp_file )) + '.o' )
2006
1997
# after optimizing, lower intrinsics to libc calls so that our linking code
2007
1998
# will find them (otherwise, llvm.cos.f32() will not link in cosf(), and
@@ -2964,7 +2955,7 @@ def do_binaryen(target, asm_target, options, memfile, wasm_binary_target,
2964
2955
if not shared .Settings .WASM_BACKEND :
2965
2956
if DEBUG :
2966
2957
# save the asm.js input
2967
- shared .safe_copy (asm_target , os . path . join ( shared . get_emscripten_temp_dir (), os . path . basename ( asm_target )) )
2958
+ shared .Building . save_intermediate (asm_target , 'asmjs.js' )
2968
2959
cmd = [os .path .join (binaryen_bin , 'asm2wasm' ), asm_target , '--total-memory=' + str (shared .Settings .TOTAL_MEMORY )]
2969
2960
if shared .Settings .BINARYEN_TRAP_MODE not in ('js' , 'clamp' , 'allow' ):
2970
2961
exit_with_error ('invalid BINARYEN_TRAP_MODE value: ' + shared .Settings .BINARYEN_TRAP_MODE + ' (should be js/clamp/allow)' )
@@ -3037,7 +3028,7 @@ def do_binaryen(target, asm_target, options, memfile, wasm_binary_target,
3037
3028
if shared .Settings .STANDALONE_WASM :
3038
3029
options .binaryen_passes += ['--pass-arg=emscripten-sbrk-val@%d' % shared .Settings .DYNAMIC_BASE ]
3039
3030
if DEBUG :
3040
- shared .safe_copy (wasm_binary_target , os . path . join ( shared . get_emscripten_temp_dir (), os . path . basename ( wasm_binary_target ) + '. pre-byn' ) )
3031
+ shared .Building . save_intermediate (wasm_binary_target , ' pre-byn.wasm' )
3041
3032
args = options .binaryen_passes
3042
3033
shared .Building .run_wasm_opt (wasm_binary_target ,
3043
3034
wasm_binary_target ,
@@ -3056,7 +3047,7 @@ def do_binaryen(target, asm_target, options, memfile, wasm_binary_target,
3056
3047
shared .check_call ([shared .PYTHON , os .path .join (binaryen_scripts , script ), final , wasm_text_target ], env = script_env )
3057
3048
if shared .Settings .EVAL_CTORS :
3058
3049
if DEBUG :
3059
- save_intermediate_with_wasm ( 'pre-eval- ctors' , wasm_binary_target )
3050
+ shared . Building . save_intermediate ( wasm_binary_target , 'pre-ctors.wasm' )
3060
3051
shared .Building .eval_ctors (final , wasm_binary_target , binaryen_bin , debug_info = intermediate_debug_info )
3061
3052
3062
3053
# after generating the wasm, do some final operations
0 commit comments