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

Cryptography v36.0.2 w/ Rust #2378

Merged
merged 83 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
7090a37
Set up pyo3_samples package
hoodmane Jan 6, 2022
0160a42
Run formatter
hoodmane Jan 6, 2022
2170e63
Remove pointless asserts from test suite
hoodmane Jan 6, 2022
b3d9b1c
Add component rust-src
hoodmane Jan 6, 2022
02fea7e
Rename test
hoodmane Jan 6, 2022
ce0348a
Scratch work
hoodmane Jan 10, 2022
9d5a49f
Merge branch 'main' into pyo3
hoodmane Jan 17, 2022
9b512a2
Merge branch 'main' into pyo3
hoodmane Apr 8, 2022
1c2ebc2
Update patch, meta.yaml
hoodmane Apr 8, 2022
4f74267
Temp
hoodmane Apr 8, 2022
ec05656
Add emscripten patch for dyncall viij
hoodmane Apr 9, 2022
01782c8
I think things work now?
hoodmane Apr 9, 2022
db9ca33
Add a comment
hoodmane Apr 9, 2022
41bf843
Merge branch 'main' into rust-crypto
hoodmane Apr 9, 2022
977b50d
Fix patch:
hoodmane Apr 9, 2022
5f32f46
Use patched chrono
hoodmane Apr 9, 2022
dafb0a0
Fix bad export type _emscripten_get_now undefined
hoodmane Apr 9, 2022
e7ec1fc
Select correct branch of chrono
hoodmane Apr 9, 2022
4e476ff
Add patch
hoodmane Apr 9, 2022
ff9b05c
Remove pyo3_samples
hoodmane Apr 9, 2022
ad92c24
Add crate to the list of words that aren't spelled wrong
hoodmane Apr 9, 2022
b8c7963
Remove out of date tests
hoodmane Apr 9, 2022
af003d6
Install nightly toolchain
hoodmane Apr 9, 2022
f0fcc05
Add pyo3_config, some cleanup
hoodmane Apr 9, 2022
cfafcda
Merge branch 'main' into rust-crypto
hoodmane Apr 9, 2022
9993777
Merge branch 'main' into rust-crypto
hoodmane Apr 15, 2022
7bec7ab
Simplify flags a bit
hoodmane Apr 15, 2022
8d25b1b
Merge branch 'main' into rust-crypto
hoodmane May 29, 2022
1a8e1d2
Move rather than copy
hoodmane May 29, 2022
bd5341d
Add todo to remove chrono patch when possible
hoodmane May 29, 2022
1c21c2f
Enable Wasm BigInt
hoodmane May 30, 2022
4232555
Fix patch
hoodmane May 30, 2022
fcb297c
Update patch
hoodmane May 30, 2022
61c6ebf
Fix patch
hoodmane May 30, 2022
49600b1
MAINT Improve debug settings in Makefile.envs
hoodmane May 30, 2022
be58530
run prettier on pyodide.asm.js if symbols are requested
hoodmane May 30, 2022
740aa0a
Merge branch 'debug-settings' into wasm-bigint
hoodmane May 30, 2022
89dafcd
Update side modules to use SIDE_MODULE_LDFLAGS
hoodmane May 30, 2022
ea35af3
Merge branch 'main' into rust-crypto2
hoodmane May 30, 2022
38b3e95
Move some environment variables out of cryptography/meta.yaml into Ma…
hoodmane May 30, 2022
9e60830
move nightly install into .circleci config
hoodmane May 30, 2022
1047114
Update patch to eliminate need for EMSCRIPTEN_LINKING_RUST
hoodmane May 30, 2022
46912f8
Remove patch from other branch
hoodmane May 30, 2022
2797669
Put back in dyncall fix
hoodmane May 30, 2022
f30c128
Put back in fexceptions flags
hoodmane May 30, 2022
b62aa82
Update changelog
hoodmane May 30, 2022
87c91c6
Ask for the same nightly version in pywasmcross that we install in ci…
hoodmane May 30, 2022
066e3d0
Update patch
hoodmane May 30, 2022
17580ef
Add comment and fix signature of emscripten_get_now
hoodmane May 31, 2022
5499d42
Add reference to emscripten issue
hoodmane May 31, 2022
29839c4
Update linker error patch
hoodmane May 31, 2022
7eb47b6
Move rust install into Makefile per ryanking13's suggestion
hoodmane May 31, 2022
a1c1f8a
Fix Makefile rust recipe
hoodmane May 31, 2022
eae9b28
Fix make rust script
hoodmane May 31, 2022
6c78842
Merge branch 'main' into rust-crypto
hoodmane Jun 1, 2022
79f7adc
Updates based on upstream fixes for emscripten_get_now problem
hoodmane Jun 1, 2022
4b05ce4
Update patch
hoodmane Jun 1, 2022
f708e91
Merge branch 'wasm-bigint' into rust-crypto
hoodmane Jun 1, 2022
c927e3d
Update patch
hoodmane Jun 1, 2022
19dc503
Merge branch 'wasm-bigint' into rust-crypto
hoodmane Jun 1, 2022
ef9282e
Merge branch 'main' into wasm-bigint
hoodmane Jun 1, 2022
215170b
Update instant patch
hoodmane Jun 1, 2022
e3b0ce2
Use stable rust
hoodmane Jun 1, 2022
080cbc6
update patch
hoodmane Jun 1, 2022
610fc31
Merge branch 'wasm-bigint' into rust-crypto
hoodmane Jun 1, 2022
344a286
Update patch
hoodmane Jun 1, 2022
44f2e5e
Update patch
hoodmane Jun 1, 2022
a10c1cc
Merge branch 'wasm-bigint' into rust-crypto
hoodmane Jun 1, 2022
6884205
Revert some unneeded changes
hoodmane Jun 1, 2022
3a43f8f
Merge branch 'main' into rust-crypto
hoodmane Jun 1, 2022
2c800f9
Reduce diff
hoodmane Jun 1, 2022
6ae843e
Compile rust with WASM_BIGINT too
hoodmane Jun 2, 2022
a47562a
Merge branch 'main' into rust-crypto
hoodmane Jun 2, 2022
7091ee5
Add link to emscripten issue to whole-archive patch
hoodmane Jun 2, 2022
ad2d42d
Add comment
hoodmane Jun 2, 2022
bf389f9
Add Rust to docker image
hoodmane Jun 7, 2022
8f47368
Remove 'make rust' step from ci config
hoodmane Jun 7, 2022
034a8ee
Don't source cargo in cryptography/meta.yaml
hoodmane Jun 7, 2022
db8bf11
Remove make rust recipe
hoodmane Jun 7, 2022
1a72996
Source cargo env
hoodmane Jun 7, 2022
c1ed178
Update docker recipe
hoodmane Jun 8, 2022
d05db31
Revert "Add Rust to docker image"
hoodmane Jun 8, 2022
75e719b
Update docs
hoodmane Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .circleci/config.yml
Expand Up @@ -129,6 +129,11 @@ jobs:
- -pkg2-v20220303-{{ checksum "Makefile.envs" }}
- -pkg2-v20220303

