# Clang >= 3.3 (required by the project) and are only valid for C code.
WARN_CFLAGS="${WARN_CFLAGS} -Wold-style-definition -Wstrict-prototypes"
+# Disable 'strict aliasing' if the compiler supports it.
+AC_LANG_PUSH([C])
+AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [OPT_CFLAGS], [-Werror])
+AC_LANG_POP([C])
+
## ##
## C++ compiler checks ##
# Major soname for python-lttngust
AC_SUBST([LTTNG_UST_LIB_SONAME_MAJOR], [ust_lib_version_current])
-AM_CFLAGS="$WARN_CFLAGS $URCU_CFLAGS $PTHREAD_CFLAGS"
+AM_CFLAGS="$OPT_CFLAGS $WARN_CFLAGS $URCU_CFLAGS $PTHREAD_CFLAGS"
AC_SUBST(AM_CFLAGS)
AM_CXXFLAGS="$WARN_CXXFLAGS $URCU_CFLAGS $PTHREAD_CFLAGS"
# SPDX-License-Identifier: LGPL-2.1-only
AM_CPPFLAGS += -I$(top_srcdir)/liblttng-ust-comm
-AM_CFLAGS += -fno-strict-aliasing
lib_LTLIBRARIES = liblttng-ust-ctl.la
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust-cyg-profile.la \
liblttng-ust-cyg-profile-fast.la
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust-dl.la
liblttng_ust_dl_la_SOURCES = \
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -fno-strict-aliasing
-
lib_LTLIBRARIES = liblttng-ust-fd.la
liblttng_ust_fd_la_SOURCES = \
lttng-ust-fd.c
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -fno-strict-aliasing
-
lib_LTLIBRARIES = liblttng-ust-fork.la
liblttng_ust_fork_la_SOURCES = ustfork.c
liblttng_ust_fork_la_LIBADD = \
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust-pthread-wrapper.la
# SPDX-License-Identifier: LGPL-2.1-only
# tracepoint provider: always built/installed (does not depend on Python per se)
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust-python-agent.la
# SPDX-License-Identifier: LGPL-2.1-only
-AM_CFLAGS += -I$(srcdir) -fno-strict-aliasing
+AM_CFLAGS += -I$(srcdir)
lib_LTLIBRARIES = liblttng-ust.la