diff --git a/configure b/configure index 65cd7d3fd39dca891eb9385121df7fea6a3b6ca4..7f2a0a0256a71d64ef659ca78c123f54cfe3d678 100755 --- a/configure +++ b/configure @@ -723,6 +723,7 @@ autodepend TAS GCC CPP +CFLAGS_SL CFLAGS_VECTOR SUN_STUDIO_CC OBJEXT @@ -5009,7 +5010,6 @@ fi fi -CFLAGS_VECTOR=$CFLAGS_VECTOR # supply -g if --enable-debug @@ -5048,6 +5048,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; } diff --git a/configure.in b/configure.in index 7b3e15092a0786f4396673b4e2b446815d4349aa..ab640115fb15bf2e90dee685a754de6b3fc6c437 100644 --- a/configure.in +++ b/configure.in @@ -475,7 +475,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 @@ -512,6 +512,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;], diff --git a/src/Makefile.global.in b/src/Makefile.global.in index b4a2f9c8795258f7e5716873281bb2ed0a1d220f..c2ff2d8f1c33c3d86a17ddb91d7c776808801553 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -241,6 +241,7 @@ CC = @CC@ GCC = @GCC@ SUN_STUDIO_CC = @SUN_STUDIO_CC@ CFLAGS = @CFLAGS@ +CFLAGS_SL = @CFLAGS_SL@ CFLAGS_VECTOR = @CFLAGS_VECTOR@ # Kind-of compilers diff --git a/src/makefiles/Makefile.cygwin b/src/makefiles/Makefile.cygwin index 5d70782acd9ac7863dfff8f1ee3b8ad1ce264715..4dd05a7ae5b8b6c237a6cf94e512967ae1cbc90d 100644 --- a/src/makefiles/Makefile.cygwin +++ b/src/makefiles/Makefile.cygwin @@ -12,7 +12,6 @@ LIBS:=$(filter-out -lm -lc, $(LIBS)) AROPT = crs DLSUFFIX = .dll -CFLAGS_SL = override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT) diff --git a/src/makefiles/Makefile.freebsd b/src/makefiles/Makefile.freebsd index 5a98e5a2b0bb0962f3bd38b07c22fa503d5fc9fc..e996f1ab4a4b0caf0b4512a820c283fd73a1c05e 100644 --- a/src/makefiles/Makefile.freebsd +++ b/src/makefiles/Makefile.freebsd @@ -7,8 +7,6 @@ endif DLSUFFIX = .so -CFLAGS_SL = -fPIC -DPIC - # Rule for building a shared library from a single .o file %.so: %.o diff --git a/src/makefiles/Makefile.hpux b/src/makefiles/Makefile.hpux index 1917d61b43601eff4b0524a85d02ca1eb1ba0daa..39ed39aec84d6ef45c09c04a3eb970e3ece5d77c 100644 --- a/src/makefiles/Makefile.hpux +++ b/src/makefiles/Makefile.hpux @@ -37,11 +37,6 @@ ifeq ($(host_cpu), ia64) 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 diff --git a/src/makefiles/Makefile.linux b/src/makefiles/Makefile.linux index f4f091caef59362c6edbe797d6cc39e6e8a1e43c..c6d0546e4d50fb9f048d2faebafd4f048d52a5a9 100644 --- a/src/makefiles/Makefile.linux +++ b/src/makefiles/Makefile.linux @@ -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 diff --git a/src/makefiles/Makefile.netbsd b/src/makefiles/Makefile.netbsd index 43841c15973b0c0b594fc2333f2bbdea4bcd71ae..c2a3cce4f01a15901da5c6c9d7b96cb43f5dc44a 100644 --- a/src/makefiles/Makefile.netbsd +++ b/src/makefiles/Makefile.netbsd @@ -9,8 +9,6 @@ endif DLSUFFIX = .so -CFLAGS_SL = -fPIC -DPIC - # Rule for building a shared library from a single .o file %.so: %.o diff --git a/src/makefiles/Makefile.openbsd b/src/makefiles/Makefile.openbsd index d8fde49d5c8d95ee73d4c507d12a50ac94bbb7c9..0c5a7b4eb357960e63bf19cd79bba44c90b39e04 100644 --- a/src/makefiles/Makefile.openbsd +++ b/src/makefiles/Makefile.openbsd @@ -7,8 +7,6 @@ endif DLSUFFIX = .so -CFLAGS_SL = -fPIC -DPIC - # Rule for building a shared library from a single .o file %.so: %.o diff --git a/src/makefiles/Makefile.osf b/src/makefiles/Makefile.osf index 31822fd79d339f724fbf17b72a1d1ea1e6986150..2d581d3b9fbf9c47634fed5fdd06b15751bf1e72 100644 --- a/src/makefiles/Makefile.osf +++ b/src/makefiles/Makefile.osf @@ -1,6 +1,6 @@ AROPT = crs DLSUFFIX = .so -CFLAGS_SL = + rpath = -rpath '$(rpathdir)' # Rule for building a shared library from a single .o file diff --git a/src/makefiles/Makefile.sco b/src/makefiles/Makefile.sco index 993861570ac7e56f6a86b56199080f33023a7acf..49c6693f148d879819b3273bbe11684a42637ef9 100644 --- a/src/makefiles/Makefile.sco +++ b/src/makefiles/Makefile.sco @@ -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 diff --git a/src/makefiles/Makefile.solaris b/src/makefiles/Makefile.solaris index e459de30cf4933869dadeac4a443ae9c165082ed..a05c0e0d3d224e0f8fde589fe68ce7d665ddddee 100644 --- a/src/makefiles/Makefile.solaris +++ b/src/makefiles/Makefile.solaris @@ -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 diff --git a/src/makefiles/Makefile.unixware b/src/makefiles/Makefile.unixware index a52717b2688e6911965cf211011dfcb06bbcb497..3d177b76e97cb036f093e03f1ce04e80e47bce99 100644 --- a/src/makefiles/Makefile.unixware +++ b/src/makefiles/Makefile.unixware @@ -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 diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32 index f0da19c94d62720592837f5ed8feec940e0eff16..2a033478717354ef3e2846bfa60d079bd2196d4a 100644 --- a/src/makefiles/Makefile.win32 +++ b/src/makefiles/Makefile.win32 @@ -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))) diff --git a/src/template/aix b/src/template/aix index 230d4613f3cebeffae17a22a0066e0f0827e2a05..f7954123e1bd5028b5c354a8211b16ac71dee811 100644 --- a/src/template/aix +++ b/src/template/aix @@ -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 diff --git a/src/template/cygwin b/src/template/cygwin index e484fe650c6e8958967eca857e6a9cb4414924cd..be8df78b6e03df0ea61f6146fc63da526448a3ad 100644 --- a/src/template/cygwin +++ b/src/template/cygwin @@ -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, diff --git a/src/template/darwin b/src/template/darwin index c05adca0bfbec7bba7a6551d4edf0ea0bf932d49..f4d4e9d7cf80d5c55e0da63ece81e4ccf69e66d7 100644 --- a/src/template/darwin +++ b/src/template/darwin @@ -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 diff --git a/src/template/freebsd b/src/template/freebsd index 1e04fece42b585de3a1bc83bd5f3385a4e4fff1b..bf16e1bf0728fadccbc6760f0bd9b3c452ee95fa 100644 --- a/src/template/freebsd +++ b/src/template/freebsd @@ -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 diff --git a/src/template/hpux b/src/template/hpux index ce4d93ced7badb8ccbe786424930387088b4060f..3c87d7a303d6da21550a8bd5697aaf12069aea39 100644 --- a/src/template/hpux +++ b/src/template/hpux @@ -7,6 +7,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 diff --git a/src/template/linux b/src/template/linux index 3eb5ad2428fdefcbd41c5dda6fa87c708a3abcf1..09ab6af86cb15be2bca727821b49b70b3df0b4f9 100644 --- a/src/template/linux +++ b/src/template/linux @@ -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" diff --git a/src/template/netbsd b/src/template/netbsd index 198697723dfb913facaaae88d452fa5f60421743..d97f995c748dab2234406ec6a4d2b5ae2d1daca5 100644 --- a/src/template/netbsd +++ b/src/template/netbsd @@ -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" diff --git a/src/template/openbsd b/src/template/openbsd index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..365268c48978ebe9588e46efe47e8e01c6e7ae25 100644 --- a/src/template/openbsd +++ b/src/template/openbsd @@ -0,0 +1,4 @@ +# src/template/openbsd + +# Extra CFLAGS for code that will go into a shared library +CFLAGS_SL="-fPIC -DPIC" diff --git a/src/template/osf b/src/template/osf index 4f10ad619a35f39c66b33c7d77dcfacf9b7a71cb..c938affd8ed6e7af81ff6ed2355efb4de822f252 100644 --- a/src/template/osf +++ b/src/template/osf @@ -4,3 +4,6 @@ if test "$GCC" != yes ; then CC="$CC -std" CFLAGS="-O -ieee" fi + +# Extra CFLAGS for code that will go into a shared library +CFLAGS_SL="" diff --git a/src/template/sco b/src/template/sco index 9a736da8be74b4d7224f2ce47c9fed72222a1a72..e216f1e7aa933ac73914f4b67c4f5fdd6b0a19ae 100644 --- a/src/template/sco +++ b/src/template/sco @@ -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 diff --git a/src/template/solaris b/src/template/solaris index e07b9a0a8d6145ee5e433704e91abf4424cc0688..f88b1cdad37f85039eabf288ae6e44c9ac3fc44c 100644 --- a/src/template/solaris +++ b/src/template/solaris @@ -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 diff --git a/src/template/unixware b/src/template/unixware index d08fca1e6bee78f3e24f2f642bd941c3dc0265dd..006c4abe4997fee98dc3a4429ebbe6e027cd00ad 100644 --- a/src/template/unixware +++ b/src/template/unixware @@ -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" diff --git a/src/template/win32 b/src/template/win32 index dc5b77ec0768a5a90388ce74cf2a59d2b3335965..d02dd97851f51a442200d44d507f1b0b0e706780 100644 --- a/src/template/win32 +++ b/src/template/win32 @@ -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