otool <=> ldd. Conditional ASAN
Figured out that otool -L
has the equivalent side-effect as ldd
.
Given the issue that the Address Sanitizer (ASAN) libraries shouldn’t be linked aside from testing, I’ve worked out how to do conditionals in autotools:
diff --git a/configure.ac b/configure.ac
index 5dfdb11..0ffd341 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,18 @@ AC_PROG_MAKE_SET
# Checks for library functions.
+# Conditionals
+
+## Enable ASAN
+AC_ARG_ENABLE([asan],
+[ --enable-asan Turn on Address Sanitizer],
+[ case "${enableval}" in
+ yes) asan=true ;;
+ no) asan=false ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-asan]) ;;
+esac],[asan=false])
+AM_CONDITIONAL([ASAN], [test x$asan = xtrue])
+
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index a99c4ed..733e8c9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,5 @@
-_debug_flags=-fsanitize=address \
+if ASAN
+_asan_debug_flags=-fsanitize=address \
-fsanitize=alignment -fsanitize=bool \
-fsanitize=bounds -fsanitize=enum -fsanitize=enum \
-fsanitize=float-cast-overflow -fsanitize=float-divide-by-zero \
@@ -8,18 +9,23 @@ _debug_flags=-fsanitize=address \
-fsanitize=signed-integer-overflow -fsanitize=unreachable \
-fsanitize=unsigned-integer-overflow -fsanitize=vla-bound \
-fsanitize=vptr
-_debug_ldflags=-fsanitize-memory-track-origins
-AM_CPPFLAGS = -Wall -Werror -Wextra $(_debug_flags)
+_asan_debug_ldflags=-fsanitize-memory-track-origins
+else
+_asan_debug_flags=
+_asan_debug_ldflags=
+endif
+
+AM_CPPFLAGS = -Wall -Werror -Wextra $(_asan_debug_flags)
bin_PROGRAMS = runtime
runtime_SOURCES = runtime.cpp
runtime_CPPFLAGS = -I$(top_srcdir)/build/jemalloc/include \
-I$(top_srcdir)/build/cvmi/include $(AM_CPPFLAGS)
-runtime_LDFLAGS = $(_debug_flags) $(_debug_ldflags)
+runtime_LDFLAGS = $(_asan_debug_flags) $(_asan_debug_ldflags)
runtime_LDADD = $(top_srcdir)/build/jemalloc/lib/libjemalloc.a
lib_LTLIBRARIES = libjvm.la
libjvm_la_SOURCES = runtime.cpp
libjvm_la_CPPFLAGS = -fPIC -I$(top_srcdir)/build/jemalloc/include \
-I$(top_srcdir)/build/cvmi/include $(AM_CPPFLAGS)
-libjvm_la_LDFLAGS = -fPIC -avoid-version $(_debug_flags) $(_debug_ldflags)
+libjvm_la_LDFLAGS = -fPIC -avoid-version $(_asan_debug_flags) $(_asan_debug_ldflags)
libjvm_la_LIBADD = $(top_srcdir)/build/jemalloc/lib/libjemalloc_pic.a