@@ -1484,21 +1484,6 @@ def get_binaryen_bin():
1484
1484
1485
1485
def run_binaryen_command (tool , infile , outfile = None , args = [], debug = False , stdout = None ):
1486
1486
cmd = [os .path .join (get_binaryen_bin (), tool )]
1487
- if outfile and tool == 'wasm-opt' and \
1488
- (settings .DEBUG_LEVEL < 3 or settings .GENERATE_SOURCE_MAP ):
1489
- # remove any dwarf debug info sections, if the debug level is <3, as
1490
- # we don't need them; also remove them if we use source maps (which are
1491
- # implemented separately from dwarf).
1492
- # note that we add this pass first, so that it doesn't interfere with
1493
- # the final set of passes (which may generate stack IR, and nothing
1494
- # should be run after that)
1495
- # TODO: if lld can strip dwarf then we don't need this. atm though it can
1496
- # only strip all debug info or none, which includes the name section
1497
- # which we may need
1498
- # TODO: once fastcomp is gone, either remove source maps entirely, or
1499
- # support them by emitting a source map at the end from the dwarf,
1500
- # and use llvm-objcopy to remove that final dwarf
1501
- cmd += ['--strip-dwarf' ]
1502
1487
cmd += args
1503
1488
if infile :
1504
1489
cmd += [infile ]
@@ -1534,8 +1519,22 @@ def run_binaryen_command(tool, infile, outfile=None, args=[], debug=False, stdou
1534
1519
return ret
1535
1520
1536
1521
1537
- def run_wasm_opt (* args , ** kwargs ):
1538
- return run_binaryen_command ('wasm-opt' , * args , ** kwargs )
1522
+ def run_wasm_opt (infile , outfile = None , args = [], ** kwargs ):
1523
+ if outfile and (settings .DEBUG_LEVEL < 3 or settings .GENERATE_SOURCE_MAP ):
1524
+ # remove any dwarf debug info sections, if the debug level is <3, as
1525
+ # we don't need them; also remove them if we use source maps (which are
1526
+ # implemented separately from dwarf).
1527
+ # note that we add this pass first, so that it doesn't interfere with
1528
+ # the final set of passes (which may generate stack IR, and nothing
1529
+ # should be run after that)
1530
+ # TODO: if lld can strip dwarf then we don't need this. atm though it can
1531
+ # only strip all debug info or none, which includes the name section
1532
+ # which we may need
1533
+ # TODO: once fastcomp is gone, either remove source maps entirely, or
1534
+ # support them by emitting a source map at the end from the dwarf,
1535
+ # and use llvm-objcopy to remove that final dwarf
1536
+ args .insert (0 , '--strip-dwarf' )
1537
+ return run_binaryen_command ('wasm-opt' , infile , outfile , args = args , ** kwargs )
1539
1538
1540
1539
1541
1540
save_intermediate_counter = 0
0 commit comments