]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Select CFLAGS_SL at configure time, not in platform-specific Makefiles.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Oct 2019 16:32:36 +0000 (12:32 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Oct 2019 16:32:36 +0000 (12:32 -0400)
Move the platform-dependent logic that sets CFLAGS_SL from
src/makefiles/Makefile.foo to src/template/foo, so that the value
is determined at configure time and thus is available while running
configure's tests.

On a couple of platforms this might save a few microseconds of build
time by eliminating a test that make otherwise has to do over and over.
Otherwise it's pretty much a wash for build purposes; in particular,
this makes no difference to anyone who might be overriding CFLAGS_SL
via a make option.

This patch in itself does nothing with the value and thus should not
change any behavior, though you'll probably have to re-run configure
to get a correctly updated Makefile.global.  We'll use the new
configure variable in a follow-on patch.

Per gripe from Kyotaro Horiguchi.  Back-patch to all supported branches,
because the follow-on patch is a portability bug fix.

Discussion: https://postgr.es/m/20191010.144533.263180400.horikyota.ntt@gmail.com

25 files changed:
configure
configure.in
src/Makefile.global.in
src/makefiles/Makefile.cygwin
src/makefiles/Makefile.freebsd
src/makefiles/Makefile.hpux
src/makefiles/Makefile.linux
src/makefiles/Makefile.netbsd
src/makefiles/Makefile.openbsd
src/makefiles/Makefile.sco
src/makefiles/Makefile.solaris
src/makefiles/Makefile.unixware
src/makefiles/Makefile.win32
src/template/aix
src/template/cygwin
src/template/darwin
src/template/freebsd
src/template/hpux
src/template/linux
src/template/netbsd
src/template/openbsd
src/template/sco
src/template/solaris
src/template/unixware
src/template/win32

index 5aff38ce984003d5a9e156e87df26ae439395347..4fb66501733009e88ac2a696b1d2f991f8add3cd 100755 (executable)
--- a/configure
+++ b/configure
@@ -725,6 +725,7 @@ autodepend
 TAS
 GCC
 CPP
+CFLAGS_SL
 CFLAGS_VECTOR
 SUN_STUDIO_CC
 OBJEXT
@@ -5039,7 +5040,6 @@ fi
 
 fi
 
-CFLAGS_VECTOR=$CFLAGS_VECTOR
 
 
 # supply -g if --enable-debug
@@ -5078,6 +5078,9 @@ fi
 # the automatic additions.
 CFLAGS="$CFLAGS $user_CFLAGS"
 
+# The template file must set up CFLAGS_SL; we don't support user override
+
+
 # Check if the compiler still works with the final flag settings
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler still works" >&5
 $as_echo_n "checking whether the C compiler still works... " >&6; }
index ffc782b44e2459fa531d89fcd9aec21d97e2fbb3..61bd57e237809bd9c0a7966406c12acd10da52d0 100644 (file)
@@ -480,7 +480,7 @@ elif test "$PORTNAME" = "hpux"; then
   PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno])
 fi
 
-AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
+AC_SUBST(CFLAGS_VECTOR)
 
 # supply -g if --enable-debug
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
@@ -517,6 +517,9 @@ fi
 # the automatic additions.
 CFLAGS="$CFLAGS $user_CFLAGS"
 
+# The template file must set up CFLAGS_SL; we don't support user override
+AC_SUBST(CFLAGS_SL)
+
 # Check if the compiler still works with the final flag settings
 AC_MSG_CHECKING([whether the C compiler still works])
 AC_TRY_LINK([], [return 0;],
index d5ecc16baa000a4f7161e24728230ac03adef9c6..7caaf7018e13287a62e6b9a8742e463b853cabc2 100644 (file)
@@ -240,6 +240,7 @@ CC = @CC@
 GCC = @GCC@
 SUN_STUDIO_CC = @SUN_STUDIO_CC@
 CFLAGS = @CFLAGS@
+CFLAGS_SL = @CFLAGS_SL@
 CFLAGS_VECTOR = @CFLAGS_VECTOR@
 CFLAGS_SSE42 = @CFLAGS_SSE42@
 
index 2d57b4b0891cf1ff0db7ce52dd7f78bf5bfabac9..df22d9fd9934940e2a301829385126f7002efb1c 100644 (file)
@@ -12,7 +12,6 @@ LIBS:=$(filter-out -lm -lc, $(LIBS))
 
 AROPT = crs
 DLSUFFIX = .dll
-CFLAGS_SL =
 
 override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT)
 
index 5008c96b3f5a5e96465f6fb81e09606b1f9f7937..8e5bc9c6ec99ca23310a2667347d108abaeda13c 100644 (file)
@@ -7,8 +7,6 @@ endif
 
 DLSUFFIX = .so
 
