Sun, 08 Jun 2025 14:57:54 +0200
add option to enable ASan
configure | file | annotate | diff | comparison | revisions | |
make/project.xml | file | annotate | diff | comparison | revisions |
--- a/configure Sun Jun 01 16:35:23 2025 +0200 +++ b/configure Sun Jun 08 14:57:54 2025 +0200 @@ -110,6 +110,9 @@ --debug add extra compile flags for debug builds --release add extra compile flags for release builds +Optional Features: + --enable-asan Enable address sanitization. + __EOF__ } @@ -178,6 +181,8 @@ "--help"*) printhelp; abort_configure ;; "--debug") BUILD_TYPE="debug" ;; "--release") BUILD_TYPE="release" ;; + "--enable-asan") FEATURE_ASAN=on ;; + "--disable-asan") unset FEATURE_ASAN ;; "-"*) echo "unknown option: $ARG"; abort_configure ;; esac done @@ -318,6 +323,26 @@ dep_checked_sdl2_ttf=1 return 0 } +dependency_error_asan() +{ + print_check_msg "$dep_checked_asan" "checking for asan... " + # dependency asan toolchain="gnuc" + while true + do + if notistoolchain "gnuc"; then + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -fsanitize=address" + TEMP_LDFLAGS="$TEMP_LDFLAGS -fsanitize=address" + print_check_msg "$dep_checked_asan" "yes\n" + dep_checked_asan=1 + return 1 + done + + print_check_msg "$dep_checked_asan" "no\n" + dep_checked_asan=1 + return 0 +} dependency_error_sdl2() { print_check_msg "$dep_checked_sdl2" "checking for sdl2... " @@ -470,20 +495,24 @@ # echo >> "$TEMP_DIR/flags.mk" -echo "configuring target: default" -echo "# flags for target default" >> "$TEMP_DIR/flags.mk" +echo "configuring global target" +echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" TEMP_CFLAGS= TEMP_CXXFLAGS= TEMP_LDFLAGS= -if dependency_error_sdl2_ttf; then - DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sdl2_ttf " +if dependency_error_ucx; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ucx " ERROR=1 fi if dependency_error_sdl2; then DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sdl2 " ERROR=1 fi +if dependency_error_sdl2_ttf; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sdl2_ttf " + ERROR=1 +fi if dependency_error_sdl2_image; then DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sdl2_image " ERROR=1 @@ -492,12 +521,28 @@ DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED glew " ERROR=1 fi -if dependency_error_ucx; then - DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ucx " - ERROR=1 -fi # Features +if [ -n "$FEATURE_ASAN" ]; then + # check dependency + if dependency_error_asan ; then + # "auto" features can fail and are just disabled in this case + if [ "$FEATURE_ASAN" = "auto" ]; then + DISABLE_FEATURE_ASAN=1 + else + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED asan " + ERROR=1 + fi + fi + if [ -n "$DISABLE_FEATURE_ASAN" ]; then + unset FEATURE_ASAN + fi +fi +if [ -n "$FEATURE_ASAN" ]; then + : +else + : +fi if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then @@ -582,6 +627,13 @@ echo " localedir: $localedir" fi echo +echo "Features:" +if [ -n "$FEATURE_ASAN" ]; then +echo " asan: on" +else +echo " asan: off" +fi +echo # generate the config.mk file pwd=`pwd`
--- a/make/project.xml Sun Jun 01 16:35:23 2025 +0200 +++ b/make/project.xml Sun Jun 08 14:57:54 2025 +0200 @@ -29,5 +29,18 @@ <dependency name="glew"> <pkgconfig>glew</pkgconfig> </dependency> + + <dependency name="asan" toolchain="gnuc"> + <cflags>-fsanitize=address</cflags> + <ldflags>-fsanitize=address</ldflags> + </dependency> + + <target> + <feature name="asan"> + <desc>Enable address sanitization.</desc> + <dependencies>asan</dependencies> + </feature> + <dependencies>ucx,sdl2,sdl2_ttf,sdl2_image,glew</dependencies> + </target> </project>