diff options
| author | 2017-06-08 03:14:18 +0200 | |
|---|---|---|
| committer | 2017-06-08 03:14:18 +0200 | |
| commit | ec9ba8bff6a4469aa75f6d570ab5109c061c6a9e (patch) | |
| tree | d38d880dda9503b2466230808eb980f1396a6923 | |
| parent | be567b3ac81caee2fc6a2e91317d4fe9e3f95a7c (diff) | |
| download | libplist-ec9ba8bff6a4469aa75f6d570ab5109c061c6a9e.tar.gz libplist-ec9ba8bff6a4469aa75f6d570ab5109c061c6a9e.tar.bz2 | |
configure: Allow building with sanitizers (without fuzzers)
Passing --with-sanitizers will enable building with available sanitizers.
Passing --with-fuzzers will enable building fuzzers which will also imply
--with-sanitizers.
| -rw-r--r-- | configure.ac | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac index 187ab11..0bf6687 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -162,15 +162,26 @@ case "$GLOBAL_CFLAGS" in | |||
| 162 | AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden]) | 162 | AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden]) |
| 163 | esac | 163 | esac |
| 164 | 164 | ||
| 165 | AC_ARG_WITH([sanitizers], | ||
| 166 | [AS_HELP_STRING([--with-sanitizers], | ||
| 167 | [build libplist with sanitizers (default is no)])], | ||
| 168 | [build_sanitizers=${withval}], | ||
| 169 | []) | ||
| 170 | |||
| 165 | AC_ARG_WITH([fuzzers], | 171 | AC_ARG_WITH([fuzzers], |
| 166 | [AS_HELP_STRING([--with-fuzzers], | 172 | [AS_HELP_STRING([--with-fuzzers], |
| 167 | [build fuzzers and libplist with sanitizers (default is no)])], | 173 | [build fuzzers (implies --with-sanitizers, default is no)])], |
| 168 | [build_fuzzers=true], | 174 | [build_fuzzers=${withval}], |
| 169 | [build_fuzzers=false]) | 175 | [build_fuzzers=no]) |
| 170 | if test "x$build_fuzzers" = "xtrue"; then | 176 | |
| 171 | if test "$CXX" != "clang++"; then | 177 | if test "x$build_fuzzers" = "xyes"; then |
| 172 | AC_MSG_WARN([building fuzzers requires clang/clang++ (continuing anyway)]) | 178 | if test "x$build_sanitizers" = "xno"; then |
| 179 | AC_MSG_ERROR([--with-fuzzers implies --with-sanitizers, but --without-sanitizers was given. This does not work.]) | ||
| 173 | fi | 180 | fi |
| 181 | build_sanitizers=yes | ||
| 182 | fi | ||
| 183 | |||
| 184 | if test "x$build_sanitizers" = "xyes"; then | ||
| 174 | AS_COMPILER_FLAG([-fsanitize=address], [ | 185 | AS_COMPILER_FLAG([-fsanitize=address], [ |
| 175 | SANITIZER_FLAGS+=" -fsanitize=address" | 186 | SANITIZER_FLAGS+=" -fsanitize=address" |
| 176 | ASAN_AVAILABLE=yes | 187 | ASAN_AVAILABLE=yes |
| @@ -207,6 +218,7 @@ if test "x$build_fuzzers" = "xtrue"; then | |||
| 207 | done | 218 | done |
| 208 | if test -n "$SAN_COV_FLAGS"; then | 219 | if test -n "$SAN_COV_FLAGS"; then |
| 209 | SANITIZER_FLAGS+=" -fsanitize-coverage=$SAN_COV_FLAGS" | 220 | SANITIZER_FLAGS+=" -fsanitize-coverage=$SAN_COV_FLAGS" |
| 221 | SANITIZERS+="+coverage " | ||
| 210 | else | 222 | else |
| 211 | AC_MSG_WARN([No sanitizer coverage supported by compiler]) | 223 | AC_MSG_WARN([No sanitizer coverage supported by compiler]) |
| 212 | fi | 224 | fi |
| @@ -224,16 +236,29 @@ if test "x$build_fuzzers" = "xtrue"; then | |||
| 224 | CFLAGS+=" -g" | 236 | CFLAGS+=" -g" |
| 225 | ]) | 237 | ]) |
| 226 | 238 | ||
| 227 | CFLAGS+=" -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" | 239 | EXTRA_CONF+=" Enabled sanitizers ......: $SANITIZERS |
| 240 | " | ||
| 241 | |||
| 228 | CFLAGS+=" $SANITIZER_FLAGS" | 242 | CFLAGS+=" $SANITIZER_FLAGS" |
| 229 | CXXFLAGS="$CFLAGS -std=c++11" | 243 | CXXFLAGS="$CFLAGS -std=c++11" |
| 244 | fi | ||
| 245 | |||
| 246 | if test "x$build_fuzzers" = "xyes"; then | ||
| 247 | if test "$CXX" != "clang++"; then | ||
| 248 | AC_MSG_WARN([building fuzzers requires clang/clang++ (continuing anyway)]) | ||
| 249 | fi | ||
| 250 | |||
| 251 | CFLAGS+=" -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" | ||
| 252 | |||
| 230 | EXTRA_CONF+=" Build fuzzers ...........: yes | 253 | EXTRA_CONF+=" Build fuzzers ...........: yes |
| 231 | " | 254 | " |
| 232 | EXTRA_CONF+=" Enabled sanitizers ......: $SANITIZERS | 255 | fi |
| 233 | " | 256 | |
| 257 | AM_CONDITIONAL([BUILD_FUZZERS],[test "x$build_fuzzers" = "xyes"]) | ||
| 258 | |||
| 259 | if test "x$build_fuzzers" = "xyes" || test "x$build_sanitizers" = "xyes"; then | ||
| 234 | AS_COMPILER_FLAGS(TEST_CFLAGS, [$CFLAGS]) | 260 | AS_COMPILER_FLAGS(TEST_CFLAGS, [$CFLAGS]) |
| 235 | fi | 261 | fi |
| 236 | AM_CONDITIONAL([BUILD_FUZZERS],[test "x$build_fuzzers" = "xtrue"]) | ||
| 237 | 262 | ||
| 238 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) | 263 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
| 239 | 264 | ||
