Skip to content

Build fixes and improvements #34

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

Merged
merged 7 commits into from
Oct 9, 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
31 changes: 21 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
# On Linux, if we don't link to gcc_eh, we get can get this error when loading the loadable extension:
# undefined symbol: _Unwind_Resume
# This adds around 29KB to the loadable extension.
# It may also be an option to just define _Unwind_Resume, but it causes crashes on errors on e.g. iOS, so rather avoid it.

[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]
# Previously we added this to rustflags for all linux builds:
# "-C", "link-arg=-lgcc_eh"
# It was to fix this error when loading the loadable extension:
# undefined symbol: _Unwind_Resume
# Now, we instead build using:
# -Z build-std=panic_abort,core,alloc
# This fixes the same issue. We still keep -lgcc_eh,
# to support manual builds without -Z build-std.

# Without -Z build-std, with -lgcc_eh:
# 241KB, loading works
# Without -Z build-std, without -lgcc_eh:
# 207KB, undefined symbol: _Unwind_Resume
# With -Z build-std, without -lgcc_eh:
# 173K, loading works
# With -Z build-std, with -lgcc_eh:
# 173K, loading works
# Conclusion: -lgcc_eh has no effect when using -Z build-std.

[target.i686-linux-unknown-linux-gnu]
[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]

