From 44404f394517f89a0bebb1aaace6e64ad79d2817 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 26 May 2011 17:29:33 -0400 Subject: [PATCH] Adjust configure to use "+Olibmerrno" with HP-UX C compiler, if possible. This is reported to be necessary on some versions of that OS. In service of this, cause PGAC_PROG_CC_CFLAGS_OPT to reject switches that result in compiler warnings, since on yet other versions of that OS, the switch does nothing except provoke a warning. Report and patch by Ibrar Ahmed, further tweaking by me. --- config/c-compiler.m4 | 3 ++ configure | 87 ++++++++++++++++++++++++++++++++++++++++++++ configure.in | 4 ++ 3 files changed, 94 insertions(+) diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 9c069f4c92..9398ca6c47 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -130,9 +130,12 @@ AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT], AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar], [pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS $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="$pgac_save_CFLAGS"]) if test x"$Ac_cachevar" = x"yes"; then CFLAGS="$CFLAGS $1" diff --git a/configure b/configure index 3b23c46293..e73315721b 100755 --- a/configure +++ b/configure @@ -4010,6 +4010,8 @@ if test "${pgac_cv_prog_cc_cflags__Wdeclaration_after_statement+set}" = set; the else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wdeclaration-after-statement" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4052,6 +4054,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wdeclaration_after_statement" >&5 @@ -4067,6 +4070,8 @@ if test "${pgac_cv_prog_cc_cflags__Wendif_labels+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wendif-labels" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4109,6 +4114,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wendif_labels" >&5 @@ -4125,6 +4131,8 @@ if test "${pgac_cv_prog_cc_cflags__Wformat_security+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wformat-security" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4167,6 +4175,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wformat_security" >&5 @@ -4183,6 +4192,8 @@ if test "${pgac_cv_prog_cc_cflags__fno_strict_aliasing+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4225,6 +4236,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fno_strict_aliasing" >&5 @@ -4241,6 +4253,8 @@ if test "${pgac_cv_prog_cc_cflags__fwrapv+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fwrapv" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4283,6 +4297,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fwrapv" >&5 @@ -4301,6 +4316,8 @@ if test "${pgac_cv_prog_cc_cflags__mp1+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -mp1" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4343,6 +4360,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__mp1" >&5 @@ -4359,6 +4377,8 @@ if test "${pgac_cv_prog_cc_cflags__fno_strict_aliasing+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4401,6 +4421,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fno_strict_aliasing" >&5 @@ -4418,6 +4439,8 @@ if test "${pgac_cv_prog_cc_cflags__qnoansialias+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -qnoansialias" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4460,6 +4483,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__qnoansialias" >&5 @@ -4468,6 +4492,69 @@ if test x"$pgac_cv_prog_cc_cflags__qnoansialias" = x"yes"; then CFLAGS="$CFLAGS -qnoansialias" fi +elif test "$PORTNAME" = "hpux"; then + # On some versions of HP-UX, libm functions do not set errno by default. + # Fix that by using +Olibmerrno if the compiler recognizes it. + { $as_echo "$as_me:$LINENO: checking whether $CC supports +Olibmerrno" >&5 +$as_echo_n "checking whether $CC supports +Olibmerrno... " >&6; } +if test "${pgac_cv_prog_cc_cflags_pOlibmerrno+set}" = set; then + $as_echo_n "(cached) " >&6 +else + pgac_save_CFLAGS=$CFLAGS +CFLAGS="$pgac_save_CFLAGS +Olibmerrno" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + pgac_cv_prog_cc_cflags_pOlibmerrno=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + pgac_cv_prog_cc_cflags_pOlibmerrno=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag +CFLAGS="$pgac_save_CFLAGS" +fi +{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags_pOlibmerrno" >&5 +$as_echo "$pgac_cv_prog_cc_cflags_pOlibmerrno" >&6; } +if test x"$pgac_cv_prog_cc_cflags_pOlibmerrno" = x"yes"; then + CFLAGS="$CFLAGS +Olibmerrno" +fi + fi # supply -g if --enable-debug diff --git a/configure.in b/configure.in index 76c1a887a3..a752618bf5 100644 --- a/configure.in +++ b/configure.in @@ -445,6 +445,10 @@ elif test "$ICC" = yes; then elif test "$PORTNAME" = "aix"; then # AIX's xlc has to have strict aliasing turned off too PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias]) +elif test "$PORTNAME" = "hpux"; then + # On some versions of HP-UX, libm functions do not set errno by default. + # Fix that by using +Olibmerrno if the compiler recognizes it. + PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno]) fi # supply -g if --enable-debug -- 2.40.0