Skip to content

Commit

Permalink
fix(api/unstable): make all api methods visible (#4015)
Browse files Browse the repository at this point in the history
* add appropriate includes so that all api methods are visible when s2n-tls is compiled as a shared object
* autogenerate bindings for all api methods and test the visibility to prevent a regression
  • Loading branch information
jmayclin authored May 25, 2023
1 parent eb52b0d commit 1f03ba5
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 166 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ jobs:
run: cargo test

- name: Test external build
# if this test is failing, make sure that api headers are appropriately
# included. For a symbol to be visible in a shared lib, the
# __attribute__((visibility("default"))) label must be on a declaration
# in the same unit of compilation as the definition. Generally this just
# means that if the linker can't resolve foo_method in tls/foo.c, you
# forgot to include api/unstable/foo.h in tls/foo.c
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cmake . -Bbuild -DBUILD_SHARED_LIBS=on -DBUILD_TESTING=off
cmake --build build
cmake --build build -- -j $(nproc)
export S2N_TLS_LIB_DIR=`pwd`/build/lib
export S2N_TLS_INCLUDE_DIR=`pwd`/api
Expand Down Expand Up @@ -124,7 +130,7 @@ jobs:
run: grep "rust-version = \"$(cat ${{env.ROOT_PATH}}/rust-toolchain)\"" ${{env.ROOT_PATH}}/s2n-tls/Cargo.toml

- name: Check MSRV of s2n-tls-sys
run: grep "rust-version = \"$(cat ${{env.ROOT_PATH}}/rust-toolchain)\"" ${{env.ROOT_PATH}}/s2n-tls-sys/Cargo.toml
run: grep "rust-version = \"$(cat ${{env.ROOT_PATH}}/rust-toolchain)\"" ${{env.ROOT_PATH}}/s2n-tls-sys/templates/Cargo.template

- name: Check MSRV of s2n-tokio
run: grep "rust-version = \"$(cat ${{env.ROOT_PATH}}/rust-toolchain)\"" ${{env.ROOT_PATH}}/s2n-tls-tokio/Cargo.toml
Expand Down
3 changes: 2 additions & 1 deletion bindings/rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ Cargo.lock
s2n-tls-sys/files.rs
s2n-tls-sys/lib
s2n-tls-sys/src/api.rs
s2n-tls-sys/src/quic.rs
s2n-tls-sys/src/tests.rs
s2n-tls-sys/src/features*
Cargo.toml
7 changes: 6 additions & 1 deletion bindings/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[workspace]
members = [
"generate",
"integration",
"s2n-tls",
"s2n-tls-sys",
"s2n-tls-tokio",
]
# generate can't be included in the workspace because of a bootstrapping problem
# s2n-tls-sys/Cargo.toml (part of the workspace) is generated by
# generate/main.rs
exclude = [
"generate"
]

[profile.release]
lto = true
Expand Down
9 changes: 4 additions & 5 deletions bindings/rust/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pushd "$(dirname "${BASH_SOURCE[0]}")"
rm -rf s2n-tls-sys/lib
mkdir -p s2n-tls-sys/lib
mkdir -p s2n-tls-sys/lib/tests
mkdir -p s2n-tls-sys/src/features

# we copy the C sources into the `lib` directory so they get published in the
# actual crate artifact.
Expand All @@ -36,16 +37,14 @@ cp -r \
# generate the bindings modules from the copied sources
pushd generate
cargo run -- ../s2n-tls-sys
popd
popd

# make sure everything builds and passes sanity checks
pushd s2n-tls-sys
cargo test
cargo test --features pq
cargo test --features quic
cargo test --features internal
cargo test --all-features
cargo test --release
cargo publish --dry-run --allow-dirty
cargo publish --dry-run --allow-dirty
cargo publish --dry-run --allow-dirty --all-features
popd

Expand Down
2 changes: 1 addition & 1 deletion bindings/rust/generate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ license = "Apache-2.0"
publish = false

[dependencies]
bindgen = "0.58"
bindgen = "0.65"
glob = "0.3"
Loading

0 comments on commit 1f03ba5

Please sign in to comment.