[target.aarch64-linux-unknown-linux-gnu]
[target.i686-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
rustflags = [
"-C", "link-arg=-lgcc_eh",
]
Expand Down
13 changes: 6 additions & 7 deletions .github/actions/upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ runs:
using: "composite"
steps:
- name: Upload binary
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ inputs.repo-token }}
overwrite: true
file: ${{ inputs.file-name }}
asset_name: ${{ inputs.file-name }}
tag: ${{ inputs.tag }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh release upload "${{ inputs.tag }}" "${{ inputs.file-name }}"
21 changes: 2 additions & 19 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
on:
push:
workflow_dispatch:
name: "linux"
jobs:
build_x86_64:
Expand All @@ -18,15 +17,7 @@ jobs:
components: rust-src

- name: Build binaries
run: bash tool/build_linux.sh x64

- name: Upload binary
if: github.event_name == 'workflow_dispatch'
uses: ./.github/actions/upload
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: libpowersync_x64.so
tag: ${{ github.ref_name }}
run: ./tool/build_linux.sh x64

build_aarch64:
name: Building Linux aarch64
Expand All @@ -43,12 +34,4 @@ jobs:
components: rust-src

- name: Build binaries
run: bash tool/build_linux.sh aarch64

- name: Upload binary
if: github.event_name == 'workflow_dispatch'
uses: ./.github/actions/upload
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: libpowersync_aarch64.so
tag: ${{ github.ref_name }}
run: ./tool/build_linux.sh aarch64
33 changes: 14 additions & 19 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
on:
push:
workflow_dispatch:
name: "macos"
jobs:
build_macOS_aarch64:
Expand All @@ -11,16 +10,14 @@ jobs:
with:
submodules: true

- name: Build binary
run: bash tool/build_macos.sh aarch64

- name: Upload binary
if: github.event_name == 'workflow_dispatch'
uses: ./.github/actions/upload
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: libpowersync_aarch64.dylib
tag: ${{ github.ref_name }}
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: ./tool/build_macos.sh aarch64

build_macOS_x64:
name: Building macOS x64
Expand All @@ -30,13 +27,11 @@ jobs:
with:
submodules: true

- name: Build binary
run: bash tool/build_macos.sh x64

- name: Upload binary
if: github.event_name == 'workflow_dispatch'
uses: ./.github/actions/upload
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: libpowersync_x64.dylib
tag: ${{ github.ref_name }}
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: ./tool/build_macos.sh x64
36 changes: 30 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: release
on:
workflow_dispatch:
push:
inputs:
publish:
type: boolean
required: false
default: false
description: Set to true to publish artifacts to external targets such as Maven Central
jobs:
draft_release:
if: github.event_name == 'workflow_dispatch'
Expand Down Expand Up @@ -57,6 +62,7 @@ jobs:
cargo install cargo-ndk

- name: Publish for Android
if: ${{ inputs.publish }}
run: |
cd android
./gradlew publish
Expand Down Expand Up @@ -123,7 +129,7 @@ jobs:
components: rust-src

- name: Build binaries
run: bash tool/build_linux.sh x64
run: ./tool/build_linux.sh x64

- name: Upload binary
uses: ./.github/actions/upload
Expand All @@ -135,7 +141,7 @@ jobs:
publish_linux_aarch64:
name: Publish Linux aarch64
needs: [draft_release]
runs-on: ubuntu-latest
runs-on: ubuntu-arm64
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -148,7 +154,7 @@ jobs:
components: rust-src

- name: Build binaries
run: bash tool/build_linux.sh aarch64
run: ./tool/build_linux.sh aarch64

- name: Upload binary
uses: ./.github/actions/upload
Expand All @@ -166,6 +172,12 @@ jobs:
with:
submodules: true

- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: bash tool/build_windows.sh x64

Expand All @@ -185,8 +197,14 @@ jobs:
with:
submodules: true

- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: bash tool/build_macos.sh aarch64
run: ./tool/build_macos.sh aarch64

- name: Upload binary
uses: ./.github/actions/upload
Expand All @@ -204,8 +222,14 @@ jobs:
with:
submodules: true

- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: bash tool/build_macos.sh x64
run: ./tool/build_macos.sh x64

- name: Upload binary
uses: ./.github/actions/upload
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
run: |
sudo apt install libreadline-dev

- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-05-18
components: rust-src

- name: Build
run: |
# Need a debug build for the dart tests
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ jobs:
with:
submodules: true

- name: Build binary
run: bash tool/build_windows.sh x64

- name: Upload binary
if: github.event_name == 'workflow_dispatch'
uses: ./.github/actions/upload
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: powersync_x64.dll
tag: ${{ github.ref_name }}
toolchain: nightly-2024-05-18
components: rust-src

- name: Build binary
run: ./tool/build_windows.sh x64
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ git push --tags
Build:

```
gh workflow run release --ref v1.2.3
gh workflow run release --ref v1.2.3 -f publish=true
```

The above does the following:
Expand Down
13 changes: 7 additions & 6 deletions tool/build_linux.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
set -e

if [ "$1" = "x64" ]; then
rustup target add target x86_64-unknown-linux-gnu
cargo build -p powersync_loadable --release
mv "target/release/libpowersync.so" "libpowersync_x64.so"
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu
mv "target/x86_64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x64.so"
else
rustup target add aarch64-unknown-linux-gnu
cargo build -p powersync_loadable --release
mv "target/release/libpowersync.so" "libpowersync_aarch64.so"
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target aarch64-unknown-linux-gnu
mv "target/aarch64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_aarch64.so"
fi
14 changes: 7 additions & 7 deletions tool/build_macos.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
set -e

if [ "$1" = "x64" ]; then
#Note: x86_64-apple-darwin has not been tested.
rustup target add target x86_64-apple-darwin
cargo build -p powersync_loadable --release
mv "target/release/libpowersync.dylib" "libpowersync_x64.dylib"
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-apple-darwin
mv "target/x86_64-apple-darwin/release/libpowersync.dylib" "libpowersync_x64.dylib"
else
rustup target add aarch64-apple-darwin
cargo build -p powersync_loadable --release
mv "target/release/libpowersync.dylib" "libpowersync_aarch64.dylib"
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-apple-darwin
mv "target/aarch64-apple-darwin/release/libpowersync.dylib" "libpowersync_aarch64.dylib"
fi
13 changes: 7 additions & 6 deletions tool/build_windows.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/sh
set -e

if [ "$1" = "x64" ]; then
rustup target add x86_64-pc-windows-msvc
cargo build -p powersync_loadable --release
mv "target/release/powersync.dll" "powersync_x64.dll"
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-pc-windows-msvc
mv "target/x86_64-pc-windows-msvc/release/powersync.dll" "powersync_x64.dll"
else
#Note: aarch64-pc-windows-msvc has not been tested.
rustup target add aarch64-pc-windows-msvc
cargo build -p powersync_loadable --release
mv "target/release/powersync.dll" "powersync_aarch64.dll"
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-pc-windows-msvc
mv "target/aarch64-pc-windows-msvc/release/powersync.dll" "powersync_aarch64.dll"
fi
Loading