From 9af729f6f4752b5f6f99cec4b627673d4144f1fa Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Tue, 21 May 2024 11:17:52 +0800 Subject: [PATCH] add vendored build to windows ci --- .github/workflows/cross.yml | 6 +-- .github/workflows/static.yml | 81 +++++++++++++++++++++++++++++++++++ .github/workflows/windows.yml | 41 ++++++++++++++++++ doc/static-linking.md | 15 ++++++- 4 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/static.yml diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 70f0f6859..4af74e986 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -1,4 +1,4 @@ -name: Cross-CI +name: CrossCompiling on: push: @@ -34,10 +34,6 @@ jobs: strategy: matrix: target: [ - { - rustc: x86_64-unknown-linux-musl, - gcc: musl-tools, - }, { rustc: x86_64-pc-windows-gnu, gcc: gcc-mingw-w64-x86-64, diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 000000000..ea04f860e --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,81 @@ +name: StaticLinking + +on: + push: + paths-ignore: + - 'ansible/**' + - 'doc/**' + - 'demo/**' + - 'scripts/**' + - 'g3proxy/doc/**' + - 'g3tiles/doc/**' + branches: + - 'master' + - 'rel/**' + - 'lts/**' + pull_request: + branches: + - 'master' + - 'rel/**' + - 'lts/**' + +env: + CARGO_TERM_COLOR: always + CROSS_COMMON_FEATURES: quic,vendored-c-ares,hickory + CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static + +jobs: + musl: + name: musl + runs-on: ubuntu-latest + strategy: + matrix: + feature: + - vendored-openssl + - vendored-tongsuo + - vendored-aws-lc + - vendored-boringssl + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-unknown-linux-musl + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install capnproto musl-tools + - name: Cargo build + run: cargo build --target=x86_64-unknown-linux-musl --no-default-features --features ${{ matrix.feature }},$CROSS_COMMON_FEATURES + msvc: + name: msvc + runs-on: windows-latest + strategy: + matrix: + feature: + - vendored-openssl + - vendored-tongsuo + - vendored-aws-lc + - vendored-boringssl + steps: + - name: Install common tools + run: choco install capnproto + - name: Install nasm and ninja for BoringSSL + if: matrix.feature == 'vendored-boringssl' + run: choco install nasm ninja + - name: Install nasm for AWS-LC + if: matrix.feature == 'vendored-aws-lc' + uses: ilammy/setup-nasm@v1 + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - name: Cargo build + run: cargo build --no-default-features --features ${{ matrix.feature }},$env:CROSS_COMMON_FEATURES diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 02207b243..eaa23150e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -35,6 +35,8 @@ jobs: submodules: true - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable + with: + components: clippy - name: Install tools (choco) run: choco install capnproto - name: Install lib dependencies (vcpkg) @@ -45,3 +47,42 @@ jobs: run: cargo clippy --no-default-features --features $env:WIN_FEATURES --tests -- --deny warnings - name: Cargo test run: cargo test --no-default-features --features $env:WIN_FEATURES + + build-vendored: + name: Build vendored + runs-on: windows-latest + strategy: + matrix: + feature: + - vendored-openssl + - vendored-tongsuo + - vendored-aws-lc + - vendored-boringssl + component: + - g3proxy + - g3bench + - g3tiles + - g3fcgen + - g3mkcert + - g3keymess + steps: + - name: Install common tools + run: choco install capnproto + - name: Install nasm and ninja for BoringSSL + if: matrix.feature == 'vendored-boringssl' + run: choco install nasm ninja + - name: Install nasm for AWS-LC + if: matrix.feature == 'vendored-aws-lc' + uses: ilammy/setup-nasm@v1 + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - name: Cargo build + run: cargo build --no-default-features --features ${{ matrix.feature }} -p ${{ matrix.component }} + - name: Cargo clippy + run: cargo clippy --no-default-features --features ${{ matrix.feature }} -p ${{ matrix.component }} -- --deny warnings diff --git a/doc/static-linking.md b/doc/static-linking.md index d77dc16ab..8a281919b 100644 --- a/doc/static-linking.md +++ b/doc/static-linking.md @@ -1,4 +1,7 @@ -# Static Linking +Static Linking +--- + +# Linux ## Install musl @@ -25,3 +28,13 @@ Then compile with the features that do not require dynamic linking: ```shell cargo build --target=x86_64-unknown-linux-musl --no-default-features --features vendored-openssl,vendored-c-ares ``` + +# Windows + +Windows provides both dynamic and static C runtimes. + +See [C runtime (CRT) and C++ standard library (STL) .lib files](https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features). + +You can change to use a static runtime by setting `-C target-feature=+crt-static` rustc flag. + +See [Static and dynamic C runtimes](https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes).