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
index 02a905bfb55b81bc80534db4bf791ab1259d574f..1d664a42d7cd6587de37c43c7727733df38ffdf4 100755 (executable)
TAS
GCC
CPP
+CFLAGS_SL
BITCODE_CXXFLAGS
BITCODE_CFLAGS
CFLAGS_VECTOR
fi
-CFLAGS_VECTOR=$CFLAGS_VECTOR
# Determine flags used to emit bitcode for JIT inlining. Need to test
BITCODE_CFLAGS="$BITCODE_CFLAGS $user_BITCODE_CFLAGS"
BITCODE_CXXFLAGS="$BITCODE_CXXFLAGS $user_BITCODE_CXXFLAGS"
-BITCODE_CFLAGS=$BITCODE_CFLAGS
-BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
+
+
+# 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
index 88d3a59506f270c59ed6eaf997b0e0ce6bb69aba..50f4b26163df8a1e8c907b09ec06df0e676fcef3 100644 (file)
PGAC_PROG_CXX_CFLAGS_OPT([+Olibmerrno])
fi
-AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
+AC_SUBST(CFLAGS_VECTOR)
# Determine flags used to emit bitcode for JIT inlining. Need to test
# for behaviour changing compiler flags, to keep compatibility with
BITCODE_CFLAGS="$BITCODE_CFLAGS $user_BITCODE_CFLAGS"
BITCODE_CXXFLAGS="$BITCODE_CXXFLAGS $user_BITCODE_CXXFLAGS"
-AC_SUBST(BITCODE_CFLAGS, $BITCODE_CFLAGS)
-AC_SUBST(BITCODE_CXXFLAGS, $BITCODE_CXXFLAGS)
+AC_SUBST(BITCODE_CFLAGS)
+AC_SUBST(BITCODE_CXXFLAGS)
+
+# 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
# (note, we're not checking that for CXX, which is optional)
index 2d21068183b9125a712a0edecd9916e3dcf59764..05b66380e0c0288f55b147cf9ed4745d0ce453b3 100644 (file)
SUN_STUDIO_CC = @SUN_STUDIO_CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
+CFLAGS_SL = @CFLAGS_SL@
CFLAGS_VECTOR = @CFLAGS_VECTOR@
CFLAGS_SSE42 = @CFLAGS_SSE42@
CFLAGS_ARMV8_CRC32C = @CFLAGS_ARMV8_CRC32C@
index f274d802b1e1f888ec9dcef4ec1d78bebd03b3b8..81089d6257bf1a24c9c3b8c17b59257e758912c2 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 c462e2fd584fc8e1b4e0b8a8ccc8127975690b71..75db21ba14501b6d82068f8e4887ac7787817088 100644 (file)
@@ -5,8 +5,6 @@ rpath = -Wl,-R'$(rpathdir)'
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 c871fb0c7ef60ff77ad85bcfb872a25889b91be3..7e18770d8969c3b927c8dc3317eda94fa4d46b3d 100644 (file)
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 ac58fe45de0c07b9fe814f09b836792696bb6d45..645f73aa2b74595b7f7cddd3dbe8d89f0656b49d 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 15695fb65c730c80e70de0cdd49e3ccc939894f8..6f9cb1d45d1683545da6fbfad8809f233a475c7b 100644 (file)
@@ -5,8 +5,6 @@ rpath = -Wl,-R'$(rpathdir)'
DLSUFFIX = .so
-CFLAGS_SL = -fPIC -DPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
index 15695fb65c730c80e70de0cdd49e3ccc939894f8..6f9cb1d45d1683545da6fbfad8809f233a475c7b 100644 (file)
@@ -5,8 +5,6 @@ rpath = -Wl,-R'$(rpathdir)'
DLSUFFIX = .so
-CFLAGS_SL = -fPIC -DPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
index a7f5652f0ca9fcc6b9f284bdcf17bf1c5ecc80f2..62a6c01c3a39ede4a390e23944e30ed055794802 100644 (file)
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 3dea11e5c2880e24a390a66af512857412348b76..8a7d6fff3e528a32f394ee2e265384cc2b28348d 100644 (file)
@@ -12,7 +12,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 999cd359457cd269f75e2ddeb0c0b66c55f80dbd..cec240d27b9a2bc6a18e9c53f20ed70c23625c1a 100644 (file)
+# 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
FORCE_DISABLE_RESTRICT=yes
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)
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 a82d5a494c9fd3983be07d594365344d7080695e..41fa4a1aba1546fbe68ed90cf9970fc5074fd1c3 100644 (file)
if test x"$PREFERRED_SEMAPHORES" = x"" ; then
PREFERRED_SEMAPHORES=UNNAMED_POSIX
fi
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
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 e39290845ad5d205ec23598a542aff57b5076c5b..ec3302c4a223fd6f946e952bc589d8684976fa8d 100644 (file)
# This is also required for ppoll(2), and perhaps other things
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)
# 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)
+# src/template/openbsd
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
index e07b9a0a8d6145ee5e433704e91abf4424cc0688..f88b1cdad37f85039eabf288ae6e44c9ac3fc44c 100644 (file)
+# 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 7da9719acbdacace04dac0cfea3b6a1e6ac2c345..1380d16548ce494f212bed93d517d7e53cd75548 100644 (file)
# 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