1 dnl The CLN manual says that without CFLAGS or CXXFLAGS being set compilation
2 dnl will happen with -O. However, AC_PROG_CC and AC_PROG_CXX set CFLAGS and
3 dnl CXXFLAGS to "-g -O2", which produces way too large binaries.
6 dnl Wrapper around AC_PROG_CC setting CFLAGS to plain "-O" as opposed to
7 dnl "-g -O2" for the GNU compiler (unless CFLAGS was set before).
9 [cl_test_CFLAGS=${CFLAGS+set}
10 # Make sure this macro does not come after AC_PROG_CC.
11 # Otherwise CFLAGS would already be set.
12 AC_BEFORE([$0],[AC_PROG_CC])dnl
14 if test "$cl_test_CFLAGS" != set && test "$ac_compiler_gnu" = yes; then
20 dnl Wrapper around AC_PROG_CXX setting CXXFLAGS to plain "-O" as opposed to
21 dnl "-g -O2" for the GNU compiler (unless CXXFLAGS was set before). Also
22 dnl emits a warning if G++ is used and optimization turned off.
23 AC_DEFUN([CL_PROG_CXX],
24 [cl_test_CXXFLAGS=${CXXFLAGS+set}
25 # Make sure this macro does not come after AC_PROG_CXX.
26 # Otherwise CXXFLAGS would already be set.
27 AC_BEFORE([$0],[AC_PROG_CXX])dnl
29 if test "$ac_compiler_gnu" = yes; then
30 if test "$cl_test_CXXFLAGS" != set; then
31 # User has not set CXXFLAGS.
34 # Warn if optimization has been turned off with GCC.
35 # Optimization is used for module ordering.
37 [ *\ -O | -O | -O\ * | *\ -O\ * | -O[!0]* | *\ -O[!0]*) ;; ]
38 *) AC_MSG_WARN([Optimization turned off. I recommend you unset CXXFLAGS.]);;
45 dnl Checks whether the stack can be marked nonexecutable by passing an option
46 dnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.
47 dnl This macro is adapted from one found in GLIBC-2.3.5.
48 AC_DEFUN([CL_AS_NOEXECSTACK],[
49 AC_REQUIRE([AC_PROG_CC])
50 AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
51 cat > conftest.c <<EOF
54 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
55 -S -o conftest.s conftest.c >/dev/null]) \
56 && grep -q .note.GNU-stack conftest.s \
57 && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack
58 -c -o conftest.o conftest.s >/dev/null])
60 cl_cv_as_noexecstack=yes
62 cl_cv_as_noexecstack=no
65 if test "$cl_cv_as_noexecstack" = yes; then
66 ASMFLAGS="$ASMFLAGS -Wa,--noexecstack"
72 dnl Checks whether the compiler supports __attribute__((flatten)).
73 AC_DEFUN([CL_ATTRIBUTE_FLATTEN],[
74 AC_REQUIRE([AC_PROG_CXX])
75 AC_CACHE_CHECK([whether the compiler supports __attribute__((flatten))], cl_cv_have_attr_flatten, [dnl
76 cat > conftest.cc <<EOF
77 void f() __attribute__((flatten));
79 AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -c conftest.cc >/dev/null 2>conftest.out)
80 if grep -i "warning" conftest.out > /dev/null; then
81 cl_cv_have_attr_flatten=no
83 cl_cv_have_attr_flatten=yes
87 if test $cl_cv_have_attr_flatten = yes; then
88 AC_DEFINE(CL_HAVE_ATTRIBUTE_FLATTEN)