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[email protected]
TAS
GCC
CPP
+CFLAGS_SL
CFLAGS_VECTOR
SUN_STUDIO_CC
OBJEXT
fi
-CFLAGS_VECTOR=$CFLAGS_VECTOR
# supply -g if --enable-debug
# 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; }
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
# 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;],
GCC = @GCC@
SUN_STUDIO_CC = @SUN_STUDIO_CC@
CFLAGS = @CFLAGS@
+CFLAGS_SL = @CFLAGS_SL@
CFLAGS_VECTOR = @CFLAGS_VECTOR@
# Kind-of compilers
AROPT = crs
DLSUFFIX = .dll
-CFLAGS_SL =
override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT)
DLSUFFIX = .so
-CFLAGS_SL = -fPIC -DPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
else
DLSUFFIX = .sl
endif
-ifeq ($(GCC), yes)
- CFLAGS_SL = -fPIC
-else
- CFLAGS_SL = +Z
-endif
# Rule for building a shared library from a single .o file
%$(DLSUFFIX): %.o
DLSUFFIX = .so
-CFLAGS_SL = -fPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
DLSUFFIX = .so
-CFLAGS_SL = -fPIC -DPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
DLSUFFIX = .so
-CFLAGS_SL = -fPIC -DPIC
-
# Rule for building a shared library from a single .o file
%.so: %.o
AROPT = crs
DLSUFFIX = .so
-CFLAGS_SL =
+
rpath = -rpath '$(rpathdir)'
# Rule for building a shared library from a single .o file
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
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
CFLAGS += $(PTHREAD_CFLAGS)
DLSUFFIX = .so
-ifeq ($(GCC), yes)
-CFLAGS_SL = -fpic
-else
-CFLAGS_SL = -K PIC
-endif
+
ifeq ($(GCC), yes)
SO_FLAGS = -shared
else
AROPT = crs
DLSUFFIX = .dll
-CFLAGS_SL =
ifneq (,$(findstring backend,$(subdir)))
ifeq (,$(findstring conversion_procs,$(subdir)))
+# 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
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
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,
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
# 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
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
# 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"
# 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"
+# src/template/openbsd
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL="-fPIC -DPIC"
CC="$CC -std"
CFLAGS="-O -ieee"
fi
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+# 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
+# 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
+# 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.
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"
# 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