60
60
echo " WARNING: Please install valgrind for more testing"
61
61
fi
62
62
63
+ CLANGOPTS=" -Wall -Wno-nullability-completeness -pthread"
64
+
63
65
# Test a statically-linked C++ version, tracking the resulting binary size and runtime
64
66
# 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/libldk.a -ldl
67
+ clang++ $CLANGOPTS demo.cpp target/debug/libldk.a -ldl
66
68
strip ./a.out
67
69
echo " C++ Bin size and runtime w/o optimization:"
68
70
ls -lha a.out
@@ -83,11 +85,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" ]; then
83
85
set +e
84
86
85
87
# 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/libldk.a -ldl
88
+ clang-$LLVM_V $CLANGOPTS -fsanitize=memory -fsanitize-memory-track-origins -g demo.c target/debug/libldk.a -ldl
87
89
./a.out
88
90
89
91
# ...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/libldk.a -ldl
92
+ clang++-$LLVM_V -std=c++11 $CLANGOPTS -fsanitize=memory -fsanitize-memory-track-origins -g demo.cpp target/debug/libldk.a -ldl
91
93
./a.out > /dev/null
92
94
93
95
# restore exit-on-failure
@@ -153,11 +155,11 @@ if [ "$HOST_PLATFORM" = "host: x86_64-unknown-linux-gnu" -o "$HOST_PLATFORM" = "
153
155
mv Cargo.toml.bk Cargo.toml
154
156
155
157
# First the C demo app...
156
- $CLANG -fsanitize=address -Wall -g -pthread demo.c target/debug/libldk.a -ldl
158
+ $CLANG $CLANGOPTS -fsanitize=address -g demo.c target/debug/libldk.a -ldl
157
159
ASAN_OPTIONS=' detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out
158
160
159
161
# ...then the C++ demo app
160
- $CLANGPP -std=c++11 -fsanitize=address -Wall -g -pthread demo.cpp target/debug/libldk.a -ldl
162
+ $CLANGPP $CLANGOPTS -std=c++11 -fsanitize=address -g demo.cpp target/debug/libldk.a -ldl
161
163
ASAN_OPTIONS=' detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' ./a.out > /dev/null
162
164
else
163
165
echo " WARNING: Please install clang-$RUSTC_LLVM_V and clang++-$RUSTC_LLVM_V to build with address sanitizer"
168
170
169
171
# Now build with LTO on on both C++ and rust, but without cross-language LTO:
170
172
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C lto
171
- clang++ -std=c++11 -Wall - flto -O2 -pthread demo.cpp target/release/libldk.a -ldl
173
+ clang++ $CLANGOPTS -std=c++11 -flto -O2 demo.cpp target/release/libldk.a -ldl
172
174
strip ./a.out
173
175
echo " C++ Bin size and runtime with only RL (LTO) optimized:"
174
176
ls -lha a.out
@@ -181,7 +183,7 @@ if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then
181
183
# packaging than simply shipping the rustup binaries (eg Debian should Just Work
182
184
# here).
183
185
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld
184
- $CLANGPP -Wall -std=c++11 - flto -fuse-ld=lld -O2 -pthread demo.cpp target/release/libldk.a -ldl
186
+ $CLANGPP $CLANGOPTS - flto -fuse-ld=lld -O2 demo.cpp target/release/libldk.a -ldl
185
187
strip ./a.out
186
188
echo " C++ Bin size and runtime with cross-language LTO:"
187
189
ls -lha a.out
0 commit comments