------------------------------------------------------------ revno: 12526 revision-id: squid3@treenet.co.nz-20130418052816-e332i43c6kc93my2 parent: squid3@treenet.co.nz-20130402124212-711cndqpa1gnidpz fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=3674 author: Francesco Chemolli committer: Amos Jeffries branch nick: 3.3 timestamp: Wed 2013-04-17 23:28:16 -0600 message: Bug 3674: Improve compiler detection, better support warnings-as-errors on clang ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20130418052816-e332i43c6kc93my2 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 588c00cab74efbd54e5669c541167ef54257e475 # timestamp: 2013-04-18 05:35:40 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20130402124212-\ # 711cndqpa1gnidpz # # Begin patch === modified file 'acinclude/compiler-flags.m4' --- acinclude/compiler-flags.m4 2012-05-11 05:45:20 +0000 +++ acinclude/compiler-flags.m4 2013-04-18 05:28:16 +0000 @@ -81,15 +81,12 @@ # - sunstudio # - none (undetected) # -AC_DEFUN([SQUID_CC_GUESS_VARIANT], [ +AC_DEFUN([SQUID_CC_GUESS_VARIANT], [ AC_CACHE_CHECK([what kind of compiler we're using],[squid_cv_compiler], [ AC_REQUIRE([AC_PROG_CC]) - if test "$GCC" = "yes" ; then - squid_cv_compiler="gcc" - fi dnl repeat the next block for each compiler, changing the - dnl preprocessor definition type so that it depends on platform-specific + dnl preprocessor definition so that it depends on platform-specific dnl predefined macros dnl SunPro CC if test -z "$squid_cv_compiler" ; then @@ -109,12 +106,39 @@ #endif ]])],[squid_cv_compiler="icc"],[]) fi + dnl clang + if test -z "$squid_cv_compiler" ; then + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#if !defined(__clang__) +#error "not clang" +#endif + ]])],[squid_cv_compiler="clang"],[]) + fi + dnl microsoft visual c++ + if test -z "$squid_cv_compiler" ; then + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#if !defined(_MSC_VER) +#error "not Microsoft VC++" +#endif + ]])],[squid_cv_compiler="msvc"],[]) + fi + dnl gcc. MUST BE LAST as many other compilers also define it for compatibility + if test -z "$squid_cv_compiler" ; then + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#if !defined(__GNUC__) +#error "not gcc" +#endif + ]])],[squid_cv_compiler="gcc"],[]) + fi dnl end of block to be repeated if test -z "$squid_cv_compiler" ; then squid_cv_compiler="none" fi - ]) - ]) + ]) dnl AC_CACHE_CHECK + ]) dnl AC_DEFUN # define the flag to use to have the compiler treat warnings as errors # requirs SQUID_CC_GUESS_VARIANT @@ -145,6 +169,13 @@ squid_cv_cc_option_optimize="-fast" squid_cv_cc_arg_pipe="" ;; + clang) + squid_cv_cxx_option_werror="-Werror -Wno-error=parentheses-equality" + squid_cv_cc_option_werror="$squid_cv_cxx_option_werror" + squid_cv_cc_option_wall="-Wall" + squid_cv_cc_option_optimize="-O2" + squid_cv_cc_arg_pipe="" + ;; icc) squid_cv_cxx_option_werror="-Werror" squid_cv_cc_option_werror="$squid_cv_cxx_option_werror" === modified file 'configure.ac' --- configure.ac 2013-03-12 10:16:57 +0000 +++ configure.ac 2013-04-18 05:28:16 +0000 @@ -259,7 +259,7 @@ ]) AC_SUBST(DEFAULT_SWAP_DIR) -if test "x$GCC" = "xyes"; then +if test "$squid_cv_compiler" = "gcc"; then GCCVER=`$CC -v 2>&1 | awk '$2 == "version" {print $3}'` GCCVER2=`echo $GCCVER | awk '{print $1 * 100}'` case "$host" in @@ -276,7 +276,7 @@ dnl Set Default CFLAGS if test "x$PRESET_CFLAGS" = "x"; then - if test "x$GCC" = "xyes"; then + if test "$squid_cv_compiler" = "gcc"; then case "$host" in *-sun-sunos*) # sunos has too many warnings for this to be useful @@ -310,7 +310,7 @@ fi dnl set squid required flags -if test "x$GCC" = "xyes"; then +if test "$squid_cv_compiler" = "gcc"; then case "$squid_host_os" in mingw) dnl Guido Serassio (serassio@squid-cache.org) 20070811