- run:
name: install rust
command: |
make rust

- run:
name: build packages
no_output_timeout: 60m
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -101,5 +101,5 @@ repos:
rev: "v2.1.0"
hooks:
- id: codespell
args: ["-L", "te,slowy,aray,ba,nd,classs,feld"]
args: ["-L", "te,slowy,aray,ba,nd,classs,crate,feld"]
exclude: ^benchmark/benchmarks/pystone_benchmarks/pystone\.py$
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -243,6 +243,12 @@ emsdk/emsdk/.complete:
date +"[%F %T] done building emsdk."


rust:
wget https://sh.rustup.rs -O /rustup.sh
sh /rustup.sh -y
source $(HOME)/.cargo/env && rustup target add wasm32-unknown-emscripten --toolchain stable


FORCE:


Expand Down
12 changes: 12 additions & 0 deletions Makefile.envs
Expand Up @@ -146,5 +146,17 @@ export MAIN_MODULE_CFLAGS= $(CFLAGS_BASE) \

export STDLIB_MODULE_CFLAGS= $(SIDE_MODULE_CFLAGS) -I Include/ -I .

# For RUST
export CARGO_BUILD_TARGET=wasm32-unknown-emscripten
export CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=emcc
export PYO3_CONFIG_FILE=$(PYODIDE_ROOT)/tools/pyo3_config.ini

