From 00d92f63d3c99440db416e427f11d30c64ef5228 Mon Sep 17 00:00:00 2001 From: SwuduSusuwu <2002luvabbaluvu@gmail.com> Date: Sat, 15 Jun 2024 08:35:29 -0700 Subject: [PATCH] @make.sh New choice `./make.sh --release` is fast ``` Welcome to Termux! ~/SubStack $ ./make.sh \# /* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */ \# /* `./make.sh` defaults to `./make.sh --debug`. Use `./make.sh --release` if you want fast executables */ + clang++ -fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fno-omit-frame-pointer -g -x c -c ./cxx//../c/rfc6234/sha1.c ^C ~/SubStack $ ./make.sh --release \# /* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */ \# /* `./make.sh --release` does not support profilers/debuggers (use `./make.sh --debug` for this) */ + clang++ -fomit-frame-pointer -DNDEBUG -O2 -x c -c ./cxx//../c/rfc6234/sha1.c + clang++ -fomit-frame-pointer -DNDEBUG -O2 -x c -c ./cxx//../c/rfc6234/sha224-256.c + clang++ -fomit-frame-pointer -DNDEBUG -O2 -x c -c ./cxx//../c/rfc6234/sha384-512.c + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//ClassSha2.cxx + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//ClassResultList.cxx + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//ClassCns.cxx + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//VirusAnalysis.cxx + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//ConversationCns.cxx ./cxx//ConversationCns.cxx:106:74: warning: non-void function does not return a value [-Wreturn-type] 106 | const FileBytecode conversationParseQuestion(const FilePath &xhtmlFile) {} /* TODO */ | ^ ./cxx//ConversationCns.cxx:107:88: warning: non-void function does not return a value [-Wreturn-type] 107 | const std::vector conversationParseResponses(const FilePath &xhtmlFile) {} /* TODO */ | ^ 2 warnings generated. + clang++ -fomit-frame-pointer -DNDEBUG -O2 -c ./cxx//main.cxx ./+ clang++ -fomit-frame-pointer -DNDEBUG -O2 sha1.o sha224-256.o sha384-512.o ClassSha2.o ClassResultList.o ClassCns.o VirusAnalysis.o ConversationCns.o main.o + set +x ~/SubStack $ ./a.out cxx/Macros.hxx: pass virusAnalysisTestsThrows(): pass conversationCnsTestsThrows(): Segmentation fault ~/SubStack $ ``` --- make.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/make.sh b/make.sh index b20355e2..5f5dbe4b 100755 --- a/make.sh +++ b/make.sh @@ -1,13 +1,13 @@ #!/bin/sh -echo '/* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */' +echo '# /* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */' #cd build sSRC="./cxx/" #INCLUDES="${sSRC}" #export CXX_FLAGS="-I${INCLUDES}" +CXX_FLAGS_RELEASE="-fomit-frame-pointer -DNDEBUG -O2" CXX_FLAGS_DEBUG="-fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment" #/* supports `g++`/`clang++`: https://developers.redhat.com/blog/2021/05/05/memory-error-checking-in-c-and-c-comparing-sanitizers-and-valgrind#tldr */ -export ASAN_OPTIONS=abort_on_error=1:fast_unwind_on_malloc=0:detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 #/* "For LLDB/GDB and to prevent very short stack traces and usually false leaks detection" */ CXX_FLAGS_DEBUG="${CXX_FLAGS_DEBUG} -fno-omit-frame-pointer" #/* thus optimization won't remove stacktraces: https://stackoverflow.com/questions/48234575/g-will-fno-omit-frame-pointer-be-effective-if-specified-before-o2-or-o3 https://clang.llvm.org/docs/MemorySanitizer.html */ -CXX_FLAGS_DEBUG="${CXX_FLAGS_DEBUG} -g" #/* gives line numbers, + arguments, to stacktraces */ +CXX_FLAGS_DEBUG="${CXX_FLAGS_DEBUG} -g" #/* extra symbols (line numbers + arguments) to stacktraces */ #CXX_FLAGS_DEBUG="${CXX_FLAGS_DEBUG} -fno-optimize-sibling-calls" #/* Don't inline functions. Does extra stacktraces. */ #CXX_FLAGS_DEBUG="${CXX_FLAGS_DEBUG} -fsanitize=undefined" #/* causes 'cannot locate symbol "__ubsan_handle_function_type_mismatch_abort"' */ if command -v ctags > /dev/null; then @@ -21,9 +21,16 @@ else echo "Error: no clang++, no g++. `apt install clang` or `apt install gcc`" exit 1 fi -rm *.o -CXX_FLAGS="${CXX_FLAGS} ${CXX_FLAGS_DEBUG}" #/* comment this to disable sanitizers/stacktraces (if you want to run fast) */ +if [ "--release" = "$1" ]; then + echo "# /* \`$0 --release\` does not support profilers/debuggers (use \`$0 --debug\` for this) */" + CXX_FLAGS="${CXX_FLAGS} ${CXX_FLAGS_RELEASE}" +else + echo "# /* \`$0\` defaults to \`$0 --debug\`. Use \`$0 --release\` if you want fast executables */" + CXX_FLAGS="${CXX_FLAGS} ${CXX_FLAGS_DEBUG}" + export ASAN_OPTIONS=abort_on_error=1:fast_unwind_on_malloc=0:detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 #/* "For LLDB/GDB and to prevent very short stack traces and usually false leaks detection" */ +fi CXX="${CXX} ${CXX_FLAGS}" +rm *.o set -x $CXX -x c -c ${sSRC}/../c/rfc6234/sha1.c $CXX -x c -c ${sSRC}/../c/rfc6234/sha224-256.c