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

Respect target-cpu in RUSTFLAGS #243

Merged
merged 7 commits into from
Apr 24, 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
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: x86-instruction-set-analyzer@0.1.0
- 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
Loading