@@ -55,7 +55,7 @@ def FilesAreEqual(filename1, filename2, verbose=False):
55
55
return (OK , '' )
56
56
57
57
58
- def DoRoundtrip (wat2wasm , wasm2wat , out_dir , filename , verbose , stdout ):
58
+ def DoRoundtrip (wat2wasm , wasm2wat , out_dir , filename , verbose , stdout , skip_roundtrip_check ):
59
59
basename = os .path .basename (filename )
60
60
basename_noext = os .path .splitext (basename )[0 ]
61
61
wasm1_file = os .path .join (out_dir , basename_noext + '-1.wasm' )
@@ -75,9 +75,9 @@ def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
75
75
if stdout :
76
76
with open (wat2_file ) as f :
77
77
sys .stdout .write (f .read ())
78
+ if skip_roundtrip_check :
78
79
return (OK , '' )
79
- else :
80
- return FilesAreEqual (wasm1_file , wasm3_file , verbose )
80
+ return FilesAreEqual (wasm1_file , wasm3_file , verbose )
81
81
82
82
83
83
def main (args ):
@@ -90,7 +90,7 @@ def main(args):
90
90
default = find_exe .GetDefaultPath (),
91
91
help = 'directory to search for all executables.' )
92
92
parser .add_argument ('--stdout' , action = 'store_true' ,
93
- help = 'do one roundtrip and write wat output to stdout' )
93
+ help = 'write wat output to stdout' )
94
94
parser .add_argument ('--no-error-cmdline' ,
95
95
help = 'don\' t display the subprocess\' s commandline when '
96
96
'an error occurs' , dest = 'error_cmdline' ,
@@ -100,7 +100,9 @@ def main(args):
100
100
action = 'store_true' )
101
101
parser .add_argument ('--no-check' , action = 'store_true' )
102
102
parser .add_argument ('--debug-names' , action = 'store_true' )
103
- parser .add_argument ('--generate-names' , action = 'store_true' )
103
+ # --generate-names modifies name section, so skip roundtrip check
104
+ parser .add_argument ('--generate-names' , action = 'store_true' ,
105
+ help = "write debug names and skip end-to-end roundtrip check" )
104
106
parser .add_argument ('--fold-exprs' , action = 'store_true' )
105
107
parser .add_argument ('--enable-exceptions' , action = 'store_true' )
106
108
parser .add_argument ('--enable-saturating-float-to-int' , action = 'store_true' )
@@ -115,7 +117,9 @@ def main(args):
115
117
parser .add_argument ('--enable-annotations' , action = 'store_true' )
116
118
parser .add_argument ('--enable-code-metadata' , action = 'store_true' )
117
119
parser .add_argument ('--enable-custom-page-sizes' , action = 'store_true' )
118
- parser .add_argument ('--inline-exports' , action = 'store_true' )
120
+ # --inline-exports can reorder exports, so skip roundtrip check
121
+ parser .add_argument ('--inline-exports' , action = 'store_true' ,
122
+ help = "write exports inline and skip end-to-end roundtrip check" )
119
123
parser .add_argument ('--inline-imports' , action = 'store_true' )
120
124
parser .add_argument ('--reloc' , action = 'store_true' )
121
125
parser .add_argument ('file' , help = 'test file.' )
@@ -178,9 +182,10 @@ def main(args):
178
182
sys .stderr .write ('File not found: %s\n ' % filename )
179
183
return ERROR
180
184
185
+ skip_roundtrip_check = options .generate_names or options .inline_exports
181
186
with utils .TempDirectory (options .out_dir , 'roundtrip-' ) as out_dir :
182
187
result , msg = DoRoundtrip (wat2wasm , wasm2wat , out_dir , filename ,
183
- options .verbose , options .stdout )
188
+ options .verbose , options .stdout , skip_roundtrip_check )
184
189
if result == ERROR :
185
190
sys .stderr .write (msg )
186
191
return result
0 commit comments