Skip to content
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

chore: build linux x86_64 ffi against glibc 2.23 #413

Merged
merged 2 commits into from
Apr 29, 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
2 changes: 1 addition & 1 deletion .github/workflows/build-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
rust: [ stable ]
env:
pact_do_not_track: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
rust: [ stable ]
env:
pact_do_not_track: true
Expand Down
6 changes: 6 additions & 0 deletions rust/Cross.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[target.x86_64-unknown-linux-gnu]
pre-build=[
"apt-get update && apt-get install --assume-yes wget unzip",
"wget https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protoc-21.5-linux-x86_64.zip",
"unzip protoc-21.5-linux-x86_64.zip -d /usr/local/"
]
[target.aarch64-unknown-linux-gnu]
pre-build=[
"dpkg --add-architecture arm64 && apt-get update && apt-get install --assume-yes wget unzip",
Expand Down
7 changes: 6 additions & 1 deletion rust/pact_ffi/release-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ cargo_flags=( "$@" )

# Build the x86_64 GNU linux release
build_x86_64_gnu() {
cargo build --target x86_64-unknown-linux-gnu "${cargo_flags[@]}"
install_cross
cargo clean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure the cargo clean is necessary before every build? Ideally, we would want Rust to re-use whatever intermediate steps it can to reduce the build time. And I thought that Rust was typically smart enough to recognise when it can re-use steps across different targets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I just saw the related comment over in the Pact-JS repo 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that is what i would want too, however building with cross isn’t storing all build files in target/ it also seems to be storing things in target/debug or target/release as well which is where we get the issue regarding missing symbols for glibc.

probably should find out where and fix it upstream as it would allow us to cache deps and not need to worry about the glibc conflicts as they should be completely seperated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JP-Ellis

Looks like there is a less destructive solution which will help for caching

Use a custom target directory for each cross-compilation target (--target-dir path/to/x).

Linked issue which describes the problems seen during multiple cross runs for diff archs

cross-rs/cross#724

cross build --target x86_64-unknown-linux-gnu "${cargo_flags[@]}"

if [[ "${cargo_flags[*]}" =~ "--release" ]]; then
gzip_and_sum \
Expand All @@ -29,6 +31,7 @@ build_x86_64_gnu() {

build_x86_64_musl() {
sudo apt-get install -y musl-tools
cargo clean
cargo build --target x86_64-unknown-linux-musl "${cargo_flags[@]}"

if [[ "${cargo_flags[*]}" =~ "--release" ]]; then
Expand Down Expand Up @@ -63,6 +66,7 @@ install_cross() {

build_aarch64_gnu() {
install_cross
cargo clean
cross build --target aarch64-unknown-linux-gnu "${cargo_flags[@]}"

if [[ "${cargo_flags[*]}" =~ "--release" ]]; then
Expand All @@ -77,6 +81,7 @@ build_aarch64_gnu() {

build_aarch64_musl() {
install_cross
cargo clean
cross build --target aarch64-unknown-linux-musl "${cargo_flags[@]}"

if [[ "${cargo_flags[*]}" =~ "--release" ]]; then
Expand Down
Loading