You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1998/05/11 12:58:57 UTC

[PATCH] $(LD) used but never defined (showstopper IMHO)

$(LD) used but never defined
----------------------------

While working on a solution for seperating arbitrary -L/-l options into
disjunct sets OBJ,PIC,DSO (because for a more correct building of DSO's
mod_xxx.so libraries have to specified but only PIC and DSO ones), I
recognized that we use $(LD) all the time. BUT WE NEVER DEFINED IT SOMEWHERE.
Not even a LD=ld is in our Makefile.config. It just was assumed that most Make
variants provide an implicit built-in LD definition which defaults to "ld".

!! A risky portability assumption and some sort of a showstopper IMHO. !!

Additionally the usage of the variable $(LD) for building DSO files is bogus,
too. Because LD can be used for other stuff while for DSO a different command
can be needed. There are platforms where you build executables with "cc" or
"ld", while DSO's are built via "ld -G" or "cc -shared" or even "libtool".  So
a different variable has to be used to avoid conflicts. We already use the
suffix _SHLIB, so $(LD_SHLIB) seems to be the canonical one here.

The above patch changes $(LD) to $(LD_SHLIB) and makes sure it can be both
overridden via APACI, via src/Configuration and via the case-esac structure in
src/Configure (as it is already the case all other XXXX_SHLIB variables).

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: INSTALL
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/INSTALL,v
retrieving revision 1.26
diff -u -r1.26 INSTALL
--- INSTALL	1998/05/08 07:50:20	1.26
+++ INSTALL	1998/05/11 10:24:09
@@ -131,9 +131,9 @@
      Reference:
 
      $ [CC=...]        [CFLAGS_SHLIB=...]         
-       [OPTIM=...]     [LDFLAGS_SHLIB=...]        
-       [CFLAGS=...]    [LDFLAGS_SHLIB_EXPORT=...] 
-       [INCLUDES=...] 
+       [OPTIM=...]     [LD_SHLIB=...]
+       [CFLAGS=...]    [LDFLAGS_SHLIB=...]        
+       [INCLUDES=...]  [LDFLAGS_SHLIB_EXPORT=...] 
        [LDFLAGS=...]   [RANLIB=...]  
        [LIBS=...] 
        ./configure [--quiet]   [--prefix=DIR]         [--enable-rule=NAME]    
@@ -156,9 +156,10 @@
                                                       [--without-support]  
 
      Use the CC, OPTIM, CFLAGS, INCLUDES, LDFLAGS, LIBS, CFLAGS_SHLIB,
-     LDFLAGS_SHLIB, LDFLAGS_SHLIB_EXPORT and RANLIB environment variables to
-     override the corresponding default entries in the src/Configuration.tmpl
-     file (see there for more information about their usage).
+     LD_SHLIB, LDFLAGS_SHLIB, LDFLAGS_SHLIB_EXPORT and RANLIB environment
+     variables to override the corresponding default entries in the
+     src/Configuration.tmpl file (see there for more information about their
+     usage).
 
          Note: The syntax ``KEY=VALUE ./configure ...'' (one single line!) is
                the GNU Autoconf compatible way of specifying defines and can
Index: configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/configure,v
retrieving revision 1.24
diff -u -r1.24 configure
--- configure	1998/05/08 07:50:21	1.24
+++ configure	1998/05/11 10:25:00
@@ -857,7 +857,7 @@
 
 #   generate settings from imported environment variables
 OIFS="$IFS" IFS="$DIFS"
-for var in CC OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LDFLAGS_SHLIB \
+for var in CC OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LD_SHLIB LDFLAGS_SHLIB \
            LDFLAGS_SHLIB_EXPORT LIBS INCLUDES RANLIB; do
     eval "val=\"\$$var\"";
     if [ ".$val" != . ]; then
Index: src/CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.843
diff -u -r1.843 CHANGES
--- CHANGES	1998/05/11 10:13:25	1.843
+++ CHANGES	1998/05/11 10:45:49
@@ -1,5 +1,14 @@
 Changes with Apache 1.3b7
 
+  *) The Makefiles assumed that DSO files are build via $(LD). This
+     is broken for two reasons: First we never defined at least LD=ld
+     somewhere to make sure this works (it was silently assumed that most Make
+     provide a built-in LD definition - ARGL!) and second using the generic LD
+     variable is not the truth (instead a special variable named LD_SHLIB is
+     reasonable because although "ld" is usually the default, it can be
+     "libtool" or even "cc" on some systems in the future).
+     [Ralf S. Engelschall]
+
   *) The LDFLAGS_SHLIB_EXPORT variable of src/Configuration[.tmpl] was
      not retrieved in src/Configure and thus was not useable.
      [Ralf S. Engelschall]
Index: src/Configuration.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Configuration.tmpl,v
retrieving revision 1.102
diff -u -r1.102 Configuration.tmpl
--- Configuration.tmpl	1998/05/04 14:44:36	1.102
+++ Configuration.tmpl	1998/05/11 10:26:12
@@ -86,6 +86,7 @@
 # change the filename extension from `.o' to `.so'. 
 
 #CFLAGS_SHLIB=
+#LD_SHLIB=
 #LDFLAGS_SHLIB=
 #LDFLAGS_SHLIB_EXPORT=
 
Index: src/Makefile.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Makefile.tmpl,v
retrieving revision 1.94
diff -u -r1.94 Makefile.tmpl
--- Makefile.tmpl	1998/05/10 13:04:26	1.94
+++ Makefile.tmpl	1998/05/11 10:49:01
@@ -41,7 +41,7 @@
 
 libhttpd.so: subdirs modules.o
 	$(CC) -c $(INCLUDES) $(CFLAGS) buildmark.c
