Skip to content

Commit

Permalink
Respect target-cpu in RUSTFLAGS (#243)
Browse files Browse the repository at this point in the history
* Respect target-cpu in RUSTFLAGS

Signed-off-by: Wish <[email protected]>

* Raise rustc requirement from 1.70 to 1.74

Signed-off-by: Wish <[email protected]>

* Fix bindgen errors

Signed-off-by: Wish <[email protected]>

* Fix CI in set -e

Signed-off-by: Wish <[email protected]>

* Use pre-built x86-instruction-set-analyzer

Signed-off-by: Wish <[email protected]>

---------

Signed-off-by: Wish <[email protected]>
Co-authored-by: messense <[email protected]>
  • Loading branch information
breezewish and messense authored Apr 24, 2024
1 parent 6f7e133 commit 841df51
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 46 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
toolchain: [1.70.0, stable, nightly]
toolchain: [1.74.0, stable, nightly]
zig: [0.10.1, 0.12.0, master]
exclude:
# Only test MSRV with zig stable version
- toolchain: 1.70.0
- toolchain: 1.74.0
zig: master
env:
RUST_BACKTRACE: "1"
Expand Down Expand Up @@ -81,6 +81,41 @@ jobs:
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target aarch64-unknown-linux-gnu
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target x86_64-pc-windows-gnu
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target aarch64-apple-darwin
- name: Install x86-instruction-set-analyzer
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Test RUSTFLAGS
shell: bash
run: |
set -e
cargo build # Build without RUSTFLAGS
echo "Running -C target_cpu=x86-64..."
echo
export RUSTFLAGS="-C target_cpu=x86-64"
target/debug/cargo-zigbuild zigbuild --manifest-path tests/target-cpu/Cargo.toml --target x86_64-unknown-linux-gnu --release
x86-instruction-set-analyzer tests/target-cpu/target/x86_64-unknown-linux-gnu/release/target-cpu | tee output.txt
echo
if grep -q 'AVX2' output.txt; then
echo "Test fail, should not contain AVX2 instruction set"
false
else
echo "Test pass"
fi
echo "Running -C target_cpu=x86-64-v4..."
echo
export RUSTFLAGS="-C target_cpu=x86-64-v4"
target/debug/cargo-zigbuild zigbuild --manifest-path tests/target-cpu/Cargo.toml --target x86_64-unknown-linux-gnu --release
x86-instruction-set-analyzer tests/target-cpu/target/x86_64-unknown-linux-gnu/release/target-cpu | tee output.txt
echo
if ! grep -q 'AVX2' output.txt; then
echo "Test fail, should contain AVX2 instruction set"
false
else
echo "Test pass"
fi
- name: macOS - Test build
run: |
cargo run zigbuild --target aarch64-apple-darwin
Expand Down
104 changes: 104 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@ license = "MIT"
keywords = ["zig", "cargo"]
readme = "README.md"
repository = "https://github.com/rust-cross/cargo-zigbuild"
rust-version = "1.70"
rust-version = "1.74"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.53"
cargo-config2 = "0.1.24"
cargo-options = "0.7.4"
cargo_metadata = "0.18.0"
clap = { version = "4.3.0", features = ["derive", "env", "wrap_help", "unstable-styles"] }
crc = "3.2.1"
dirs = "5.0.0"
fat-macho = { version = "0.4.6", default-features = false, optional = true }
fs-err = "2.6.0"
path-slash = "0.2.0"
rustc_version = "0.4.0"
rustflags = "0.1.6"
semver = "1.0.5"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
Expand Down
Loading

0 comments on commit 841df51

Please sign in to comment.