Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/tools/wasm-split/wasm-split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ void splitModule(const WasmSplitOptions& options) {
}
continue;
}
if (function->name == wasm.start) {
if (!options.quiet) {
std::cerr << "warning: cannot split out start function " << func
<< "\n";
}
continue;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you do the same thing in multiSplitModule after this line?

assert(currFuncs);

Then we don't need to do anything in module-splitting.cpp.

Also while you're at it you can add this there too, to be consistent with splitModule:

if (!function) {
if (!options.quiet) {
std::cerr << "warning: function " << func << " does not exist\n";
}
continue;
}
if (function->imported()) {
if (!options.quiet) {
std::cerr << "warning: cannot split out imported function " << func
<< "\n";
}
continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better, we can factor these three checks out to a function use it in both places

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (!options.quiet && options.keepFuncs.contains(func)) {
std::cerr << "warning: function " << func
<< " was to be both kept and split. It will be split.\n";
Expand Down
28 changes: 28 additions & 0 deletions test/lit/wasm-split/start.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: wasm-split %s --split-funcs=start_func,other -o1 %t.1.wasm -o2 %t.2.wasm -g 2>&1 | filecheck %s
;; RUN: wasm-dis -all %t.1.wasm | filecheck %s --check-prefix PRIMARY
;; RUN: wasm-dis -all %t.2.wasm | filecheck %s --check-prefix SECONDARY

;; Do not error on trying to split out the start function. It cannot be
;; split out, keep it in the primary module.

(module
;; PRIMARY: (type $0 (func))

;; PRIMARY: (start $start_func)

;; PRIMARY: (func $start_func (type $0)
;; PRIMARY-NEXT: )
(func $start_func)

(start $start_func)

;; SECONDARY: (type $0 (func))

;; SECONDARY: (func $other (type $0)
;; SECONDARY-NEXT: )
(func $other)
)


Loading