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

Add CI test for FreeBSD #477

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,24 @@ jobs:
run: cargo ${{ env.ACTION_CARGO }} -p aws-lc-rs --all-targets --target ${{ matrix.target }} --features bindgen
- name: Release Build for ${{ matrix.target }}
run: cargo ${{ env.ACTION_CARGO }} --release -p aws-lc-rs --all-targets --target ${{ matrix.target }}
freebsd:
if: github.repository_owner == 'aws'
name: aws-lc-rs freebsd test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Prepare VM
uses: vmactions/freebsd-vm@v1
with:
release: 13.2
usesh: true
copyback: false
prepare: |
pkg install -y git gmake bash sudo cmake-core llvm-devel-lite curl rust-bindgen-cli

Choose a reason for hiding this comment

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

do we expect bindgen's CLI to be stable through time? is there a way to pin it to current version?

Copy link
Contributor Author

@justsmth justsmth Aug 6, 2024

Choose a reason for hiding this comment

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

I would hope it remains stable. If not, our policy will be to support the latest version of "bindgen" and advise consumers to re-install/upgrade to the latest.

run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
export AWS_LC_SYS_EXTERNAL_BINDGEN=1
cargo test -p aws-lc-rs
1 change: 1 addition & 0 deletions aws-lc-sys/builder/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn prepare_bindings_builder(manifest_dir: &Path, options: &BindingOptions) -> bi
.allowlist_file(r".*(/|\\)openssl((/|\\)[^/\\]+)+\.h")
.allowlist_file(r".*(/|\\)rust_wrapper\.h")
.rustified_enum(r"point_conversion_form_t")
.rust_target(bindgen::RustTarget::Stable_1_59)
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
.generate_comments(true)
.fit_macro_constants(false)
Expand Down
40 changes: 30 additions & 10 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{fmt, fmt::Debug};

use cc_builder::CcBuilder;
use cmake_builder::CmakeBuilder;
Expand Down Expand Up @@ -353,6 +354,12 @@ fn is_bindgen_required() -> bool {
|| !has_pregenerated()
}

fn internal_bindgen_supported() -> bool {
// TODO: internal bindgen creates invalid bindings on FreeBSD
// See: https://github.com/aws/aws-lc-rs/issues/476
target_os() != "freebsd"
}

fn is_no_prefix() -> bool {
unsafe { AWS_LC_SYS_NO_PREFIX }
}
Expand Down Expand Up @@ -436,7 +443,7 @@ fn main() {
all(target_arch = "x86", target_os = "linux", target_env = "gnu")
))
))]
if !is_external_bindgen() {
if internal_bindgen_supported() && !is_external_bindgen() {
emit_warning(&format!(
"Generating bindings - internal bindgen. Platform: {}",
target()
Expand Down Expand Up @@ -532,6 +539,16 @@ pub(crate) struct BindingOptions {
pub disable_prelude: bool,
}

impl Debug for BindingOptions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BindingOptions")
.field("build_prefix", &self.build_prefix)
.field("include_ssl", &self.include_ssl)
.field("disable_prelude", &self.disable_prelude)
.finish()
}
}

fn invoke_external_bindgen(
manifest_dir: &Path,
prefix: &Option<String>,
Expand Down Expand Up @@ -579,25 +596,28 @@ fn invoke_external_bindgen(
// to conform with the most recent release. We will guide consumers to likewise use the
// latest version of bindgen-cli.
bindgen_params.extend(vec![
"--rust-target",
r"1.59",
"--with-derive-default",
"--with-derive-eq",
"--allowlist-file",
r".*(/|\\)openssl(/|\\)[^/\\]+\.h",
r".*(/|\\)openssl((/|\\)[^/\\]+)+\.h",
"--allowlist-file",
r".*(/|\\)rust_wrapper\.h",
"--rustified-enum",
r"point_conversion_form_t",
"--default-macro-constant-type",
r"signed",
"--formatter",
r"rustfmt",
"--output",
gen_bindings_path.to_str().unwrap(),
"--with-derive-default",
"--with-derive-partialeq",
"--with-derive-eq",
"--raw-line",
COPYRIGHT,
"--generate",
"functions,types,vars,methods,constructors,destructors",
header.as_str(),
"--rust-target",
r"1.59",
"--output",
gen_bindings_path.to_str().unwrap(),
"--formatter",
r"rustfmt",
"--",
]);
clang_args
Expand Down
Loading