Skip to content

Commit c14513f

Browse files
authored
Merge pull request #116 from TheBlueMatt/main
Support Building on Fedora
2 parents a7ad891 + 52e8a0e commit c14513f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@ on: [push, pull_request]
44

55
jobs:
66
check_bindings:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
11+
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
12+
distro: [ "debian:bullseye", "fedora:39" ]
713
runs-on: ubuntu-latest
8-
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
9-
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
10-
container: debian:bullseye
14+
container: ${{ matrix.distro }}
1115
env:
1216
TOOLCHAIN: stable
1317
steps:
1418
- name: Install native Rust toolchain, Valgrind, and build utilitis
19+
if: "matrix.distro == 'debian:bullseye'"
1520
run: |
1621
apt-get update
1722
apt-get -y dist-upgrade
1823
apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang wget
24+
- name: Install native Rust toolchain, Valgrind, and build utilitis
25+
if: "matrix.distro == 'fedora:39'"
26+
run: |
27+
dnf -y install cargo rust-std-static-wasm32-wasi valgrind lld git g++ clang wget which diffutils
1928
- name: Checkout source code
2029
uses: actions/checkout@v2
2130
with:
@@ -38,7 +47,11 @@ jobs:
3847
git clone https://github.com/rust-bitcoin/rust-lightning
3948
cd rust-lightning
4049
git checkout 0.0.118-bindings
50+
- name: Pin memchr
51+
if: "matrix.distro == 'debian:bullseye'"
52+
run: |
4153
# Pin memchr until we can remove it
54+
cd rust-lightning
4255
cargo update -p memchr --precise "2.5.0" --verbose
4356
- name: Fix Github Actions to not be broken
4457
run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings

genbindings.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ rm genbindings_path_map_test_file.c
7474
case "$ENV_TARGET" in
7575
"x86_64"*)
7676
export RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge"
77-
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
77+
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -march=sandybridge -mtune=sandybridge"
7878
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS"
7979
;;
8080
"aarch64_apple_darwin")
@@ -85,7 +85,7 @@ case "$ENV_TARGET" in
8585
*)
8686
# Assume this isn't targeted at another host and build for the host's CPU.
8787
export RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=native"
88-
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -mcpu=native"
88+
export BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS -march=native -mtune=native"
8989
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS"
9090
;;
9191
esac
@@ -429,7 +429,9 @@ if [ "$HOST_OSX" = "true" ]; then
429429
fi
430430
fi
431431
else
432-
CLANG_LLVM_V=$(clang --version | head -n1 | awk '{ print substr($4, 0, 2); }')
432+
# Output is something like clang version 17.0.3 (Fedora 17.0.3-1.fc39) or Debian clang version 14.0.6
433+
CLANG_LLVM_V=$(clang --version | head -n1 | awk '{ print substr($3, 0, 2); }')
434+
[ "$CLANG_LLVM_V" = "ve" ] && CLANG_LLVM_V=$(clang --version | head -n1 | awk '{ print substr($4, 0, 2); }')
433435
if [ -x "$(which ld.lld)" ]; then
434436
LLD_LLVM_V="$(ld.lld --version | awk '{ print $2; }')"
435437
if [ "$LLD_LLVM_V" = "LLD" ]; then # eg if the output is "Debian LLD ..."
@@ -586,7 +588,7 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
586588
MANUAL_LINK_CFLAGS="$MANUAL_LINK_CFLAGS -C link-arg=$ARG"
587589
done
588590
export CFLAGS_x86_64_apple_darwin="$CFLAGS_x86_64_apple_darwin -O3 -fPIC -fembed-bitcode"
589-
RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS --offline -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort
591+
RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS --offline -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort
590592
fi
591593
fi
592594
# If we're on an M1 don't bother building X86 binaries
@@ -595,7 +597,7 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
595597
export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode"
596598
# Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
597599
cargo clean --release
598-
CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="$RUSTFLAGS -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS -v --release
600+
CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="$RUSTFLAGS -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS -v --release
599601

600602
if [ "$2" = "true" ]; then
601603
$CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 -c demo.cpp -o demo.o

0 commit comments

Comments
 (0)