On 2013-04-26 12:57:09 -0700, Jeff Davis wrote:
> I updated the patch and split it into two parts (attached).
> The second patch adds the configure-time check for the right
> compilation flags, and uses them when compiling checksum.c. I
> called the new variable CFLAGS_EXTRA, for lack of a better idea,
> so feel free to come up with a new name. It doesn't check for, or
> use, -msse4.1, but that can be specified by the user by
> configuring with CFLAGS_EXTRA="-msse4.1".
CFLAGS_VECTORIZATION? EXTRA sounds to generic to me.
> --- a/config/c-compiler.m4
> +++ b/config/c-compiler.m4
> @@ -242,6 +242,30 @@ undefine([Ac_cachevar])dnl
>
>
>
> +# PGAC_PROG_CC_CFLAGS_EXTRA_OPT
> +# -----------------------
> +# Given a string, check if the compiler supports the string as a
> +# command-line option. If it does, add the string to CFLAGS_EXTRA.
> +AC_DEFUN([PGAC_PROG_CC_CFLAGS_EXTRA_OPT],
> +[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_extra_$1])])dnl
> +AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
> +[pgac_save_CFLAGS_EXTRA=$CFLAGS_EXTRA
> +CFLAGS_EXTRA="$pgac_save_CFLAGS_EXTRA $1"
> +ac_save_c_werror_flag=$ac_c_werror_flag
> +ac_c_werror_flag=yes
> +_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
> + [Ac_cachevar=yes],
> + [Ac_cachevar=no])
> +ac_c_werror_flag=$ac_save_c_werror_flag
> +CFLAGS_EXTRA="$pgac_save_CFLAGS_EXTRA"])
> +if test x"$Ac_cachevar" = x"yes"; then
> + CFLAGS_EXTRA="$CFLAGS_EXTRA $1"
> +fi
> +undefine([Ac_cachevar])dnl
> +])# PGAC_PROG_CC_CFLAGS_EXTRA_OPT
I think it would be better to have a PGAC_PROG_CC_VAR_OPT or so which
assigns the flag to some passed variable name. Then we can reuse it for
different vars and I have the feeling those will come. And having a
CFLAGS_VECTOR_OPT would just be stupid ;)
Greetings,
Andres Freund
-- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services