# idealy we could automatically include all SIDE_MODULE_LDFLAGS here
export RUSTFLAGS= \
-C relocation-model=pic \
-C target-feature=+mutable-globals \
-C link-arg=-sSIDE_MODULE=1 \
-C link-arg=-sWASM_BIGINT

.output_vars:
set
2 changes: 1 addition & 1 deletion cpython/adjust_sysconfig.py
Expand Up @@ -23,7 +23,7 @@ def adjust_sysconfig(config_vars: dict[str, str]):
MAINCC="cc",
LDSHARED="cc",
LINKCC="cc",
BLDSHARED="cc",
BLDSHARED="emcc -sSIDE_MODULE=1", # setuptools-rust looks at this
CXX="c++",
LDCXXSHARED="c++",
)
Expand Down
@@ -1,7 +1,7 @@
From e83a295f8e1b8c48d4748d1811a4b22840f25e14 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Thu, 24 Jun 2021 04:08:02 -0700
Subject: [PATCH 1/6] Throw away errors in minify_wasm_js
Subject: [PATCH 1/8] Throw away errors in minify_wasm_js

---
emcc.py | 13 ++++++++-----
Expand Down
2 changes: 1 addition & 1 deletion emsdk/patches/0002-Fix-dup.patch
@@ -1,7 +1,7 @@
From 40956dee436737d9dd40e0b57c6e2ebd26569920 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Wed, 8 Sep 2021 17:49:15 -0700
Subject: [PATCH 2/6] Fix dup
Subject: [PATCH 2/8] Fix dup

