Skip to content

Commit

Permalink
fix: do not config cross compilation in config.toml, document it in d…
Browse files Browse the repository at this point in the history
…ocs (#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>
  • Loading branch information
usamoi authored Dec 18, 2023
1 parent 9e46faa commit 5bd1792
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
10 changes: 0 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,3 @@ rustdocflags = ["--document-private-items"]
[target.'cfg(target_os="macos")']
# Postgres symbols won't be available until runtime
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"]

[target.x86_64-unknown-linux-gnu]
linker = "x86_64-linux-gnu-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[env]
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu = "-isystem /usr/x86_64-linux-gnu/include/ -ccc-gcc-name x86_64-linux-gnu-gcc"
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"
32 changes: 6 additions & 26 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,15 @@ env:
RUSTFLAGS: "-Dwarnings"

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.main.outputs.matrix }}
steps:
- uses: actions/github-script@v7
id: main
with:
script: |
let matrix;
if ("${{ github.event_name }}" == "pull_request") {
matrix = [
{ version: 15, os: "ubuntu-latest" },
];
} else {
matrix = [
{ version: 12, os: "ubuntu-latest" },
{ version: 13, os: "ubuntu-latest" },
{ version: 14, os: "ubuntu-latest" },
{ version: 15, os: "ubuntu-latest" },
{ version: 16, os: "ubuntu-latest" },
];
}
core.setOutput('matrix', JSON.stringify(matrix));
check:
needs: matrix
strategy:
matrix:
include: ${{ fromJson(needs.matrix.outputs.matrix) }}
include:
- { version: 12, os: "ubuntu-latest" }
- { version: 13, os: "ubuntu-latest" }
- { version: 14, os: "ubuntu-latest" }
- { version: 15, os: "ubuntu-latest" }
- { version: 16, os: "ubuntu-latest" }
runs-on: ${{ matrix.os }}
env:
VERSION: ${{ matrix.version }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ jobs:
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
sudo apt-get -y install crossbuild-essential-arm64
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml
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
fi
- name: Build Release
run: |
Expand Down
31 changes: 27 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can configure PostgreSQL by the reference of the parent image in https://hub

## Install from source

Install Rust and base dependency.
Install base dependency.

```sh
sudo apt install -y \
Expand All @@ -41,10 +41,15 @@ sudo apt install -y \
ccache \
clang \
git
```

Install Rust. The following command will install Rustup, the Rust toolchain installer for your user. Do not install rustc using package manager.

```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Install PostgreSQL.
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.

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

Install clang-16.
Install clang-16. We do not support other versions of clang.

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

Clone the Repository.
Clone the Repository. Note the following commands are executed in the cloned repository directory.

```sh
git clone https://github.com/tensorchord/pgvecto.rs.git
Expand Down Expand Up @@ -101,6 +106,24 @@ DROP EXTENSION IF EXISTS vectors;
CREATE EXTENSION vectors;
```

### Cross compilation

Assuming that you build target for aarch64 in a x86_64 host environment, you need to set right linker and sysroot for Rust.

```sh
sudo apt install crossbuild-essential-arm64
```

Add the following section to the end of `~/.cargo/config.toml`.

```toml
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[env]
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu = "-isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc"
```

## Install from release

Download the deb package in the release page, and type `sudo apt install vectors-pg15-*.deb` to install the deb package.
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ if [ "$OS" == "ubuntu-latest" ]; then
sudo apt-get -y install build-essential libpq-dev postgresql-$VERSION postgresql-server-dev-$VERSION
sudo apt-get -y install clang-16
sudo apt-get -y install crossbuild-essential-arm64
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml
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
echo "local all all trust" | sudo tee /etc/postgresql/$VERSION/main/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" | sudo tee -a /etc/postgresql/$VERSION/main/pg_hba.conf
echo "host all all ::1/128 trust" | sudo tee -a /etc/postgresql/$VERSION/main/pg_hba.conf
Expand Down

0 comments on commit 5bd1792

Please sign in to comment.