48
48
# Finally, sanity-check the generated C and C++ bindings with demo apps:
49
49
50
50
# Naively run the C demo app:
51
- gcc -Wall -g -pthread demo.c ../ target/debug/liblightning .a -ldl
51
+ gcc -Wall -g -pthread demo.c target/debug/libldk .a -ldl
52
52
./a.out
53
53
54
54
# 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 -L../target/ debug/ -llightning -ldl
55
+ g++ -std=c++11 -Wall -g -pthread demo.cpp -Ltarget/ debug/ -lldk -ldl
56
56
if [ -x " ` which valgrind` " ]; then
57
- LD_LIBRARY_PATH=../ target/debug/ valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
57
+ LD_LIBRARY_PATH=target/debug/ valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out
58
58
echo
59
59
else
60
60
echo " WARNING: Please install valgrind for more testing"
61
61
fi
62
62
63
63
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
64
64
# across debug, LTO, and cross-language LTO builds (using the same compiler each time).
65
- clang++ -std=c++11 -Wall -pthread demo.cpp ../ target/debug/liblightning .a -ldl
65
+ clang++ -std=c++11 -Wall -pthread demo.cpp target/debug/libldk .a -ldl
66
66
./a.out > /dev/null
67
67
echo " C++ Bin size and runtime w/o optimization:"
68
68
ls -lha a.out
@@ -75,19 +75,19 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" ]; then
75
75
if [ -x " $( which clang-$LLVM_V ) " ]; then
76
76
cargo +nightly clean
77
77
cargo +nightly rustc -Zbuild-std --target x86_64-unknown-linux-gnu -v -- -Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes
78
- mv ../ target/x86_64-unknown-linux-gnu/debug/liblightning .* ../ target/debug/
78
+ mv target/x86_64-unknown-linux-gnu/debug/libldk .* target/debug/
79
79
80
80
# Sadly, std doesn't seem to compile into something that is memsan-safe as of Aug 2020,
81
81
# so we'll always fail, not to mention we may be linking against git rustc LLVM which
82
82
# may differ from clang-llvm, so just allow everything here to fail.
83
83
set +e
84
84
85
85
# First the C demo app...
86
- clang-$LLVM_V -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -Wall -g -pthread demo.c ../ target/debug/liblightning .a -ldl
86
+ clang-$LLVM_V -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -Wall -g -pthread demo.c target/debug/libldk .a -ldl
87
87
./a.out
88
88
89
89
# ...then the C++ demo app
90
- clang++-$LLVM_V -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -Wall -g -pthread demo.cpp ../ target/debug/liblightning .a -ldl
90
+ clang++-$LLVM_V -std=c++11 -fsanitize=memory -fsanitize-memory-track-origins -Wall -g -pthread demo.cpp target/debug/libldk .a -ldl
91
91
./a.out > /dev/null
92
92
93
93
# restore exit-on-failure
@@ -153,11 +153,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" -o "$HOST_PLATFORM" = "
153
153
mv Cargo.toml.bk Cargo.toml
154
154
155
155
# First the C demo app...
156
- $CLANG -fsanitize=address -Wall -g -pthread demo.c ../ target/debug/liblightning .a -ldl
156
+ $CLANG -fsanitize=address -Wall -g -pthread demo.c target/debug/libldk .a -ldl
157
157
ASAN_OPTIONS=' detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out
158
158
159
159
# ...then the C++ demo app
160
- $CLANGPP -std=c++11 -fsanitize=address -Wall -g -pthread demo.cpp ../ target/debug/liblightning .a -ldl
160
+ $CLANGPP -std=c++11 -fsanitize=address -Wall -g -pthread demo.cpp target/debug/libldk .a -ldl
161
161
ASAN_OPTIONS=' detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out > /dev/null
162
162
else
163
163
echo " WARNING: Please install clang-$RUSTC_LLVM_V and clang++-$RUSTC_LLVM_V to build with address sanitizer"
168
168
169
169
# Now build with LTO on on both C++ and rust, but without cross-language LTO:
170
170
cargo rustc -v --release -- -C lto
171
- clang++ -std=c++11 -Wall -flto -O2 -pthread demo.cpp ../ target/release/liblightning .a -ldl
171
+ clang++ -std=c++11 -Wall -flto -O2 -pthread demo.cpp target/release/libldk .a -ldl
172
172
echo " C++ Bin size and runtime with only RL (LTO) optimized:"
173
173
ls -lha a.out
174
174
time ./a.out > /dev/null
@@ -180,7 +180,7 @@ if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then
180
180
# packaging than simply shipping the rustup binaries (eg Debian should Just Work
181
181
# here).
182
182
cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld
183
- $CLANGPP -Wall -std=c++11 -flto -fuse-ld=lld -O2 -pthread demo.cpp ../ target/release/liblightning .a -ldl
183
+ $CLANGPP -Wall -std=c++11 -flto -fuse-ld=lld -O2 -pthread demo.cpp target/release/libldk .a -ldl
184
184
echo " C++ Bin size and runtime with cross-language LTO:"
185
185
ls -lha a.out
186
186
time ./a.out > /dev/null
0 commit comments