This fixes two problems with the `dup` system calls:
1. `dup` expects that every file descriptor has a corresponding file (so pipes and (https://github.com/emscripten-core/emscripten/issues/14640)
Expand Down
@@ -1,7 +1,7 @@
From 73b89ee1b5a57c65824baf91b547be32b69decbd Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Tue, 15 Feb 2022 23:27:03 -0500
Subject: [PATCH 3/6] Fix side module exception handling
Subject: [PATCH 3/8] Fix side module exception handling

See https://github.com/emscripten-core/emscripten/pull/16309

Expand Down
@@ -1,7 +1,7 @@
From 8de43377d0e72a4c5794f8494a06d81a9609090f Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 2 Mar 2022 13:44:14 -0800
Subject: [PATCH 4/6] Fix lookupPath when applied to a symlink loop
Subject: [PATCH 4/8] Fix lookupPath when applied to a symlink loop

The following code leads to an infinite loop in lookupPath:

Expand Down
@@ -1,7 +1,7 @@
From 8eed4062c1a0bd6aa7859938240f8761e6e72114 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 18 May 2022 21:49:17 -0700
Subject: [PATCH 5/6] Indicate Emscripten version in uname
Subject: [PATCH 5/8] Indicate Emscripten version in uname

This patch has been upstreamed:
https://github.com/emscripten-core/emscripten/pull/17026
Expand Down
@@ -1,7 +1,7 @@
From 4462c2871933db0adc4b46a24f77b942caff969c Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sun, 29 May 2022 18:17:29 -0700
Subject: [PATCH 6/6] Add BigInt64Array shim for Safari 14
Subject: [PATCH 6/8] Add BigInt64Array shim for Safari 14

---
src/parseTools.js | 2 +-
Expand Down
33 changes: 33 additions & 0 deletions emsdk/patches/0007-Disable-whole-archive-when-linking-rust.patch
@@ -0,0 +1,33 @@
From 9fb8391c7e6b9f36f45a1448e49597f899cce29d Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Thu, 6 Jan 2022 09:40:39 -0800
Subject: [PATCH 7/8] 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 512561c69..d180993a1 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -443,7 +443,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

26 changes: 26 additions & 0 deletions emsdk/patches/0008-Add-signature-to-emscripten_get_now.patch
@@ -0,0 +1,26 @@
From b6839bba05c1a5eab390f47309a7bef1b7294eca Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 1 Jun 2022 10:54:08 -0700
Subject: [PATCH 8/8] Add signature to emscripten_get_now

Upstream PR:
https://github.com/emscripten-core/emscripten/pull/17123/files
---
src/library.js | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/library.js b/src/library.js
index ef8a618bb..5b5a9d838 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2657,6 +2657,7 @@ LibraryManager.library = {
},

emscripten_get_now__import: true,
+ emscripten_get_now__sig: 'd',
emscripten_get_now: ';' +
#if ENVIRONMENT_MAY_BE_NODE
"if (ENVIRONMENT_IS_NODE) {\n" +
--
2.25.1

23 changes: 16 additions & 7 deletions packages/cryptography/meta.yaml
@@ -1,20 +1,29 @@
package:
name: cryptography
version: 3.4.8
version: 36.0.2

source:
url: https://files.pythonhosted.org/packages/cc/98/8a258ab4787e6f835d350639792527d2eb7946ff9fc0caca9c3f4cf5dcfe/cryptography-3.4.8.tar.gz
sha256: 94cc5ed4ceaefcbe5bf38c8fba6a21fc1d365bb8fb826ea1688e3370b2e24a1c
url: https://files.pythonhosted.org/packages/10/a7/51953e73828deef2b58ba1604de9167843ee9cd4185d8aaffcb45dd1932d/cryptography-36.0.2.tar.gz
sha256: 70f8f4f7bb2ac9f340655cbac89d68c527af5bb4387522a8413e841e3e6628c9
patches:
# TODO: remove this when chrono makes a release
- patches/0001-Use-patched-chrono.patch
- patches/0002-Add-instant-patch.patch
build:
script: |
export OPENSSL_INCLUDE_PATH=$(pkg-config --cflags-only-I --dont-define-prefix openssl)
export OPENSSL_LIBRARY_PATH=$(pkg-config --libs-only-L --dont-define-prefix openssl)
source $HOME/.cargo/env

# TODO: remove this when chrono makes a release
git clone --depth 1 https://github.com/hoodmane/chrono.git --branch pyodide
hoodmane marked this conversation as resolved.
Show resolved Hide resolved
# TODO: remove this when instant makes a release
git clone --depth 1 https://github.com/hoodmane/instant.git --branch emscripten-no-leading-underscore
cflags: |
-Wno-implicit-function-declaration
$(OPENSSL_INCLUDE_PATH)
ldflags: |
$(OPENSSL_LIBRARY_PATH)
script: |
export CRYPTOGRAPHY_DONT_BUILD_RUST=1
export OPENSSL_INCLUDE_PATH=$(pkg-config --cflags-only-I --dont-define-prefix openssl)
export OPENSSL_LIBRARY_PATH=$(pkg-config --libs-only-L --dont-define-prefix openssl)
requirements:
run:
- openssl
Expand Down
26 changes: 26 additions & 0 deletions packages/cryptography/patches/0001-Use-patched-chrono.patch
@@ -0,0 +1,26 @@
From 53ee3cee6aae5333d61ac687677cf2ca39cb831a Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Fri, 8 Apr 2022 18:17:51 -0700
Subject: [PATCH 1/2] Use patched chrono

---
src/rust/Cargo.toml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 617167d0..35bf38ae 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -5,6 +5,9 @@ authors = ["The cryptography developers <cryptography-dev@python.org>"]
edition = "2018"
publish = false

+[patch.crates-io]
+chrono = { path = "../../chrono" }
+
[dependencies]
lazy_static = "1"
pyo3 = { version = "0.15.1" }
--
2.25.1

24 changes: 24 additions & 0 deletions packages/cryptography/patches/0002-Add-instant-patch.patch
@@ -0,0 +1,24 @@
From 196ace04edb63a93000418f91d56a3cec11b8345 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 1 Jun 2022 10:11:44 -0700
Subject: [PATCH 2/2] Add instant patch

---
src/rust/Cargo.toml | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 35bf38ae..23a64977 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -7,6 +7,7 @@ publish = false

[patch.crates-io]
chrono = { path = "../../chrono" }
+instant = { path = "../../instant" }

[dependencies]
lazy_static = "1"
--
2.25.1