Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1p0H-0007ah-3Y for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 11:16:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1p0F-0002oo-TK for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 11:16:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1p0F-0002lO-G3 for pgsql-hackers@lists.postgresql.org; Tue, 19 Jan 2021 11:16:51 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l1p0B-0001E4-8T for pgsql-hackers@lists.postgresql.org; Tue, 19 Jan 2021 11:16:50 +0000 Received: by mail-io1-xd32.google.com with SMTP id h11so9721349ioh.11 for ; Tue, 19 Jan 2021 03:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IYv9Ri5qdYaPSRPi47HXOU59Znl6WVg9Rd+xaAZI/+E=; b=E5sRX9ISzwxU8L6oCyrceY0Azu2yDOzoGrg6I028eKdMMT1/WqPcrc0OWbHj1A0hLE L7dv5fxZnADxWP27AboooXOLLE/jqRdqM1pOH7BpQ32GFxIB1ZA2Tr1O08PIKrI3K1Dy LHSnCwiKZvYsqanG1hbwp1djWujpVyerNzZh1XiYfy0UgoyKT+iOYoScFGqFXvCA3kGO geX0UGYXMAgw8m/XuBP5IzDSixdRpmpQhLMqsbzbFnGMGwD2P6Qmhy5qqilTsEfdqqL+ zdUHOEjVBjkQRfG7Izgajvp21cUKc92nnZ2msFpLQI4tBf9AoJ/zf6b9Zm65Il0EORAS cvLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IYv9Ri5qdYaPSRPi47HXOU59Znl6WVg9Rd+xaAZI/+E=; b=Qbfl8OsXibwm9Rsa4BWYA3j87lz/bYPRomTMtEQTYR8oZwAUhm8LXTdmMvpV4oirDF uW8CdHwAYGB2+u18q1XtjXXfjVVJoz/xdlry0hLQkbrQGFrZ0IfoTujaYBrOGpiTh6iW Ji1VEC2Z6leaKTUig9mn3N2gppwrpBWk7TDOdEUYP3YC7uft2yp/rlum2L7etfLK2NND 2ozFJcPQOrQ9esbXZ5TGzFxyZYF/+ulF/pJRU6YOSchqIR43LqSCY8VDuzPO/oK6Ta7o fafmmXfcO6GRReHYH4/l3ia6XKE9x9UdRZ9jhyNYQEwLWoD/iwZCk+m50Ps6x1Kfuj9R axBw== X-Gm-Message-State: AOAM533JMiWv7zholYgSQkppcGt3hquYsBhA37/5p+S1RpL68gJ+udK5 8RAHZFdJYhmGBH8y6evWfC3lbcnpz0epmA== X-Google-Smtp-Source: ABdhPJzBjrysj64vv/qVZT0hPR2/s+HI+RmHtr8RyovWw/v3iiodxQSeeWGld5lbLqizjUECg0hNfA== X-Received: by 2002:a92:d3c7:: with SMTP id c7mr2888953ilh.137.1611055005759; Tue, 19 Jan 2021 03:16:45 -0800 (PST) Received: from MacBook-Pro.localdomain (97-118-190-247.hlrn.qwest.net. [97.118.190.247]) by smtp.gmail.com with ESMTPSA id s8sm10002735ilv.76.2021.01.19.03.16.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jan 2021 03:16:45 -0800 (PST) From: James Hilliard To: pgsql-hackers@lists.postgresql.org Cc: Tom Lane , Sergey Shinderuk , Thomas Munro , James Hilliard Subject: [PATCH 1/1] Fix detection of pwritev support for OSX. Date: Tue, 19 Jan 2021 04:16:25 -0700 Message-Id: <20210119111625.20435-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Fixes: gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I../../../../src/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -c -o fd.o fd.c fd.c:3661:10: warning: 'pwritev' is only available on macOS 11.0 or newer [-Wunguarded-availability-new] part = pg_pwritev(fd, iov, iovcnt, offset); ^~~~~~~~~~ ../../../../src/include/port/pg_iovec.h:49:20: note: expanded from macro 'pg_pwritev' ^~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/sys/uio.h:104:9: note: 'pwritev' has been marked as being introduced in macOS 11.0 here, but the deployment target is macOS 10.15.0 ssize_t pwritev(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(pwritev) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)); ^ fd.c:3661:10: note: enclose 'pwritev' in a __builtin_available check to silence this warning part = pg_pwritev(fd, iov, iovcnt, offset); ^~~~~~~~~~ ../../../../src/include/port/pg_iovec.h:49:20: note: expanded from macro 'pg_pwritev' ^~~~~~~ 1 warning generated. This results in a runtime error: running bootstrap script ... dyld: lazy symbol binding failed: Symbol not found: _pwritev Referenced from: /usr/local/pgsql/bin/postgres Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: _pwritev Referenced from: /usr/local/pgsql/bin/postgres Expected in: /usr/lib/libSystem.B.dylib child process was terminated by signal 6: Abort trap: 6 To fix this we set -Werror=unguarded-availability-new so that a compile test for pwritev will fail if the symbol is unavailable on the requested SDK version. --- configure | 88 ++++++++++++++++++++++++++++++++++++++++++++-------- configure.ac | 19 +++++++++++- 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 8af4b99021..503b0d27e6 100755 --- a/configure +++ b/configure @@ -5373,6 +5373,47 @@ if test x"$pgac_cv_prog_CC_cflags__Werror_vla" = x"yes"; then fi + # Prevent usage of symbols marked as newer than our target. + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Werror=unguarded-availability-new, for CFLAGS" >&5 +$as_echo_n "checking whether ${CC} supports -Werror=unguarded-availability-new, for CFLAGS... " >&6; } +if ${pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new+:} false; then : + $as_echo_n "(cached) " >&6 +else + pgac_save_CFLAGS=$CFLAGS +pgac_save_CC=$CC +CC=${CC} +CFLAGS="${CFLAGS} -Werror=unguarded-availability-new" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new=yes +else + pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new=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" +CC="$pgac_save_CC" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new" >&5 +$as_echo "$pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new" >&6; } +if test x"$pgac_cv_prog_CC_cflags__Werror_unguarded_availability_new" = x"yes"; then + CFLAGS="${CFLAGS} -Werror=unguarded-availability-new" +fi + + # -Wvla is not applicable for C++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wendif-labels, for CFLAGS" >&5 @@ -15715,6 +15756,40 @@ $as_echo "#define HAVE_PS_STRINGS 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pwritev" >&5 +$as_echo_n "checking for pwritev... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_UIO_H +#include +#endif +int +main () +{ +struct iovec *iov; +off_t offset; +offset = 0; +pwritev(0, iov, 0, offset); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_PWRITEV 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : $as_echo "#define HAVE_DLOPEN 1" >>confdefs.h @@ -15871,19 +15946,6 @@ esac fi -ac_fn_c_check_func "$LINENO" "pwritev" "ac_cv_func_pwritev" -if test "x$ac_cv_func_pwritev" = xyes; then : - $as_echo "#define HAVE_PWRITEV 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" pwritev.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS pwritev.$ac_objext" - ;; -esac - -fi - ac_fn_c_check_func "$LINENO" "random" "ac_cv_func_random" if test "x$ac_cv_func_random" = xyes; then : $as_echo "#define HAVE_RANDOM 1" >>confdefs.h diff --git a/configure.ac b/configure.ac index 868a94c9ba..30fa39c859 100644 --- a/configure.ac +++ b/configure.ac @@ -494,6 +494,8 @@ if test "$GCC" = yes -a "$ICC" = no; then AC_SUBST(PERMIT_DECLARATION_AFTER_STATEMENT) # Really don't want VLAs to be used in our dialect of C PGAC_PROG_CC_CFLAGS_OPT([-Werror=vla]) + # Prevent usage of symbols marked as newer than our target. + PGAC_PROG_CC_CFLAGS_OPT([-Werror=unguarded-availability-new]) # -Wvla is not applicable for C++ PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels]) PGAC_PROG_CXX_CFLAGS_OPT([-Wendif-labels]) @@ -1726,6 +1728,22 @@ if test "$pgac_cv_var_PS_STRINGS" = yes ; then AC_DEFINE([HAVE_PS_STRINGS], 1, [Define to 1 if the PS_STRINGS thing exists.]) fi +AC_MSG_CHECKING([for pwritev]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_UIO_H +#include +#endif], +[struct iovec *iov; +off_t offset; +offset = 0; +pwritev(0, iov, 0, offset); +])], [AC_MSG_RESULT(yes) +AC_DEFINE([HAVE_PWRITEV], 1, [Define to 1 if you have the `pwritev' function.])], +[AC_MSG_RESULT(no)]) + AC_REPLACE_FUNCS(m4_normalize([ dlopen explicit_bzero @@ -1739,7 +1757,6 @@ AC_REPLACE_FUNCS(m4_normalize([ pread preadv pwrite - pwritev random srandom strlcat -- 2.30.0