You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.0 KiB

  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.
  4. dnl Wrapper around AC_PROG_CC setting CFLAGS to plain "-O" as opposed to
  5. dnl "-g -O2" for the GNU compiler (unless CFLAGS was set before).
  6. AC_DEFUN([CL_PROG_CC],
  7. [cl_test_CFLAGS=${CFLAGS+set}
  8. # Make sure this macro does not come after AC_PROG_CC.
  9. # Otherwise CFLAGS would already be set.
  10. AC_BEFORE([$0],[AC_PROG_CC])dnl
  11. AC_PROG_CC([$1])
  12. if test "$cl_test_CFLAGS" != set && test "$ac_compiler_gnu" = yes; then
  13. CFLAGS="-O"
  14. fi
  15. ])
  16. dnl Wrapper around AC_PROG_CXX setting CXXFLAGS to plain "-O" as opposed to
  17. dnl "-g -O2" for the GNU compiler (unless CXXFLAGS was set before). Also
  18. dnl emits a warning if G++ is used and optimization turned off.
  19. AC_DEFUN([CL_PROG_CXX],
  20. [cl_test_CXXFLAGS=${CXXFLAGS+set}
  21. # Make sure this macro does not come after AC_PROG_CXX.
  22. # Otherwise CXXFLAGS would already be set.
  23. AC_BEFORE([$0],[AC_PROG_CXX])dnl
  24. AC_PROG_CXX([$1])
  25. if test "$ac_compiler_gnu" = yes; then
  26. if test "$cl_test_CXXFLAGS" != set; then
  27. # User has not set CXXFLAGS.
  28. CXXFLAGS="-O"
  29. else
  30. # Warn if optimization has been turned off with GCC.
  31. # Optimization is used for module ordering.
  32. case $CXXFLAGS in
  33. [ *\ -O | -O | -O\ * | *\ -O\ * | -O[!0]* | *\ -O[!0]*) ;; ]
  34. *) AC_MSG_WARN([Optimization turned off. I recommend you unset CXXFLAGS.]);;
  35. esac
  36. fi
  37. fi
  38. ])
  39. dnl Checks whether the stack can be marked nonexecutable by passing an option
  40. dnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.
  41. dnl This macro is adapted from one found in GLIBC-2.3.5.
  42. AC_DEFUN([CL_AS_NOEXECSTACK],[
  43. AC_REQUIRE([AC_PROG_CC])
  44. AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
  45. cat > conftest.c <<EOF
  46. void foo() {}
  47. EOF
  48. if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS
  49. -S -o conftest.s conftest.c >/dev/null]) \
  50. && grep -q .note.GNU-stack conftest.s \
  51. && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack
  52. -c -o conftest.o conftest.s >/dev/null])
  53. then
  54. cl_cv_as_noexecstack=yes
  55. else
  56. cl_cv_as_noexecstack=no
  57. fi
  58. rm -f conftest*])
  59. if test "$cl_cv_as_noexecstack" = yes; then
  60. ASMFLAGS="$ASMFLAGS -Wa,--noexecstack"
  61. fi
  62. AC_SUBST(ASMFLAGS)
  63. ])
  64. dnl Checks whether the compiler supports __attribute__((flatten)).
  65. AC_DEFUN([CL_ATTRIBUTE_FLATTEN],[
  66. AC_REQUIRE([AC_PROG_CXX])
  67. AC_CACHE_CHECK([whether the compiler supports __attribute__((flatten))], cl_cv_have_attr_flatten, [dnl
  68. cat > conftest.cc <<EOF
  69. void f() __attribute__((flatten));
  70. EOF
  71. AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -c conftest.cc >/dev/null 2>conftest.out)
  72. if grep -i "warning" conftest.out > /dev/null; then
  73. cl_cv_have_attr_flatten=no
  74. else
  75. cl_cv_have_attr_flatten=yes
  76. fi
  77. rm -f conftest*
  78. ])
  79. if test $cl_cv_have_attr_flatten = yes; then
  80. AC_DEFINE(CL_HAVE_ATTRIBUTE_FLATTEN)
  81. fi
  82. ])