diff --git a/Makefile.envs b/Makefile.envs index 8884d52a4..f0f998765 100644 --- a/Makefile.envs +++ b/Makefile.envs @@ -148,7 +148,7 @@ export STDLIB_MODULE_CFLAGS= $(SIDE_MODULE_CFLAGS) -I Include/ -I . # For RUST export CARGO_HOME ?= $(HOME)/.cargo export CARGO_BUILD_TARGET=wasm32-unknown-emscripten -export CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=emcc +export CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=$(PYODIDE_ROOT)/tools/rust_emcc_wrapper.py export PYO3_CONFIG_FILE=$(PYODIDE_ROOT)/tools/pyo3_config.ini # idealy we could automatically include all SIDE_MODULE_LDFLAGS here diff --git a/emsdk/patches/0004-Disable-whole-archive-when-linking-rust.patch b/emsdk/patches/0004-Disable-whole-archive-when-linking-rust.patch deleted file mode 100644 index 75d01db52..000000000 --- a/emsdk/patches/0004-Disable-whole-archive-when-linking-rust.patch +++ /dev/null @@ -1,33 +0,0 @@ -From c250eb29047c4341cdc1d13f3706eb6991cf0f9b Mon Sep 17 00:00:00 2001 -From: Hood Chatham -Date: Thu, 6 Jan 2022 09:40:39 -0800 -Subject: [PATCH 4/4] Disable whole-archive when linking rust - -Rust .rlib archives contain an extra metadata file called lib.rmeta. -Emscripten sets `--whole-archive` by default if LINKABLE is set. -But with `--whole-archive` the linker crashes with an error due to -the extra files. This disables the problematic `--whole-archive` -setting when we are linking rust. - -See emscripten issue: -https://github.com/emscripten-core/emscripten/issues/17109 ---- - tools/building.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/building.py b/tools/building.py -index 24ddaa13f..cb015e18f 100644 ---- a/tools/building.py -+++ b/tools/building.py -@@ -360,7 +360,7 @@ def link_lld(args, target, external_symbols=None): - - # Emscripten currently expects linkable output (SIDE_MODULE/MAIN_MODULE) to - # include all archive contents. -- if settings.LINKABLE: -+ if settings.LINKABLE and not any(arg.endswith(".rlib") for arg in args): - args.insert(0, '--whole-archive') - args.append('--no-whole-archive') - --- -2.25.1 - diff --git a/packages/cryptography/meta.yaml b/packages/cryptography/meta.yaml index 1dac92447..81713b4a3 100644 --- a/packages/cryptography/meta.yaml +++ b/packages/cryptography/meta.yaml @@ -1,7 +1,6 @@ package: name: cryptography version: 36.0.2 - _disabled: true source: url: https://files.pythonhosted.org/packages/10/a7/51953e73828deef2b58ba1604de9167843ee9cd4185d8aaffcb45dd1932d/cryptography-36.0.2.tar.gz @@ -25,6 +24,7 @@ build: $(OPENSSL_INCLUDE_PATH) ldflags: | $(OPENSSL_LIBRARY_PATH) + -Wl,--no-entry requirements: run: - openssl diff --git a/tools/rust_emcc_wrapper.py b/tools/rust_emcc_wrapper.py new file mode 100755 index 000000000..b64edf1bf --- /dev/null +++ b/tools/rust_emcc_wrapper.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +import subprocess +import sys + + +def update_args(args): + # https://github.com/emscripten-core/emscripten/issues/17109 + args.insert(0, "-Wl,--no-whole-archive") + + # Remove -s ASSERTIONS=1 + # See https://github.com/rust-lang/rust/pull/97928 + for i in range(len(args)): + if "ASSERTIONS" in args[i]: + del args[i - 1 : i + 1] + break + + # remove -lc. Not sure if it makes a difference but -lc doesn't belong here. + # https://github.com/emscripten-core/emscripten/issues/17191 + for i in reversed(range(len(args))): + if args[i] == "c" and args[i - 1] == "-l": + del args[i - 1 : i + 1] + + # Prevent a bunch of errors caused by buggy behavior in + # `esmcripten/tools/building.py:lld_flags_for_executable` REQUIRED_EXPORTS + # contains symbols that should come from the main module. + # https://github.com/emscripten-core/emscripten/issues/17202 + args.append("-sERROR_ON_UNDEFINED_SYMBOLS=0") + # Seems like --no-entry should be implied by SIDE_MODULE but apparently it + # isn't? + args.append("-Wl,--no-entry") + # Without this, the dylink section seems to get deleted which causes trouble + # at load time. + args.append("-Wl,--no-gc-sections") + + return args + + +def main(args): + args = update_args(args) + return subprocess.call(["emcc"] + args) + + +if __name__ == "__main__": + args = sys.argv[1:] + sys.exit(main(args))