-	$(LD) $(LDFLAGS_SHLIB) -o libhttpd.so buildmark.o $(OBJS) $(REGLIB)
+	$(LD_SHLIB) $(LDFLAGS_SHLIB) -o libhttpd.so buildmark.o $(OBJS) $(REGLIB)
 	@if [ ".$(SHLIB_SUFFIX_LIST)" != . ]; then \
 		rm -f libhttpd.so.*; \
 		for suffix in $(SHLIB_SUFFIX_LIST) ""; do \
Index: src/Configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Configure,v
retrieving revision 1.259
diff -u -r1.259 Configure
--- Configure	1998/05/11 10:13:26	1.259
+++ Configure	1998/05/11 10:28:56
@@ -773,6 +773,7 @@
 ####################################################################
 ## Check for user provided flags for shared object support
 ##
+TLD_SHLIB=`egrep '^LD_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
 TLDFLAGS_SHLIB=`egrep '^LDFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
 TLDFLAGS_SHLIB_EXPORT=`egrep '^LDFLAGS_SHLIB_EXPORT=' Makefile.config | tail -1 | awk -F= '{print $2}'`
 TCFLAGS_SHLIB=`egrep '^CFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
@@ -782,6 +783,7 @@
 ## required.  For more platforms just add the required lines below.
 ##
 if [ "x$using_shlib" = "x1" ] ; then
+    LD_SHLIB="ld"
     DEF_SHARED_CORE=no
     SHLIB_SUFFIX_DEPTH=all
     SHLIB_EXPORT_FILES=no
@@ -1026,6 +1028,9 @@
     if [ "x$TCFLAGS_SHLIB" = "x" ]; then
         echo "CFLAGS_SHLIB=$CFLAGS_SHLIB -DSHARED_MODULE" >> Makefile.config
     fi
+    if [ "x$TLD_SHLIB" = "x" ]; then
+        echo "LD_SHLIB=$LD_SHLIB" >> Makefile.config
+    fi
     if [ "x$TLDFLAGS_SHLIB" = "x" ]; then
         echo "LDFLAGS_SHLIB=$LDFLAGS_SHLIB" >> Makefile.config
     fi
@@ -1726,7 +1731,7 @@
 
 .c.so:
 	$(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo
-	$(LD) $(LDFLAGS_SHLIB) -o $@ $*.lo
+	$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $*.lo
 
 clean:
 	rm -f $(LIB) $(OBJS) $(SHLIBS) $(OBJS_PIC)
Index: src/modules/proxy/Makefile.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/modules/proxy/Makefile.tmpl,v
retrieving revision 1.16
diff -u -r1.16 Makefile.tmpl
--- Makefile.tmpl	1998/05/10 13:04:34	1.16
+++ Makefile.tmpl	1998/05/11 10:28:47
@@ -19,7 +19,7 @@
 
 libproxy.so: $(OBJS_PIC)
 	rm -f $@
-	$(LD) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC)
+	$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC)
 
 .SUFFIXES: .o .lo
 
Index: src/support/Makefile.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/support/Makefile.tmpl,v
retrieving revision 1.19
diff -u -r1.19 Makefile.tmpl
--- Makefile.tmpl	1998/05/09 18:28:40	1.19
+++ Makefile.tmpl	1998/05/11 10:33:07
@@ -31,7 +31,7 @@
 apxs: apxs.pl
 	sed <apxs.pl >apxs \
 	    -e 's%@CC@%$(CC)%g' \
-	    -e 's%@LD@%$(LD)%g' \
+	    -e 's%@LD_SHLIB@%$(LD_SHLIB)%g' \
 	    -e 's%@CFLAGS@%$(CFLAGS)%g' \
 	    -e 's%@CFLAGS_SHLIB@%$(CFLAGS_SHLIB)%g' \
 	    -e 's%@LDFLAGS_SHLIB@%$(LDFLAGS_SHLIB)%g' && chmod a+x apxs
Index: src/support/apxs.pl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/support/apxs.pl,v
retrieving revision 1.6
diff -u -r1.6 apxs.pl
--- apxs.pl	1998/05/06 15:18:03	1.6
+++ apxs.pl	1998/05/11 10:34:01
@@ -69,9 +69,9 @@
 ##
 
 my $CFG_CC            = '@CC@';            # substituted via Makefile.tmpl
-my $CFG_LD            = '@LD@';            # substituted via Makefile.tmpl
 my $CFG_CFLAGS        = '@CFLAGS@';        # substituted via Makefile.tmpl
 my $CFG_CFLAGS_SHLIB  = '@CFLAGS_SHLIB@';  # substituted via Makefile.tmpl
+my $CFG_LD_SHLIB      = '@LD_SHLIB@';      # substituted via Makefile.tmpl
 my $CFG_LDFLAGS_SHLIB = '@LDFLAGS_SHLIB@'; # substituted via Makefile.tmpl 
 my $CFG_PREFIX        = '@prefix@';        # substituted via APACI install
 my $CFG_SBINDIR       = '@sbindir@';       # substituted via APACI install
@@ -262,7 +262,7 @@
         my $ok = 0;
         my $name;
         foreach $name (qw(
-            CC LD CFLAGS CFLAGS_SHLIB LDFLAGS_SHLIB 
+            CC LD_SHLIB CFLAGS CFLAGS_SHLIB LDFLAGS_SHLIB 
             PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR
         )) {
             if ($arg eq $name or $arg eq lc($name)) {
@@ -338,7 +338,7 @@
     }
 
     #   create link command
-    my $cmd = "$CFG_LD $CFG_LDFLAGS_SHLIB -o $dso_file";
+    my $cmd = "$CFG_LD_SHLIB $CFG_LDFLAGS_SHLIB -o $dso_file";
     my $o;
     foreach $o (@objs) {
         $cmd .= " $o";