Skip to content

Commit a51172d

Browse files
authored
remove build script, bump MSRV to use standard cfg attributes for SIMD (#213)
1 parent 3d7feb2 commit a51172d

File tree

7 files changed

+83
-235
lines changed

7 files changed

+83
-235
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
- simd
1818
- check_x86
1919
- aarch64
20-
- msrv_x64
21-
- msrv_aarch64
20+
- msrv
2221
- miri
2322
- clippy_check
2423
steps:
@@ -44,7 +43,7 @@ jobs:
4443

4544
runs-on: ${{ matrix.os }}
4645
env:
47-
CARGO_CFG_HTTPARSE_DISABLE_SIMD: 1
46+
RUSTFLAGS: --cfg httparse_disable_simd
4847

4948
steps:
5049
- name: Checkout
@@ -76,14 +75,10 @@ jobs:
7675
- nightly
7776

7877
target_feature:
78+
- "" # runtime detection
7979
- "+sse4.2"
8080
- "+avx2"
8181
- "+sse4.2,+avx2"
82-
83-
disable_compiletime:
84-
- 0
85-
- 1
86-
8782
steps:
8883
- name: Checkout
8984
uses: actions/checkout@v5
@@ -96,7 +91,6 @@ jobs:
9691
- name: Test
9792
env:
9893
RUSTFLAGS: -C target_feature=${{ matrix.target_feature }}
99-
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: ${{ matrix.disable_compiletime }}
10094
run: cargo test
10195

10296
check_x86:
@@ -113,48 +107,26 @@ jobs:
113107

114108
- name: Test without SIMD
115109
env:
116-
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: 1
110+
RUSTFLAGS: --cfg httparse_disable_simd
117111
run: cargo test --target i686-unknown-linux-musl
118112

119113
- name: Test
120114
run: cargo test --target i686-unknown-linux-musl
121115

122-
msrv_x64:
123-
name: msrv (x64)
116+
msrv:
117+
name: msrv
124118
runs-on: ubuntu-latest
125119
steps:
126120
- name: Checkout
127121
uses: actions/checkout@v5
128122

129123
- name: Install Rust
130-
uses: dtolnay/rust-toolchain@1.47.0
124+
uses: dtolnay/rust-toolchain@1.59.0
131125

132-
# Only build, dev-dependencies don't compile on 1.47.0
126+
# Only build, dev-dependencies don't compile on 1.59.0
133127
- name: Build
134128
run: cargo build
135129

136-
# This tests that aarch64 gracefully fallbacks to SWAR if neon_intrinsics aren't available (<1.59)
137-
msrv_aarch64:
138-
name: msrv (aarch64)
139-
runs-on: ubuntu-latest
140-
steps:
141-
- name: Checkout
142-
uses: actions/checkout@v5
143-
144-
- name: Install cross-compiling dependencies
145-
run: |
146-
sudo apt-get update
147-
sudo apt-get install -y gcc-aarch64-linux-gnu
148-
149-
- name: Setup Rust
150-
uses: dtolnay/rust-toolchain@1.47.0
151-
with:
152-
target: aarch64-unknown-linux-gnu
153-
154-
# Only build, dev-dependencies don't compile on 1.47.0
155-
- name: Build
156-
run: cargo build --target aarch64-unknown-linux-gnu
157-
158130
clippy_check:
159131
runs-on: ubuntu-latest
160132
steps:

.github/workflows/cibench.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ on:
55

66
env:
77
CARGO_TERM_COLOR: always
8-
RUSTFLAGS: "-C target-cpu=native"
98

109
jobs:
1110
benchmark:
1211
name: Run benchmarks
1312
runs-on: ubuntu-latest
13+
env:
14+
RUSTFLAGS: "-C target-cpu=native"
1415
steps:
1516
- uses: actions/checkout@v5
1617
with:
@@ -41,7 +42,17 @@ jobs:
4142
runs-on: ubuntu-latest
4243
strategy:
4344
matrix:
44-
feature: [swar, sse42, avx2]
45+
include:
46+
- feature: runtime
47+
rustflags: ""
48+
- feature: swar
49+
rustflags: "--cfg httparse_disable_simd"
50+
- feature: sse4.2
51+
rustflags: "-C target-feature=+sse4.2"
52+
- feature: avx2
53+
rustflags: "-C target-feature=+avx2"
54+
env:
55+
RUSTFLAGS: ${{ matrix.rustflags }}
4556
steps:
4657
- uses: actions/checkout@v5
4758
with:
@@ -57,17 +68,11 @@ jobs:
5768
run: |
5869
git checkout master
5970
cargo bench --bench parse -- --save-baseline master-${{ matrix.feature }}
60-
env:
61-
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
62-
RUSTFLAGS: ${{ matrix.feature != 'swar' && format('-C target-feature=+{0}', matrix.feature) || '' }}
6371
6472
- name: Run benchmarks (PR)
6573
run: |
6674
git checkout ${{ github.event.pull_request.head.sha }}
6775
cargo bench --bench parse -- --save-baseline pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-${{ matrix.feature }}
68-
env:
69-
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
70-
RUSTFLAGS: ${{ matrix.feature != 'swar' && format('-C target-feature=+{0}', matrix.feature) || '' }}
7176
7277
- name: Compare benchmarks
7378
run: |
@@ -78,7 +83,13 @@ jobs:
7883
runs-on: macos-latest
7984
strategy:
8085
matrix:
81-
feature: [swar, neon]
86+
include:
87+
- feature: swar
88+
rustflags: "--cfg httparse_disable_simd"
89+
- feature: neon
90+
rustflags: "-C target-feature=+neon"
91+
env:
92+
RUSTFLAGS: ${{ matrix.rustflags }}
8293
steps:
8394
- uses: actions/checkout@v5
8495
with:
@@ -94,17 +105,11 @@ jobs:
94105
run: |
95106
git checkout master
96107
cargo bench --bench parse -- --save-baseline master-aarch64-${{ matrix.feature }}
97-
env:
98-
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
99-
RUSTFLAGS: ${{ matrix.feature == 'neon' && '-C target-feature=+neon' || '' }}
100108
101109
- name: Run benchmarks (PR)
102110
run: |
103111
git checkout ${{ github.event.pull_request.head.sha }}
104112
cargo bench --bench parse -- --save-baseline pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-aarch64-${{ matrix.feature }}
105-
env:
106-
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
107-
RUSTFLAGS: ${{ matrix.feature == 'neon' && '-C target-feature=+neon' || '' }}
108113
109114
- name: Compare benchmarks
110115
run: |

Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ documentation = "https://docs.rs/httparse"
99
readme = "README.md"
1010
keywords = ["http", "parser", "no_std"]
1111
categories = ["network-programming", "no-std", "parser-implementations", "web-programming"]
12-
edition = "2018"
13-
build = "build.rs"
12+
edition = "2021"
13+
rust-version = "1.59"
1414

1515
[features]
1616
default = ["std"]
@@ -34,8 +34,5 @@ opt-level = 3
3434

3535
[lints.rust]
3636
unexpected_cfgs = { level = "warn", check-cfg = [
37-
'cfg(httparse_simd)',
38-
'cfg(httparse_simd_target_feature_avx2)',
39-
'cfg(httparse_simd_target_feature_sse42)',
40-
'cfg(httparse_simd_neon_intrinsics)',
37+
'cfg(httparse_disable_simd)',
4138
] }

build.rs

Lines changed: 0 additions & 133 deletions
This file was deleted.

clippy.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ macro_rules! next {
1010
}
1111

1212
macro_rules! expect {
13-
($bytes:ident.next() == $pat:pat => $ret:expr) => {
13+
($bytes:ident.next() == $pat:pat_param => $ret:expr) => {
1414
expect!(next!($bytes) => $pat |? $ret)
1515
};
16-
($e:expr => $pat:pat |? $ret:expr) => {
16+
($e:expr => $pat:pat_param |? $ret:expr) => {
1717
match $e {
1818
v@$pat => v,
1919
_ => return $ret
@@ -31,7 +31,7 @@ macro_rules! complete {
3131
}
3232

3333
macro_rules! byte_map {
34-
($($p:pat)|+) => {{
34+
($($p:pat_param)|+) => {{
3535
const fn make_map() -> [bool; 256] {
3636
let mut ret = [false; 256];
3737
let mut i = 0;

0 commit comments

Comments
 (0)