Skip to content

Commit 6e34cb3

Browse files
authored
Merge pull request #97 from TheBlueMatt/main
Fix LTO compilation with latest ld.lld on OSX
2 parents f87b75f + baba8f6 commit 6e34cb3

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ jobs:
7070
run: rustup target install aarch64-apple-darwin
7171
- name: Fetch upstream LLVM/clang snapshot
7272
run: |
73-
wget -O clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
74-
if [ "$(shasum -a 256 clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "7bc2259bf75c003f644882460fc8e844ddb23b27236fe43a2787870a4cd8ab50" ]; then
73+
wget -O clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.3/clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz
74+
if [ "$(shasum -a 256 clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "ac668586b2b3d068f1e43520a3ef0b1592e5dc3eff1a4a4b772e29803b428a69" ]; then
7575
echo "Bad hash"
7676
exit 1
7777
fi
7878
- name: Unpack upstream LLVM+clang and use it by default
7979
run: |
80-
tar xvvf clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
80+
tar xvvf clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz
8181
- name: Checkout source code
8282
uses: actions/checkout@v2
8383
with:
@@ -93,5 +93,5 @@ jobs:
9393
run: ./genbindings.sh ./rust-lightning true
9494
- name: Rebuild bindings using upstream clang, and check the sample app builds + links
9595
run: |
96-
export PATH=`pwd`/clang+llvm-12.0.0-x86_64-apple-darwin/bin:$PATH
96+
export PATH=`pwd`/clang+llvm-15.0.3-x86_64-apple-darwin/bin:$PATH
9797
CC=clang ./genbindings.sh ./rust-lightning true

genbindings.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ if [ "$2" = "true" ]; then
338338
strip ./a.out
339339
echo " C++ Bin size and runtime w/o optimization:"
340340
ls -lha a.out
341-
time ./a.out > /dev/null
341+
./a.out > /dev/null
342342
fi
343343

344344
# Then, check with memory sanitizer, if we're on Linux and have rustc nightly
@@ -492,7 +492,7 @@ fi
492492
strip ./a.out
493493
echo "C++ Bin size and runtime with only RL (LTO) optimized:"
494494
ls -lha a.out
495-
time ./a.out > /dev/null
495+
./a.out > /dev/null
496496

497497
if [ "$CLANGPP" != "" ]; then
498498
# If we can use cross-language LTO, use it for building C dependencies (i.e. libsecp256k1) as well
@@ -559,11 +559,12 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
559559
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
560560

561561
if [ "$2" = "true" ]; then
562-
$CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 demo.cpp target/release/libldk.a -ldl
562+
$CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 -c demo.cpp -o demo.o
563+
$CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -Wl,--lto-O2 -Wl,-O2 -O2 demo.o target/release/libldk.a -ldl
563564
strip ./a.out
564565
echo "C++ Bin size and runtime with cross-language LTO:"
565566
ls -lha a.out
566-
time ./a.out > /dev/null
567+
./a.out > /dev/null
567568
fi
568569
fi
569570
else

0 commit comments

Comments
 (0)