Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm: Upgrade Emscripten 2.0.13 => 3.0.0 #880

Merged
merged 7 commits into from
Nov 24, 2021

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Nov 24, 2021

All the way to the current latest version.

Interesting changes
  • Clang now performs loop unrolling when targeting WebAssembly at -O2 and higher. It can be disabled using -fno-unroll-loops.

  • Use LLVM's new pass manager by default, as LLVM does. This changes a bunch of things about how LLVM optimizes and inlines, so it may cause noticeable changes in compile times, code size, and speed, either for better or for worse.

  • When building with -s MAIN_MODULE emscripten will now error on undefined symbol by default. This matches the behvious of clang/gcc/msvc. This requires that your side modules be present on the command line. If you do not specify your side modules on the command line (either direcly or via RUNTIME_LINKED_LIBS) you may need to add -s WARN_ON_UNDEFINED_SYMBOLS=0 to avoid errors about symbol that are missing at link time (but present in your side modules provided at runtime). We hope that this case is not common and most users are building with side modules listed on the command line.

  • The WebAssembly linker (wasm-ld) now performes string tail merging on any static string data in your program.

  • wasm-ld will now perform string tail merging in debug string sections as well as regular data sections.

  • Symbols marked as visibility hidden are no longer exported from C/C++ code when building with SIDE_MODULE, MAIN_MODULE or LINKABLE. If you need to export a hidden symbol you can still do so by adding it to EXPORTED_FUNCTIONS.

  • Drop support for node versions older than v5.10.0. We now assume the existence of Buffer.from which was added in v5.10.0.

  • libcxxabi updated to llvm-12.

  • libcxx updated to llvm-12.

  • The version of musl libc used by emscripten was upgraded from v1.1.15 to v1.2.2. There could be some minor size regressions (or gains) due to changes in upstream musl code but we don't expect anything major. Since this is a fairly substantial change (at least internally) we are bumping the major version of Emscripten to 3.

Despite all this, the linker issues persist, so there's another workaround to keep the libthemis.wasm binary usable.

Also, update provisional version of WasmThemis to 0.13.13. I should have done this in #878, but I somehow missed that 0.13.11 has been already released for WasmThemis.

Checklist

  • Change is covered by automated tests
  • The coding guidelines are followed
  • Changelog is updated (in case of notable or breaking changes)

Uneventful minor version upgrade.

- Clang now performs loop unrolling when targeting WebAssembly at -O2
  and higher. It can be disabled using `-fno-unroll-loops`.

- Use LLVM's new pass manager by default, as LLVM does. This changes a
  bunch of things about how LLVM optimizes and inlines, so it may cause
  noticeable changes in compile times, code size, and speed, either for
  better or for worse.
- `EXTRA_EXPORTED_RUNTIME_METHODS` is deprecated in favor of just using
  `EXPORTED_RUNTIME_METHODS`.
- When building with `-s MAIN_MODULE` emscripten will now error
  on undefined symbol by default. This matches the behvious of
  clang/gcc/msvc. This requires that your side modules be present
  on the command line. If you do not specify your side modules on the
  command line (either direcly or via `RUNTIME_LINKED_LIBS`) you may
  need to add `-s WARN_ON_UNDEFINED_SYMBOLS=0` to avoid errors about
  symbol that are missing at link time (but present in your side modules
  provided at runtime). We hope that this case is not common and most
  users are building with side modules listed on the command line.

(I still can't figure out linkage with Emscripten, so whatever...)
Another uneventful minor version upgrade.

- The WebAssembly linker (`wasm-ld`) now performes string tail merging
  on any static string data in your program.
- wasm-ld will now perform string tail merging in debug string sections
  as well as regular data sections.
- libcxxabi updated to llvm-12.
- libcxx updated to llvm-12.
- Drop support for node versions older than v5.10.0. We now assume the
  existence of `Buffer.from` which was added in v5.10.0.
- Bug fixes
- Symbols marked as visibility hidden are no longer exported from C/C++
  code when building with `SIDE_MODULE`, `MAIN_MODULE` or `LINKABLE`.
  If you need to export a hidden symbol you can still do so by adding
  it to EXPORTED_FUNCTIONS.
New major version mostly means that they have removed some functions
(that we don't use), and the new version of musl which is fairly minor
in and of itself.

- The version of musl libc used by emscripten was upgraded from v1.1.15
  to v1.2.2. There could be some minor size regressions (or gains) due
  to changes in upstream musl code but we don't expect anything major.
  Since this is a fairly substantial change (at least internally) we
  are bumping the major version of Emscripten to 3.
I have somehow missed that we have released 0.13.11 already for
WasmThemis, and there is 0.13.12 for SwiftThemis, so the next minor
version for WasmThemis will be at least 0.13.13, right?
@ilammy ilammy added this to the 0.14.0 milestone Nov 24, 2021
@ilammy ilammy added the W-WasmThemis 🌐 Wrapper: WasmThemis, JavaScript API, npm packages label Nov 24, 2021
Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

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

Let’s make emscripten happy! (And us)

@@ -24,14 +24,19 @@ WASM_PRE_JS = $(abspath $(WASM_PATH)/emscripten/pre.js)

WASM_PACKAGE = $(BIN_PATH)/wasm-themis.tgz

$(BIN_PATH)/libthemis.js: LDFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS=@$(WASM_RUNTIME)
$(BIN_PATH)/libthemis.js: LDFLAGS += -s EXPORTED_RUNTIME_METHODS=@$(WASM_RUNTIME)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why has the changed variable's name? who depends on it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why has the changed variable's name?

Emscripten changelog quoted in commit message:

2.0.18: 04/23/2021
------------------

- `EXTRA_EXPORTED_RUNTIME_METHODS` is deprecated in favor of just using
  `EXPORTED_RUNTIME_METHODS`.

who depends on it?

That would be the linker. This tells what Emscripten runtime methods to retain so that WasmThemis can make use of them.

@ilammy ilammy merged commit 09bdb5a into cossacklabs:master Nov 24, 2021
@ilammy ilammy deleted the wasm-upgrade-emscripten branch November 24, 2021 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
W-WasmThemis 🌐 Wrapper: WasmThemis, JavaScript API, npm packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants