Skip to content

Commit 39676ac

Browse files
authored
Automatically set AVX2/FMA flags on x86 (#188)
We can put the AVX2 and FMA flags in the `.cargo/config.toml` file so that they are automatically applied on x86, instead of users having to manually set an environment variable.
1 parent 8bd2acf commit 39676ac

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[target.'cfg(target_os="macos")']
22
# Postgres symbols won't be available until runtime
33
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"]
4+
5+
[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))']
6+
rustflags = ["-Ctarget-feature=+avx2,+fma"]

.github/workflows/deb-packager.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ jobs:
3232
platform:
3333
- type: amd64
3434
runs_on: ubuntu-latest
35-
rustflags: '-C target-feature=+avx2,+fma'
3635
- type: arm64
3736
runs_on: cloud-image-runner-arm64
38-
rustflags: ''
3937

4038
env:
4139
PG_SRC_DIR: pgbuild
@@ -81,7 +79,7 @@ jobs:
8179
id: debbuild
8280
run: |
8381
export PATH=~/${{ env.PG_INSTALL_DIR }}/bin:$PATH
84-
(cd ${{ env.TAG_DIR }} && ${{ matrix.platform.rustflags != '' && format('RUSTFLAGS="{0}"', matrix.platform.rustflags) || '' }} make package)
82+
(cd ${{ env.TAG_DIR }} && make package)
8583
bash scripts/package-deb.sh "${{ env.TAG }}" "${PWD}/${{ env.TAG_DIR }}" "$RUNNER_OS" "${{ matrix.pg.major }}"
8684
8785
# Use a GH artifact, then we can make use of the (quite limited) GH API https://docs.github.com/en/rest/actions/artifacts

.github/workflows/pgrx_test.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ jobs:
2626
platform:
2727
- type: amd64
2828
runs_on: ubuntu-22.04
29-
rustflags: '-C target-feature=+avx2,+fma'
3029
- type: arm64
3130
runs_on: cloud-image-runner-arm64
32-
rustflags: ''
3331

3432
env:
3533
PG_SRC_DIR: pgbuild
@@ -70,12 +68,10 @@ jobs:
7068
id: clippy
7169
run: |
7270
cd pgvectorscale
73-
${{ matrix.platform.rustflags != '' && format('export RUSTFLAGS="{0}"', matrix.platform.rustflags) || '' }}
7471
cargo clippy --all-targets --no-default-features --features 'pg_test pg${{ matrix.pg.major }}'
7572
7673
- name: Run tests
7774
id: runtests
7875
run: |
7976
cd pgvectorscale
80-
${{ matrix.platform.rustflags != '' && format('export RUSTFLAGS="{0}"', matrix.platform.rustflags) || '' }}
8177
cargo pgrx test -- pg${{ matrix.pg.major }}

0 commit comments

Comments
 (0)