Skip to content

Commit

Permalink
[wasm-emscripten-finalize] Remove --separate-data-segments (#6091)
Browse files Browse the repository at this point in the history
See #6088
  • Loading branch information
sbc100 authored Nov 27, 2023
1 parent c5db74c commit e031490
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 166 deletions.
49 changes: 12 additions & 37 deletions scripts/test/lld.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def args_for_finalize(filename):
ret = ['--global-base=568']
ret = []
if 'safe_stack' in filename:
ret += ['--check-stack-overflow']
if 'shared' in filename:
Expand All @@ -30,38 +30,19 @@ def args_for_finalize(filename):

def run_test(input_path):
print('..', input_path)
is_passive = '.passive.' in input_path
mem_file = input_path + '.mem'
extension_arg_map = {
'.out': [],
}
if not is_passive:
extension_arg_map.update({
'.mem.out': ['--separate-data-segments', mem_file],
})
for ext, args in extension_arg_map.items():
expected_file = input_path + ext
if not os.path.exists(expected_file):
if ext == '.out':
shared.fail_with_error('output ' + expected_file +
' does not exist')
else:
continue

cmd = shared.WASM_EMSCRIPTEN_FINALIZE + args
if '64' in input_path:
cmd += ['--enable-memory64', '--bigint']
cmd += [input_path, '-S']
cmd += args_for_finalize(os.path.basename(input_path))
actual = support.run_command(cmd)
expected_file = input_path + '.out'
if not os.path.exists(expected_file):
shared.fail_with_error('output ' + expected_file +
' does not exist')

shared.fail_if_not_identical_to_file(actual, expected_file)
cmd = list(shared.WASM_EMSCRIPTEN_FINALIZE)
if '64' in input_path:
cmd += ['--enable-memory64', '--bigint']
cmd += [input_path, '-S']
cmd += args_for_finalize(os.path.basename(input_path))
actual = support.run_command(cmd)

if ext == '.mem.out':
with open(mem_file) as mf:
mem = mf.read()
shared.fail_if_not_identical_to_file(mem, input_path + '.mem.mem')
os.remove(mem_file)
shared.fail_if_not_identical_to_file(actual, expected_file)


def test_wasm_emscripten_finalize():
Expand All @@ -76,15 +57,9 @@ def update_lld_tests():

for input_path in shared.get_tests(shared.get_test_dir('lld'), ['.wat', '.wasm']):
print('..', input_path)
is_passive = '.passive.' in input_path
mem_file = input_path + '.mem'
extension_arg_map = {
'.out': [],
}
if not is_passive:
extension_arg_map.update({
'.mem.out': ['--separate-data-segments', mem_file + '.mem'],
})
for ext, ext_args in extension_arg_map.items():
out_path = input_path + ext
if ext != '.out' and not os.path.exists(out_path):
Expand Down
28 changes: 0 additions & 28 deletions src/tools/wasm-emscripten-finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,18 @@
using namespace wasm;

int main(int argc, const char* argv[]) {
const uint64_t INVALID_BASE = -1;

std::string infile;
std::string outfile;
std::string inputSourceMapFilename;
std::string outputSourceMapFilename;
std::string outputSourceMapUrl;
std::string dataSegmentFile;
bool emitBinary = true;
bool debugInfo = false;
bool DWARF = false;
bool sideModule = false;
bool legalizeJavaScriptFFI = true;
bool bigInt = false;
bool checkStackOverflow = false;
uint64_t globalBase = INVALID_BASE;
bool standaloneWasm = false;
// TODO: remove after https://github.com/WebAssembly/binaryen/issues/3043
bool minimizeWasmChanges = false;
Expand Down Expand Up @@ -93,14 +89,6 @@ int main(int argc, const char* argv[]) {
WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&emitBinary](Options*, const std::string&) { emitBinary = false; })
.add("--global-base",
"",
"The address at which static globals were placed",
WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&globalBase](Options*, const std::string& argument) {
globalBase = std::stoull(argument);
})
.add("--side-module",
"",
"Input is an emscripten side module",
Expand Down Expand Up @@ -150,14 +138,6 @@ int main(int argc, const char* argv[]) {
[&outputSourceMapUrl](Options* o, const std::string& argument) {
outputSourceMapUrl = argument;
})
.add("--separate-data-segments",
"",
"Separate data segments to a file",
WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&dataSegmentFile](Options* o, const std::string& argument) {
dataSegmentFile = argument;
})
.add("--check-stack-overflow",
"",
"Check for stack overflows every time the stack is extended",
Expand Down Expand Up @@ -294,14 +274,6 @@ int main(int argc, const char* argv[]) {
passRunner.add("strip-dwarf");
}

// Finally, separate out data segments if relevant
if (!dataSegmentFile.empty()) {
passRunner.options.arguments["separate-data-segments"] = dataSegmentFile;
passRunner.options.arguments["separate-data-segments-global-base"] =
std::to_string(globalBase);
passRunner.add("separate-data-segments");
}

passRunner.run();

BYN_TRACE_WITH_TYPE("emscripten-dump", "Module after:\n");
Expand Down
5 changes: 0 additions & 5 deletions test/lit/help/wasm-emscripten-finalize.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
;; CHECK-NEXT: output file. In this mode if no output
;; CHECK-NEXT: file is specified, we write to stdout.
;; CHECK-NEXT:
;; CHECK-NEXT: --global-base The address at which static globals were
;; CHECK-NEXT: placed
;; CHECK-NEXT:
;; CHECK-NEXT: --side-module Input is an emscripten side module
;; CHECK-NEXT:
;; CHECK-NEXT: --input-source-map,-ism Consume source map from the specified
Expand All @@ -42,8 +39,6 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --output-source-map-url,-osu Emit specified string as source map URL
;; CHECK-NEXT:
;; CHECK-NEXT: --separate-data-segments Separate data segments to a file
;; CHECK-NEXT:
;; CHECK-NEXT: --check-stack-overflow Check for stack overflows every time the
;; CHECK-NEXT: stack is extended
;; CHECK-NEXT:
Expand Down
Binary file removed test/lld/em_asm.wat.mem.mem
Binary file not shown.
68 changes: 0 additions & 68 deletions test/lld/em_asm.wat.mem.out

This file was deleted.

Binary file removed test/lld/hello_world.wat.mem.mem
Binary file not shown.
27 changes: 0 additions & 27 deletions test/lld/hello_world.wat.mem.out

This file was deleted.

2 changes: 1 addition & 1 deletion test/unit/test_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class EmscriptenFinalizeTest(utils.BinaryenTestCase):
def do_output_test(self, args):
# without any output file specified, don't error, don't write the wasm
p = shared.run_process(shared.WASM_EMSCRIPTEN_FINALIZE + [
self.input_path('empty_lld.wat'), '--global-base=1024'
self.input_path('empty_lld.wat')
] + args, capture_output=True)
return p.stdout

Expand Down

0 comments on commit e031490

Please sign in to comment.