-CFLAGS_SL = -fPIC -DPIC
-
 # extra stuff for $(with_temp_install)
 # we need this to get LD_LIBRARY_PATH searched ahead of the compiled-in
 # rpath, if no DT_RUNPATH is present in the executable. The conditions
index aef035e8463420a7dc8e6f3e77187b68b3e11f3a..bb76afc9b8fdf88c35a94249a14a6dfaadcd433c 100644 (file)
@@ -37,11 +37,6 @@ ifeq ($(host_cpu), ia64)
 else
    DLSUFFIX = .sl
 endif
-ifeq ($(GCC), yes)
-   CFLAGS_SL = -fPIC
-else
-   CFLAGS_SL = +Z
-endif
 
 # env var name to use in place of LD_LIBRARY_PATH
 ld_library_path_var = SHLIB_PATH
index f4f091caef59362c6edbe797d6cc39e6e8a1e43c..c6d0546e4d50fb9f048d2faebafd4f048d52a5a9 100644 (file)
@@ -7,8 +7,6 @@ rpath = -Wl,-rpath,'$(rpathdir)',--enable-new-dtags
 
 DLSUFFIX = .so
 
-CFLAGS_SL = -fPIC
-
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
index 43841c15973b0c0b594fc2333f2bbdea4bcd71ae..c2a3cce4f01a15901da5c6c9d7b96cb43f5dc44a 100644 (file)
@@ -9,8 +9,6 @@ endif
 
 DLSUFFIX = .so
 
-CFLAGS_SL = -fPIC -DPIC
-
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
index d8fde49d5c8d95ee73d4c507d12a50ac94bbb7c9..0c5a7b4eb357960e63bf19cd79bba44c90b39e04 100644 (file)
@@ -7,8 +7,6 @@ endif
 
 DLSUFFIX = .so
 
-CFLAGS_SL = -fPIC -DPIC
-
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
index 993861570ac7e56f6a86b56199080f33023a7acf..49c6693f148d879819b3273bbe11684a42637ef9 100644 (file)
@@ -2,11 +2,7 @@ AROPT = cr
 export_dynamic = -Wl,-Bexport
 
 DLSUFFIX = .so
-ifeq ($(GCC), yes)
-CFLAGS_SL = -fpic
-else
-CFLAGS_SL = -K PIC
-endif
+
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
index e459de30cf4933869dadeac4a443ae9c165082ed..a05c0e0d3d224e0f8fde589fe68ce7d665ddddee 100644 (file)
@@ -10,11 +10,7 @@ rpath = -Wl,-R'$(rpathdir)'
 endif
 
 DLSUFFIX = .so
-ifeq ($(GCC), yes)
-CFLAGS_SL = -fPIC
-else
-CFLAGS_SL = -KPIC
-endif
+
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
index a52717b2688e6911965cf211011dfcb06bbcb497..3d177b76e97cb036f093e03f1ce04e80e47bce99 100644 (file)
@@ -17,11 +17,7 @@ endif
 CFLAGS += $(PTHREAD_CFLAGS)
 
 DLSUFFIX = .so
-ifeq ($(GCC), yes)
-CFLAGS_SL = -fpic
-else
-CFLAGS_SL = -K PIC
-endif
+
 ifeq ($(GCC), yes)
 SO_FLAGS = -shared
 else
index 3c8024a715fa76a31d4094dd3db2345ec4b1d6d1..d02dfd2b18734b17a3d2f6b87400de2c119ac5aa 100644 (file)
@@ -13,7 +13,6 @@ override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT)
 
 AROPT = crs
 DLSUFFIX = .dll
-CFLAGS_SL =
 
 ifneq (,$(findstring backend,$(subdir)))
 ifeq (,$(findstring conversion_procs,$(subdir)))
index 230d4613f3cebeffae17a22a0066e0f0827e2a05..f7954123e1bd5028b5c354a8211b16ac71dee811 100644 (file)
@@ -1,3 +1,5 @@
+# src/template/aix
+
 # Set default options if using xlc.  This formerly included -qsrcmsg, but that
 # option elicits internal compiler errors from xlc v16.1.0.  Note: configure
 # will add -qnoansialias if the compiler accepts it, even if user specifies a
@@ -13,6 +15,9 @@ if test "$GCC" != yes ; then
   esac
 fi
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
 # Native memset() is faster, tested on:
 #      AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
 #      AIX 5.3 ML3, gcc 4.0.1
index b6ea0ded522c5a8091808526cae9c6ba04d52df8..79a108145ff0b0ec9cd133e38952b48d663724b5 100644 (file)
@@ -2,6 +2,9 @@
 
 SRCH_LIB="/usr/local/lib"
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
 # --allow-multiple-definition is required to link pg_dump because it finds
 # pg_toupper() etc. in both libpq and pgport
 # we'd prefer to use --disable-auto-import to match MSVC linking behavior,
