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

Error when trying the new HTML5 GDNative support: "Assertion failed: need the dylink section to be first" #44886

Closed
setzer22 opened this issue Jan 3, 2021 · 2 comments

Comments

@setzer22
Copy link

setzer22 commented Jan 3, 2021

Godot version:

3.2.4.beta4.official

OS/device including version:
Arch Linux (rolling release) on Linux Kernel 5.9.10 (please let me know if you need more information as I'm unsure what to include here).

Issue description:
I wanted to try out the new GDNative support for HTML5 builds (https://godotengine.org/article/godot-web-export-progress-report-4, #44076) for my game, which is using Rust via the godot-rust bindings (https://github.com/godot-rust/godot-rust). I managed to compile a .wasm library using emscripten, but after trying to load the game on the browser I just got a blank page with the spinner wheel and the following errors on the console:

On Firefox 83:

Assertion failed: need the dylink section to be first tmp_js_export.js:9:16304
Uncaught (in promise) Error: undefined tmp_js_export.js:9:16407
Uncaught (in promise) Error: undefined tmp_js_export.js:9:16407

On Chromium 87:

Uncaught (in promise) RuntimeError: abort(Assertion failed: need the dylink section to be first). Build with -s ASSERTIONS=1 for more info.
    at abort (http://localhost:8060/tmp_js_export.js:9:16407)
    at assert (http://localhost:8060/tmp_js_export.js:9:6791)
    at loadSideModule (http://localhost:8060/tmp_js_export.js:9:22451)
    at http://localhost:8060/tmp_js_export.js:9:26930
    at async Promise.all (index 1)
Assertion failed: need the dylink section to be first

Steps to reproduce:

  • Create a project with a minimal setup for GDNative compilation (a zip file is provided below).
  • Compile the native shared library as a wasm module via emscripten (steps provided for the Rust language and my linux distribution, ymmv)
    1. Install emscripten via emsdk: emsdk install latest && emsdk activate latest (may require root privileges)
    2. Install the emscripten toolchain for Rust as described here (https://www.hellorust.com/setup/emscripten/). That is:
      rustup toolchain add stable
      rustup target add asmjs-unknown-emscripten --toolchain stable
      rustup target add wasm32-unknown-emscripten --toolchain stable
    3. Build the project using the wasm32-unknown-emscripten target. In the minimal reproduction project, this can be achieved by:
      cd $PROJECT_PATH/rust/
      C_INCLUDE_PATH=/usr/include cargo build --target wasm32-unknown-emscripten
    4. After this, a .wasm file should be generated under rust/target/wasm32-unknown-emscripten/debug/rust_test.wasm
  • On the gdnlib resource, use the new HTML5 > wasm32 section and make it point to the wasm file generated on the previous step.
  • Open the Export panel (i.e. Project > Export). Download the export templates for the current version when prompted, if necessary. Finally set up a new HTML5 export and select GDNative on the Export Type dropdown.
  • Export the game and/or run it directly from the editor via the HTML5 run button. The aforementioned message will be dislpayed on the console.

Minimal reproduction project:
GDNative_Rust_Example.zip

The minimal reproduction project contains the following:

  • A simple scene, with a label and an initial text of "".
  • A RustTestScript node, with the native script attached.
    • This script exposes a get_test_message method, which simply returns a string.
  • A Control node, with a Main.gd script attached.
    • This script calls get_test_message on the native script, and sets the Label's text to it.

This has been tested to work with a regular desktop build under 64 bit Linux. Based on experience from my own project, it should work just as fine in other platforms as well (e.g. never had trouble building like this on windows, for instance).

Note that, due to file size, I could not upload the build files, just the compiled wasm module. If anyone is interested in those just let me know, but they can still be regenerated with the procedure described above.

About the issue

I'm not sure if this is a bug on the Godot side, it could just be that I'm not building the wasm module correctly. But I'm nontheless reporting this because it may be helpful to diagnose a potential issue, and help other people looking into this with the same kind of problem.

If anything, I think the expected procedure to compile wasm gdnative modules for the HTML5 exporter should be documented. It's totally understandable that it still isn't, this was just released in a beta after all! 😅 I was hoping rasing thiss issue would help towards that goal.

@setzer22
Copy link
Author

setzer22 commented Jan 3, 2021

I'm closing because this does not seem to have anything to do with Godot. My findings so far:

@extrawurst
Copy link
Contributor

@setzer22 maybe this thread Is of interest for you: godot-rust/gdnative#647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants