autoconf: Don't AC_SUBST() LD in configure
authorAndres Freund <andres@anarazel.de>
Fri, 2 Dec 2022 03:03:26 +0000 (19:03 -0800)
committerAndres Freund <andres@anarazel.de>
Fri, 2 Dec 2022 03:03:26 +0000 (19:03 -0800)
The only use of $(LD) in Makefiles is for AIX, to generate the export file for
the backend. We only support the system linker on AIX and we already hardcode
the path to a number of other binaries. Removing LD substitution will simplify
the upcoming meson PGXS compatibility.

While at it, add a comment why -r is used.

A subsequent commit will remove the determination of LD from configure as
well.

Discussion: https://postgr.es/m/20221005200710.luvw5evhwf6clig6@awork3.anarazel.de

configure
configure.ac
src/Makefile.global.in
src/backend/Makefile

index f62fbc5d0f53c7bb78bcab535b7805889d9fe5ba..4b24e36a93bbc6e5f4475ed5fb20c210195c5235 100755 (executable)
--- a/configure
+++ b/configure
@@ -693,7 +693,6 @@ STRIP_SHARED_LIB
 STRIP_STATIC_LIB
 STRIP
 with_gnu_ld
-LD
 LDFLAGS_SL
 LDFLAGS_EX
 ZSTD_LIBS
@@ -9645,7 +9644,6 @@ with_gnu_ld=$ac_cv_prog_gnu_ld
 
 
 
-
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
index 6e7c8e09411370f5548aaf5754bb6fdea18ed1b1..61e6da6eb373f151c766cd3fb214b8b06fc514dd 100644 (file)
@@ -1132,7 +1132,6 @@ AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only])
 AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only])
 
 PGAC_PROG_LD
-AC_SUBST(LD)
 AC_SUBST(with_gnu_ld)
 PGAC_CHECK_STRIP
 AC_CHECK_TOOL(AR, ar, ar)
index 346b73260fc255b8b309c607dc055a550b6dc659..6ee0f513018d4777bf9820bbada9af94f362ebaf 100644 (file)
@@ -289,7 +289,6 @@ LDAP_LIBS_FE = @LDAP_LIBS_FE@
 LDAP_LIBS_BE = @LDAP_LIBS_BE@
 UUID_LIBS = @UUID_LIBS@
 LLVM_LIBS=@LLVM_LIBS@
-LD = @LD@
 with_gnu_ld = @with_gnu_ld@
 
 # It's critical that within LDFLAGS, all -L switches pointing to build-tree
@@ -316,8 +315,6 @@ LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@
 LDFLAGS_EX = @LDFLAGS_EX@
 # LDFLAGS_SL might have already been assigned by calling makefile
 LDFLAGS_SL += @LDFLAGS_SL@
-LDREL = -r
-LDOUT = -o
 WINDRES = @WINDRES@
 X = @EXEEXT@
 
index 181c217fae4c86cc22a93861be713c33f7e9e44d..efd4d30a28d564397cc490410d4203c129c825c8 100644 (file)
@@ -100,8 +100,14 @@ ifeq ($(PORTNAME), aix)
 postgres: $(POSTGRES_IMP)
    $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) $(LDFLAGS_EX) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
 
+# Linking to a single .o with -r is a lot faster than building a .a or passing
+# all objects to MKLDEXPORT.
+#
+# It looks alluring to use $(CC) -r instead of ld -r, but that doesn't
+# trivially work with gcc, due to gcc specific static libraries linked in with
+# -r.
 $(POSTGRES_IMP): $(OBJS)
-   $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(call expand_subsys,$^)
+   ld -r -o SUBSYS.o $(call expand_subsys,$^)
    $(MKLDEXPORT) SUBSYS.o . > $@
    @rm -f SUBSYS.o