index c05adca0bfbec7bba7a6551d4edf0ea0bf932d49..f4d4e9d7cf80d5c55e0da63ece81e4ccf69e66d7 100644 (file)
@@ -16,6 +16,9 @@ if test x"$PG_SYSROOT" != x"" ; then
   fi
 fi
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
 # Select appropriate semaphore support.  Darwin 6.0 (macOS 10.2) and up
 # support System V semaphores; before that we have to use named POSIX
 # semaphores, which are less good for our purposes because they eat a
index 1e04fece42b585de3a1bc83bd5f3385a4e4fff1b..bf16e1bf0728fadccbc6760f0bd9b3c452ee95fa 100644 (file)
@@ -1,5 +1,8 @@
 # src/template/freebsd
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
+
 case $host_cpu in
   alpha*)   CFLAGS="-O";;  # alpha has problems with -O2
 esac
index 79d3475664e6ddf4313f5b1e69ed9adb76d83d53..50fff80c53012e788c9ba0fe9050cf7339e9cba8 100644 (file)
@@ -8,6 +8,13 @@ if test "$GCC" != yes ; then
   CFLAGS="+O2"
 fi
 
+# Extra CFLAGS for code that will go into a shared library
+if test "$GCC" = yes ; then
+  CFLAGS_SL="-fPIC"
+else
+  CFLAGS_SL="+Z"
+fi
+
 # Pick right test-and-set (TAS) code.  We need out-of-line assembler
 # when not using gcc.
 case $host in
index 3eb5ad2428fdefcbd41c5dda6fa87c708a3abcf1..09ab6af86cb15be2bca727821b49b70b3df0b4f9 100644 (file)
@@ -3,6 +3,9 @@
 # Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise
 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC"
+
 # If --enable-profiling is specified, we need -DLINUX_PROFILE
 PLATFORM_PROFILE_FLAGS="-DLINUX_PROFILE"
 
index 198697723dfb913facaaae88d452fa5f60421743..d97f995c748dab2234406ec6a4d2b5ae2d1daca5 100644 (file)
@@ -1,2 +1,5 @@
 # src/template/netbsd
 # tools/thread/thread_test must be run
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..365268c48978ebe9588e46efe47e8e01c6e7ae25 100644 (file)
@@ -0,0 +1,4 @@
+# src/template/openbsd
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
index 9a736da8be74b4d7224f2ce47c9fed72222a1a72..e216f1e7aa933ac73914f4b67c4f5fdd6b0a19ae 100644 (file)
@@ -1 +1,10 @@
+# src/template/sco
+
 CC="$CC -b elf"
+
+# Extra CFLAGS for code that will go into a shared library
+if test "$GCC" = yes ; then
+  CFLAGS_SL="-fpic"
+else
+  CFLAGS_SL="-K PIC"
+fi
index e07b9a0a8d6145ee5e433704e91abf4424cc0688..f88b1cdad37f85039eabf288ae6e44c9ac3fc44c 100644 (file)
@@ -1,3 +1,12 @@
+# src/template/solaris
+
+# Extra CFLAGS for code that will go into a shared library
+if test "$GCC" = yes ; then
+  CFLAGS_SL="-fPIC"
+else
+  CFLAGS_SL="-KPIC"
+fi
+
 if test "$SUN_STUDIO_CC" = yes ; then
   CC="$CC -Xa"                 # relaxed ISO C mode
   CFLAGS="-v"                  # -v is like gcc -Wall
index d08fca1e6bee78f3e24f2f642bd941c3dc0265dd..006c4abe4997fee98dc3a4429ebbe6e027cd00ad 100644 (file)
@@ -1,3 +1,5 @@
+# src/template/unixware
+
 if test "$GCC" != yes; then
   # The -Kno_host is for a bug in the compiler.  See -hackers
   # discussion on 7-8/Aug/2003.
@@ -37,5 +39,12 @@ __EOF__
 
 fi
 
+# Extra CFLAGS for code that will go into a shared library
+if test "$GCC" = yes ; then
+  CFLAGS_SL="-fpic"
+else
+  CFLAGS_SL="-K PIC"
+fi
+
 # Unixware's ldap library reportedly needs these too
 EXTRA_LDAP_LIBS="-llber -lresolv"
index 7da9719acbdacace04dac0cfea3b6a1e6ac2c345..1380d16548ce494f212bed93d517d7e53cd75548 100644 (file)
@@ -1,5 +1,8 @@
 # src/template/win32
 
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
 # --allow-multiple-definition is required to link pg_dump because it finds
 # pg_toupper() etc. in both libpq and pgport
 # --disable-auto-import is to ensure we get MSVC-like linking behavior