Skip to content

Commit d08bdf4

Browse files
committed
[bindings] Fix genbindings.sh compile issues on OSX
There were two issues on OSX - we need to give gcc the clang warnings flags because `gcc` *is* clang on OSX and we missed an `-std=c++11` on one of the clang++ calls, causing compile failures.
1 parent afc9808 commit d08bdf4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

genbindings.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ fi
4747

4848
# Finally, sanity-check the generated C and C++ bindings with demo apps:
4949

50+
CFLAGS="-Wall -Wno-nullability-completeness -pthread"
51+
5052
# Naively run the C demo app:
51-
gcc -Wall -g -pthread demo.c target/debug/libldk.a -ldl
53+
gcc $CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl
5254
./a.out
5355

5456
# And run the C++ demo app in valgrind to test memory model correctness and lack of leaks.
55-
g++ -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl
57+
g++ $CFLAGS -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/debug/ -lldk -ldl
5658
if [ -x "`which valgrind`" ]; then
5759
LD_LIBRARY_PATH=target/debug/ valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
5860
echo
5961
else
6062
echo "WARNING: Please install valgrind for more testing"
6163
fi
6264

63-
CLANGOPTS="-Wall -Wno-nullability-completeness -pthread"
64-
6565
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
6666
# across debug, LTO, and cross-language LTO builds (using the same compiler each time).
67-
clang++ $CLANGOPTS demo.cpp target/debug/libldk.a -ldl
67+
clang++ $CFLAGS -std=c++11 demo.cpp target/debug/libldk.a -ldl
6868
strip ./a.out
6969
echo " C++ Bin size and runtime w/o optimization:"
7070
ls -lha a.out
@@ -85,11 +85,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" ]; then
8585
set +e
8686

8787
# First the C demo app...
88-
clang-$LLVM_V $CLANGOPTS -fsanitize=memory -fsanitize-memory-track-origins -g demo.c target/debug/libldk.a -ldl
88+
clang-$LLVM_V $CFLAGS -fsanitize=memory -fsanitize-memory-track-origins -g demo.c target/debug/libldk.a -ldl
8989
./a.out
9090

9191
# ...then the C++ demo app
92-
clang++-$LLVM_V -std=c++11 $CLANGOPTS -fsanitize=memory -fsanitize-memory-track-origins -g demo.cpp target/debug/libldk.a -ldl
92+
clang++-$LLVM_V $CFLAGS -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -g demo.cpp target/debug/libldk.a -ldl
9393
./a.out >/dev/null
9494

9595
# restore exit-on-failure
@@ -155,11 +155,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" -o "$HOST_PLATFORM" = "
155155
mv Cargo.toml.bk Cargo.toml
156156

157157
# First the C demo app...
158-
$CLANG $CLANGOPTS -fsanitize=address -g demo.c target/debug/libldk.a -ldl
158+
$CLANG $CFLAGS -fsanitize=address -g demo.c target/debug/libldk.a -ldl
159159
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out
160160

161161
# ...then the C++ demo app
162-
$CLANGPP $CLANGOPTS -std=c++11 -fsanitize=address -g demo.cpp target/debug/libldk.a -ldl
162+
$CLANGPP $CFLAGS -std=c++11 -fsanitize=address -g demo.cpp target/debug/libldk.a -ldl
163163
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out >/dev/null
164164
else
165165
echo "WARNING: Please install clang-$RUSTC_LLVM_V and clang++-$RUSTC_LLVM_V to build with address sanitizer"
@@ -170,7 +170,7 @@ fi
170170

171171
# Now build with LTO on on both C++ and rust, but without cross-language LTO:
172172
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C lto
173-
clang++ $CLANGOPTS -std=c++11 -flto -O2 demo.cpp target/release/libldk.a -ldl
173+
clang++ $CFLAGS -std=c++11 -flto -O2 demo.cpp target/release/libldk.a -ldl
174174
strip ./a.out
175175
echo "C++ Bin size and runtime with only RL (LTO) optimized:"
176176
ls -lha a.out
@@ -183,7 +183,7 @@ if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then
183183
# packaging than simply shipping the rustup binaries (eg Debian should Just Work
184184
# here).
185185
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld
186-
$CLANGPP $CLANGOPTS -flto -fuse-ld=lld -O2 demo.cpp target/release/libldk.a -ldl
186+
$CLANGPP $CFLAGS -flto -fuse-ld=lld -O2 demo.cpp target/release/libldk.a -ldl
187187
strip ./a.out
188188
echo "C++ Bin size and runtime with cross-language LTO:"
189189
ls -lha a.out

0 commit comments

Comments
 (0)