-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use compile_error macro to replace build script (#71)
* Use compile_error macro to replace build script * Update rustc in bench runners * Add CI to test cross compilation * Add more targets * Prepare for merge * Also build from macos arm * Use nightly rust for hybrid * Fix more cross compilation cases * Install toolchain if needed * Add last target back, even if not working * Check if changes fixes doctest * Try use rustdocflags * Reuse std::hash::RandomState to get rid of rand dependency * Try set rustflags in x compile CI * Try use all flags in x compile CI * Fine tune cross compilation ci
- Loading branch information
Showing
10 changed files
with
100 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[build] | ||
rustflags = ["-C", "target-cpu=native"] | ||
rustflags = ["-C", "target-cpu=native"] | ||
rustdocflags = ["-C", "target-cpu=native"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Cross Compile | ||
|
||
on: | ||
# Trigger when merged on main | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
# Manual trigger | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
RUSTFLAGS: "-C target-feature=+aes,+vaes,+avx2" | ||
|
||
jobs: | ||
|
||
build_x86: | ||
name: Build | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- from: ubuntu-latest | ||
target: "aarch64-apple-darwin" | ||
allow_failure_hybrid: true | ||
- from: ubuntu-latest | ||
target: "aarch64-unknown-linux-gnu" | ||
allow_failure_hybrid: true | ||
- from: ubuntu-latest | ||
target: "aarch64-unknown-linux-musl" | ||
allow_failure_hybrid: true | ||
- from: ubuntu-latest | ||
target: "i686-unknown-linux-gnu" | ||
allow_failure_hybrid: true | ||
- from: ubuntu-latest | ||
target: "x86_64-pc-windows-msvc" | ||
allow_failure_hybrid: true # Supposed to work as hybrid but not tested yet | ||
- from: ubuntu-latest | ||
target: "x86_64-unknown-linux-gnu" | ||
allow_failure_hybrid: false | ||
- from: macos-latest | ||
target: "aarch64-apple-darwin" | ||
allow_failure_hybrid: true | ||
- from: macos-latest | ||
target: "x86_64-unknown-linux-gnu" | ||
allow_failure_hybrid: true # Supposed to work as hybrid but not tested yet | ||
|
||
runs-on: ${{ matrix.from }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install target | ||
run: rustup target add ${{ matrix.target }} | ||
|
||
- name: Build | ||
run: cargo build --release --target ${{ matrix.target }} | ||
|
||
- name: Switch to nightly rust | ||
run: rustup default nightly | ||
|
||
- name: Build Hybrid | ||
continue-on-error: ${{ matrix.allow_failure_hybrid }} | ||
run: cargo build --release --features hybrid --target ${{ matrix.target }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
extern crate rustc_version; | ||
use rustc_version::{version_meta, Channel}; | ||
|
||
fn main() { | ||
// When conditions permits, enable hybrid feature to leverage wider intrinsics for even more throughput | ||
if version_meta().unwrap().channel == Channel::Nightly | ||
&& cfg!(target_arch = "x86_64") | ||
&& cfg!(target_feature = "avx2") | ||
&& cfg!(target_feature = "vaes") { | ||
println!("cargo:rustc-cfg=hybrid"); | ||
} | ||
|
||
// If not cross compiling, make sure the aes feature is available | ||
if std::env::var("HOST").unwrap_or_default() == std::env::var("TARGET").unwrap_or_default() | ||
&& cfg!(not(target_feature = "aes")) { | ||
panic!("| GxHash requires target-feature 'aes' to be enabled.\n\ | ||
| Build with RUSTFLAGS=\"-C target-cpu=native\" or RUSTFLAGS=\"-C target-feature=+aes\" to enable."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters