From 07f86dac8d3e634bc3813fb90ac5f0eef83a2341 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 27 May 2022 11:55:13 -0700 Subject: [PATCH 01/15] Add relevant `--target` to `cargo test` in CI --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4de7c7fa8..bd1e22367 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,10 +166,10 @@ jobs: run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV - if: "startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')" # CI's Windows doesn't have require root certs - run: cargo test --workspace --exclude tokio-boring --exclude hyper-boring + run: cargo test --workspace --target ${{ matrix.target }} --exclude tokio-boring --exclude hyper-boring name: Run tests (Windows) - if: "!startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')" - run: cargo test + run: cargo test --target ${{ matrix.target }} name: Run tests (not Windows) - if: "contains(matrix.target, 'ios')" # It's... theoretically possible to run tests on iPhone Simulator, From 31fb60c7a4d31023bb3d762ce64f807ad0831dff Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 3 Jun 2022 13:07:14 -0700 Subject: [PATCH 02/15] Refactor check-only and extra-test-args --- .github/workflows/ci.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd1e22367..6f7f51d3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,8 @@ jobs: - i686-msvc - x86_64-msvc include: + - check_only: false + - extra_test_args: '' - thing: stable target: x86_64-unknown-linux-gnu rust: stable @@ -108,12 +110,18 @@ jobs: - thing: aarch64-ios target: aarch64-apple-ios os: macos-latest + check_only: true + # It's... theoretically possible to run tests on iPhone Simulator, + # but for now, make sure that BoringSSL only builds. - thing: aarch64-ios-sim target: aarch64-apple-ios-sim os: macos-latest + check_only: true - thing: x86_64-ios target: x86_64-apple-ios os: macos-latest + + check_only: true - thing: i686-linux target: i686-unknown-linux-gnu rust: stable @@ -138,10 +146,14 @@ jobs: target: i686-pc-windows-msvc rust: stable-x86_64-msvc os: windows-latest + # CI's Windows doesn't have required root certs + extra_test_args: --workspace --exclude tokio-boring --exclude hyper-boring - thing: x86_64-msvc target: x86_64-pc-windows-msvc rust: stable-x86_64-msvc os: windows-latest + # CI's Windows doesn't have required root certs + extra_test_args: --workspace --exclude tokio-boring --exclude hyper-boring steps: - uses: actions/checkout@v2 @@ -151,6 +163,10 @@ jobs: run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} shell: bash - run: rustup target add ${{ matrix.target }} + - name: Install Linux cross-compile dependencies + if: "contains(matrix.target, 'linux') && !startsWith(matrix.target, 'x86_64')" + run: sudo apt install -y gcc-multilib g++-multilib + shell: bash - name: Install nasm if: startsWith(matrix.os, 'windows') run: choco install nasm @@ -164,18 +180,12 @@ jobs: - name: Set LIBCLANG_PATH if: startsWith(matrix.os, 'windows') run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV - - if: "startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')" - # CI's Windows doesn't have require root certs - run: cargo test --workspace --target ${{ matrix.target }} --exclude tokio-boring --exclude hyper-boring - name: Run tests (Windows) - - if: "!startsWith(matrix.os, 'windows') && !contains(matrix.target, 'ios')" - run: cargo test --target ${{ matrix.target }} - name: Run tests (not Windows) - - if: "contains(matrix.target, 'ios')" - # It's... theoretically possible to run tests on iPhone Simulator, - # but for now, make sure that BoringSSL only builds. + - if: "!matrix.check_only" + run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} + name: Run tests + - if: matrix.check_only run: cargo check --target ${{ matrix.target }} --all-targets - name: Check tests (iOS) + name: Check tests - name: Test boring-sys cargo publish # Running `cargo publish --dry-run` tests two things: # From 9d1a81a1a1312297ec88246860ca07810281ae8d Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 3 Jun 2022 13:32:08 -0700 Subject: [PATCH 03/15] Add matrix.apt_packages --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f7f51d3d..77b0491cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,7 @@ jobs: include: - check_only: false - extra_test_args: '' + - apt_packages: '' - thing: stable target: x86_64-unknown-linux-gnu rust: stable @@ -120,7 +121,6 @@ jobs: - thing: x86_64-ios target: x86_64-apple-ios os: macos-latest - check_only: true - thing: i686-linux target: i686-unknown-linux-gnu @@ -164,8 +164,8 @@ jobs: shell: bash - run: rustup target add ${{ matrix.target }} - name: Install Linux cross-compile dependencies - if: "contains(matrix.target, 'linux') && !startsWith(matrix.target, 'x86_64')" - run: sudo apt install -y gcc-multilib g++-multilib + if: "matrix.apt_packages != ''" + run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }} shell: bash - name: Install nasm if: startsWith(matrix.os, 'windows') From 9d01c7c536961010cd5a1b3d035bdf3c0d075a20 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 3 Jun 2022 13:20:07 -0700 Subject: [PATCH 04/15] Make arm and Android builds check-only --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77b0491cb..022bebccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,18 +96,22 @@ jobs: target: arm-linux-androideabi rust: stable os: ubuntu-latest + check_only: true - thing: arm64-android target: aarch64-linux-android rust: stable os: ubuntu-latest + check_only: true - thing: i686-android target: i686-linux-android rust: stable os: ubuntu-latest + check_only: true - thing: x86_64-android target: x86_64-linux-android rust: stable os: ubuntu-latest + check_only: true - thing: aarch64-ios target: aarch64-apple-ios os: macos-latest @@ -126,14 +130,19 @@ jobs: target: i686-unknown-linux-gnu rust: stable os: ubuntu-latest + apt_packages: gcc-multilib g++-multilib - thing: arm-linux target: arm-unknown-linux-gnueabi rust: stable os: ubuntu-latest + apt_packages: gcc-arm-linux-gnueabi g++-arm-linux-gnueabi + check_only: true - thing: aarch64-linux target: aarch64-unknown-linux-gnu rust: stable os: ubuntu-latest + apt_packages: crossbuild-essential-arm64 + check_only: true - thing: x86_64-musl target: x86_64-unknown-linux-musl rust: stable @@ -163,7 +172,7 @@ jobs: run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} shell: bash - run: rustup target add ${{ matrix.target }} - - name: Install Linux cross-compile dependencies + - name: Install target-specific APT dependencies if: "matrix.apt_packages != ''" run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }} shell: bash From a64dc350d97669f3992db0ea8e7e18b733b3f329 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 13:24:46 -0700 Subject: [PATCH 05/15] Remove musl test; there's no standard musl C++ setup for us to use --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 022bebccd..e11712eb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,6 @@ jobs: - i686-linux - arm-linux - aarch64-linux - - x86_64-musl - x86_64-mingw - i686-msvc - x86_64-msvc @@ -143,10 +142,6 @@ jobs: os: ubuntu-latest apt_packages: crossbuild-essential-arm64 check_only: true - - thing: x86_64-musl - target: x86_64-unknown-linux-musl - rust: stable - os: ubuntu-latest - thing: x86_64-mingw target: x86_64-pc-windows-gnu rust: stable From 704c6e45456cd240839e58518af049f3778fdf7c Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 3 Jun 2022 16:35:41 -0700 Subject: [PATCH 06/15] Build tests even for cross-compiling --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e11712eb3..a26e5640b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,8 +188,9 @@ jobs: run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} name: Run tests - if: matrix.check_only - run: cargo check --target ${{ matrix.target }} --all-targets - name: Check tests + # We `build` because we want the linker to verify we are cross-compiling correctly. + run: cargo build --target ${{ matrix.target }} --tests + name: Build tests - name: Test boring-sys cargo publish # Running `cargo publish --dry-run` tests two things: # From 81ef8b4f831f18b38e220f25a42e43d89cda0784 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 14:09:49 -0700 Subject: [PATCH 07/15] Add custom environment for ARM Linux cross-compilation --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a26e5640b..8edcce0cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,7 @@ jobs: - check_only: false - extra_test_args: '' - apt_packages: '' + - custom_env: {} - thing: stable target: x86_64-unknown-linux-gnu rust: stable @@ -136,12 +137,20 @@ jobs: os: ubuntu-latest apt_packages: gcc-arm-linux-gnueabi g++-arm-linux-gnueabi check_only: true + custom_env: + CC: arm-linux-gnueabi-gcc + CXX: arm-linux-gnueabi-g++ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER: arm-linux-gnueabi-g++ - thing: aarch64-linux target: aarch64-unknown-linux-gnu rust: stable os: ubuntu-latest apt_packages: crossbuild-essential-arm64 check_only: true + custom_env: + CC: aarch64-linux-gnu-gcc + CXX: aarch64-linux-gnu-g++ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++ - thing: x86_64-mingw target: x86_64-pc-windows-gnu rust: stable @@ -187,10 +196,12 @@ jobs: - if: "!matrix.check_only" run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} name: Run tests + env: ${{ matrix.custom_env }} - if: matrix.check_only # We `build` because we want the linker to verify we are cross-compiling correctly. run: cargo build --target ${{ matrix.target }} --tests name: Build tests + env: ${{ matrix.custom_env }} - name: Test boring-sys cargo publish # Running `cargo publish --dry-run` tests two things: # From 2bb1d3d652c7780ec3410d8cd1cf2da2ab7d0b7f Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 14:10:05 -0700 Subject: [PATCH 08/15] Add custom linker for Android cross-compilation --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8edcce0cf..d88beca2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: rust: stable os: macos-latest - thing: arm-android - target: arm-linux-androideabi + target: armv7-linux-androideabi rust: stable os: ubuntu-latest check_only: true @@ -193,6 +193,9 @@ jobs: - name: Set LIBCLANG_PATH if: startsWith(matrix.os, 'windows') run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV + - name: Set Android Linker path + if: endsWith(matrix.thing, '-android') + run: echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++" >> "$GITHUB_ENV" - if: "!matrix.check_only" run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} name: Run tests From a5bbe4bd6d4871d4ad4180d8dfe3829941083698 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 17:37:03 -0700 Subject: [PATCH 09/15] Add arm64-macos cross-compile to CI --- .github/workflows/ci.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d88beca2c..50e6fab65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,7 +65,6 @@ jobs: matrix: thing: - stable - - macos-x86_64 - arm-android - arm64-android - i686-android @@ -76,6 +75,8 @@ jobs: - i686-linux - arm-linux - aarch64-linux + - arm64-macos + - x86_64-macos - x86_64-mingw - i686-msvc - x86_64-msvc @@ -88,10 +89,6 @@ jobs: target: x86_64-unknown-linux-gnu rust: stable os: ubuntu-latest - - thing: macos-x86_64 - target: x86_64-apple-darwin - rust: stable - os: macos-latest - thing: arm-android target: armv7-linux-androideabi rust: stable @@ -151,6 +148,15 @@ jobs: CC: aarch64-linux-gnu-gcc CXX: aarch64-linux-gnu-g++ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++ + - thing: arm64-macos + target: aarch64-apple-darwin + rust: stable + os: macos-latest + check_only: true + - thing: x86_64-macos + target: x86_64-apple-darwin + rust: stable + os: macos-latest - thing: x86_64-mingw target: x86_64-pc-windows-gnu rust: stable From 03c532fe8e6e527a8bb1c738dfb18b224cc73f6a Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 17:43:14 -0700 Subject: [PATCH 10/15] Always run tests in bash This is only necessary for the windows-gnu target, but causes no issues anywhere else. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50e6fab65..1f9e396b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,11 +205,13 @@ jobs: - if: "!matrix.check_only" run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} name: Run tests + shell: bash env: ${{ matrix.custom_env }} - if: matrix.check_only # We `build` because we want the linker to verify we are cross-compiling correctly. run: cargo build --target ${{ matrix.target }} --tests name: Build tests + shell: bash env: ${{ matrix.custom_env }} - name: Test boring-sys cargo publish # Running `cargo publish --dry-run` tests two things: From 34fc414b1a1d364292eb12957b08ee89b35907a6 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 17:49:06 -0700 Subject: [PATCH 11/15] Use gcc/g++ as the compilers for windows-gnu, not Clang --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f9e396b6..d499e91a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,7 +160,16 @@ jobs: - thing: x86_64-mingw target: x86_64-pc-windows-gnu rust: stable - os: ubuntu-latest + os: windows-latest + check_only: true # tests are flaky for unclear reasons + custom_env: + CC: gcc + CXX: g++ + C_INCLUDE_PATH: "C:\\msys64\\usr\\include" + CPLUS_INCLUDE_PATH: "C:\\msys64\\usr\\include" + LIBRARY_PATH: "C:\\msys64\\usr\\lib" + # CI's Windows doesn't have required root certs + extra_test_args: --workspace --exclude tokio-boring --exclude hyper-boring - thing: i686-msvc target: i686-pc-windows-msvc rust: stable-x86_64-msvc From bb5848228f517df45adc1af17e5bf471565fc226 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 17:36:20 -0700 Subject: [PATCH 12/15] boring-sys: Don't check for MSVC with target_env x86_64-pc-windows-gnu is identified as `target_env = "msvc"` too, but doesn't use the Visual Studio CMake generator. --- boring-sys/build/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boring-sys/build/main.rs b/boring-sys/build/main.rs index e9749ff9b..33c2f1d63 100644 --- a/boring-sys/build/main.rs +++ b/boring-sys/build/main.rs @@ -153,7 +153,7 @@ fn get_boringssl_source_path(config: &Config) -> &PathBuf { /// so adjust library location based on platform and build target. /// See issue: https://github.com/alexcrichton/cmake-rs/issues/18 fn get_boringssl_platform_output_path(config: &Config) -> String { - if config.target_env == "msvc" { + if config.target.ends_with("-msvc") { // Code under this branch should match the logic in cmake-rs let debug_env_var = config .env From 27b1e2657e729b7dc5631966bb73c32387f71c38 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Oct 2023 14:23:09 -0700 Subject: [PATCH 13/15] boring-sys: Blocklist max_align_t in bindgen https://github.com/rust-lang/rust-bindgen/issues/1823 --- boring-sys/build/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/boring-sys/build/main.rs b/boring-sys/build/main.rs index 33c2f1d63..b2ed72f65 100644 --- a/boring-sys/build/main.rs +++ b/boring-sys/build/main.rs @@ -676,6 +676,7 @@ fn main() { .size_t_is_usize(true) .layout_tests(true) .prepend_enum_name(true) + .blocklist_type("max_align_t") // Not supported by bindgen on all targets, not used by BoringSSL .clang_args(get_extra_clang_args_for_bindgen(&config)) .clang_arg("-I") .clang_arg(include_path.display().to_string()); From a6e882e47d49e27d6acd2c826580e466f48de223 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Mon, 13 Nov 2023 17:38:42 -0600 Subject: [PATCH 14/15] Remove unused target_env from boring-sys build config --- boring-sys/build/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/boring-sys/build/config.rs b/boring-sys/build/config.rs index 12e89ffa8..79d119fcd 100644 --- a/boring-sys/build/config.rs +++ b/boring-sys/build/config.rs @@ -8,7 +8,6 @@ pub(crate) struct Config { pub(crate) host: String, pub(crate) target: String, pub(crate) target_arch: String, - pub(crate) target_env: String, pub(crate) target_os: String, pub(crate) features: Features, pub(crate) env: Env, @@ -42,7 +41,6 @@ impl Config { let host = env::var("HOST").unwrap(); let target = env::var("TARGET").unwrap(); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); let features = Features::from_env(); @@ -58,7 +56,6 @@ impl Config { host, target, target_arch, - target_env, target_os, features, env, From 789b6a25042008b89a0116926ae041c832610ec5 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Mon, 13 Nov 2023 21:35:45 -0600 Subject: [PATCH 15/15] Swap build and run order; always build --- .github/workflows/ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d499e91a4..98ab144fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,15 +211,14 @@ jobs: - name: Set Android Linker path if: endsWith(matrix.thing, '-android') run: echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++" >> "$GITHUB_ENV" - - if: "!matrix.check_only" - run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} - name: Run tests + - name: Build tests + # We `build` because we want the linker to verify we are cross-compiling correctly for check-only targets. + run: cargo build --target ${{ matrix.target }} --tests ${{ matrix.extra_test_args }} shell: bash env: ${{ matrix.custom_env }} - - if: matrix.check_only - # We `build` because we want the linker to verify we are cross-compiling correctly. - run: cargo build --target ${{ matrix.target }} --tests - name: Build tests + - name: Run tests + if: "!matrix.check_only" + run: cargo test --target ${{ matrix.target }} ${{ matrix.extra_test_args }} shell: bash env: ${{ matrix.custom_env }} - name: Test boring-sys cargo publish