Skip to content

Commit 5bd1792

Browse files
authored
fix: do not config cross compilation in config.toml, document it in docs (#198)
* fix: do not config cross compilation in config.toml, document it in docs Signed-off-by: usamoi <usamoi@outlook.com> * docs: improve install-from-source-code instructions Signed-off-by: usamoi <usamoi@outlook.com> * ci: enable all checks for all PRs Signed-off-by: usamoi <usamoi@outlook.com> --------- Signed-off-by: usamoi <usamoi@outlook.com>
1 parent 9e46faa commit 5bd1792

File tree

5 files changed

+37
-40
lines changed

5 files changed

+37
-40
lines changed

.cargo/config.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,3 @@ rustdocflags = ["--document-private-items"]
44
[target.'cfg(target_os="macos")']
55
# Postgres symbols won't be available until runtime
66
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"]
7-
8-
[target.x86_64-unknown-linux-gnu]
9-
linker = "x86_64-linux-gnu-gcc"
10-
11-
[target.aarch64-unknown-linux-gnu]
12-
linker = "aarch64-linux-gnu-gcc"
13-
14-
[env]
15-
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu = "-isystem /usr/x86_64-linux-gnu/include/ -ccc-gcc-name x86_64-linux-gnu-gcc"
16-
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"

.github/workflows/check.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,15 @@ env:
4242
RUSTFLAGS: "-Dwarnings"
4343

4444
jobs:
45-
matrix:
46-
runs-on: ubuntu-latest
47-
outputs:
48-
matrix: ${{ steps.main.outputs.matrix }}
49-
steps:
50-
- uses: actions/github-script@v7
51-
id: main
52-
with:
53-
script: |
54-
let matrix;
55-
if ("${{ github.event_name }}" == "pull_request") {
56-
matrix = [
57-
{ version: 15, os: "ubuntu-latest" },
58-
];
59-
} else {
60-
matrix = [
61-
{ version: 12, os: "ubuntu-latest" },
62-
{ version: 13, os: "ubuntu-latest" },
63-
{ version: 14, os: "ubuntu-latest" },
64-
{ version: 15, os: "ubuntu-latest" },
65-
{ version: 16, os: "ubuntu-latest" },
66-
];
67-
}
68-
core.setOutput('matrix', JSON.stringify(matrix));
6945
check:
70-
needs: matrix
7146
strategy:
7247
matrix:
73-
include: ${{ fromJson(needs.matrix.outputs.matrix) }}
48+
include:
49+
- { version: 12, os: "ubuntu-latest" }
50+
- { version: 13, os: "ubuntu-latest" }
51+
- { version: 14, os: "ubuntu-latest" }
52+
- { version: 15, os: "ubuntu-latest" }
53+
- { version: 16, os: "ubuntu-latest" }
7454
runs-on: ${{ matrix.os }}
7555
env:
7656
VERSION: ${{ matrix.version }}

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
9292
if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
9393
sudo apt-get -y install crossbuild-essential-arm64
94+
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml
95+
echo 'env.BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"' | tee -a ~/.cargo/config.toml
9496
fi
9597
- name: Build Release
9698
run: |

docs/installation.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You can configure PostgreSQL by the reference of the parent image in https://hub
2121

2222
## Install from source
2323

24-
Install Rust and base dependency.
24+
Install base dependency.
2525

2626
```sh
2727
sudo apt install -y \
@@ -41,10 +41,15 @@ sudo apt install -y \
4141
ccache \
4242
clang \
4343
git
44+
```
45+
46+
Install Rust. The following command will install Rustup, the Rust toolchain installer for your user. Do not install rustc using package manager.
47+
48+
```sh
4449
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
4550
```
4651

47-
Install PostgreSQL.
52+
Install PostgreSQL and its headers. We assume you may install PostgreSQL 15. Feel free to replace `15` to any other major version number you need.
4853

4954
```sh
5055
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
@@ -53,7 +58,7 @@ sudo apt-get update
5358
sudo apt-get -y install libpq-dev postgresql-15 postgresql-server-dev-15
5459
```
5560

56-
Install clang-16.
61+
Install clang-16. We do not support other versions of clang.
5762

5863
```sh
5964
sudo sh -c 'echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-16 main" >> /etc/apt/sources.list'
@@ -62,7 +67,7 @@ sudo apt-get update
6267
sudo apt-get -y install clang-16
6368
```
6469

65-
Clone the Repository.
70+
Clone the Repository. Note the following commands are executed in the cloned repository directory.
6671

6772
```sh
6873
git clone https://github.com/tensorchord/pgvecto.rs.git
@@ -101,6 +106,24 @@ DROP EXTENSION IF EXISTS vectors;
101106
CREATE EXTENSION vectors;
102107
```
103108

109+
### Cross compilation
110+
111+
Assuming that you build target for aarch64 in a x86_64 host environment, you need to set right linker and sysroot for Rust.
112+
113+
```sh
114+
sudo apt install crossbuild-essential-arm64
115+
```
116+
117+
Add the following section to the end of `~/.cargo/config.toml`.
118+
119+
```toml
120+
[target.aarch64-unknown-linux-gnu]
121+
linker = "aarch64-linux-gnu-gcc"
122+
123+
[env]
124+
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"
125+
```
126+
104127
## Install from release
105128

106129
Download the deb package in the release page, and type `sudo apt install vectors-pg15-*.deb` to install the deb package.

scripts/ci_setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if [ "$OS" == "ubuntu-latest" ]; then
1414
sudo apt-get -y install build-essential libpq-dev postgresql-$VERSION postgresql-server-dev-$VERSION
1515
sudo apt-get -y install clang-16
1616
sudo apt-get -y install crossbuild-essential-arm64
17+
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml
18+
echo 'env.BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"' | tee -a ~/.cargo/config.toml
1719
echo "local all all trust" | sudo tee /etc/postgresql/$VERSION/main/pg_hba.conf
1820
echo "host all all 127.0.0.1/32 trust" | sudo tee -a /etc/postgresql/$VERSION/main/pg_hba.conf
1921
echo "host all all ::1/128 trust" | sudo tee -a /etc/postgresql/$VERSION/main/pg_hba.conf

0 commit comments

Comments
 (0)