Greetings all.

Attached is a different solution to (and Changelog for) the core issue observed, that of the incorrect RPATH value for the test suite on AIX 5.3. Rather than defining directory specific LDFLAGS variables, this patch defines a new variable (RPATH), and appends it to the LDFLAGS variable in each directory's makefile, along with the relevant directory path.

Martin and I spent probably an hour or so this morning discussing different ways to generate the proposed sectional makefile.in setup. The conclusion that was reached was that generating these files would be an extremely verbose process. In addition, the fatal flaw is the inability to remove or combine flags. An example is if a pair of flags defined in different files (such as makefile.release.in and makefile.static.in) are mutually exclusive. Another example is the MSVC runtime library options, which vary on two or three build mode options.

The basic layout of the sectional makefile would likely have been as follows. The 'core' makefile.in contains variables that are used in all builds with a given compiler on a given platform. This is mostly the same as the existing makefile.in. In addition to this makefiles, a generated makefile would exist for each build type attribute, and would be named like makefile.attribute.in. The attributes are debug/optimized, archive/shared, nothread/posix/solaris/dec, and narrow/wide. These variables would contain the (narrow) set of variables which do vary. These variables would be SUFFIX (only for archive/shared), CXXFLAGS, CPPFLAGS, LDFLAGS, and ARFLAGS.

Within the .config files, these changing variables would be named like VARIABLE.mode (ie: CXXFLAGS.debug and LDFLAGS.shared, taking the place of the existing DEBUG_CXXFLAGS and SHARED_LDFLAGS variables respectively).

A similar set of files would exist in each major subdirectory. The variables within the .config files would be named like VARIABLE.dir (for the makefile.in in each directory) and VARIABLE.dir.mode (for the makefile.mode.in in each directory).

Another concept that was discussed was the possibility of creating a compiler driver. This driver would handle translating a set of gcc style compiler switches into switches understood by each compiler, along with such things as template repository locations and rpath control switches.

--Andrew Black
Index: GNUmakefile
===================================================================
--- GNUmakefile	(revision 484691)
+++ GNUmakefile	(working copy)
@@ -589,6 +589,7 @@
           && echo "LDLIBS     = $(LDLIBS)"               >> $(MAKEFILE_IN)  \
           && echo "LDSOFLAGS  = $(LDSOFLAGS)"            >> $(MAKEFILE_IN)  \
           && echo "MAPFLAGS   = $(MAPFLAGS)"             >> $(MAKEFILE_IN)  \
+          && echo "RPATH      = $(RPATH)"                >> $(MAKEFILE_IN)  \
           && [ "$(MAPFILE)" = "" ]                                          \
           || echo "MAPFILE    = $$""(TOPDIR)/$(MAPFILE)" >> $(MAKEFILE_IN)  \
           && echo "RUNFLAGS   = -t 180"                  >> $(MAKEFILE_IN)  \
Index: etc/config/GNUmakefile.exm
===================================================================
--- etc/config/GNUmakefile.exm	(revision 484691)
+++ etc/config/GNUmakefile.exm	(working copy)
@@ -23,6 +23,10 @@
 
 RUNFLAGS += -d $(EXMDIR)
 
+ifneq ($(RPATH),)
+  LDFLAGS += $(RPATH)$(LIBDIR)
+endif
+
 ##############################################################################
 #  TARGETS
 ##############################################################################
Index: etc/config/acc.config
===================================================================
--- etc/config/acc.config	(revision 484691)
+++ etc/config/acc.config	(working copy)
@@ -68,6 +68,7 @@
 LDFLAGS         = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings "$$"(_LDOPTS)
 endif
 
+RPATH = -Wl,+b
 
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g +d
@@ -79,7 +80,7 @@
 # shared/static library options
 SHARED_CXXFLAGS =
 SHARED_CPPFLAGS =
-SHARED_LDFLAGS  = -Wl,+b$(LIBDIR)
+SHARED_LDFLAGS  =
 SHARED_SUFFIX   = .sl
 
 STATIC_CXXFLAGS =
Index: etc/config/sunpro.config
===================================================================
--- etc/config/sunpro.config	(revision 484691)
+++ etc/config/sunpro.config	(working copy)
@@ -25,6 +25,8 @@
 AR              = CC
 ARFLAGS         = -xar -o
 
+RPATH = -R
+
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g
 DEBUG_CPPFLAGS  =
@@ -35,7 +37,7 @@
 # shared/static library options
 SHARED_CXXFLAGS =
 SHARED_CPPFLAGS =
-SHARED_LDFLAGS  = -R$(LIBDIR)
+SHARED_LDFLAGS  = 
 
 STATIC_CXXFLAGS =
 STATIC_CPPFLAGS =
Index: etc/config/GNUmakefile.ph
===================================================================
--- etc/config/GNUmakefile.ph	(revision 484691)
+++ etc/config/GNUmakefile.ph	(working copy)
@@ -47,6 +47,10 @@
 # override the runtarget set in makefile.common
 RUNTARGET   = $(shell $(MAKE) -s listtarget listsubtests | sed "s/ / .\//g")
 
+ifneq ($(RPATH),)
+  LDFLAGS += $(RPATH)$(LIBDIR)
+endif
+
 ##############################################################################
 #  TARGETS  
 ##############################################################################
Index: etc/config/mipspro.config
===================================================================
--- etc/config/mipspro.config	(revision 484691)
+++ etc/config/mipspro.config	(working copy)
@@ -36,6 +36,8 @@
 # the extension of assembly files is .s
 AS_EXT = .s
 
+RPATH = -Wl,-rpath,
+
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g
 DEBUG_CPPFLAGS  =
@@ -47,7 +49,7 @@
 # shared/static library options
 SHARED_CXXFLAGS =
 SHARED_CPPFLAGS =
-SHARED_LDFLAGS  = -Wl,-rpath,$(LIBDIR)
+SHARED_LDFLAGS  = 
 
 STATIC_CXXFLAGS =
 STATIC_CPPFLAGS =
Index: etc/config/GNUmakefile.bin
===================================================================
--- etc/config/GNUmakefile.bin	(revision 484691)
+++ etc/config/GNUmakefile.bin	(working copy)
@@ -48,6 +48,10 @@
 # Don't want to link exec utility with stdlib, so create our own LDFLAGS var
 LDFLAGS.exec = $(filter-out -l$(LIBBASE),$(LDFLAGS))
 
+ifneq ($(RPATH),)
+  LDFLAGS += $(RPATH)$(LIBDIR)
+endif
+
 ##############################################################################
 #  TARGETS
 ##############################################################################
Index: etc/config/gcc.config
===================================================================
--- etc/config/gcc.config	(revision 484691)
+++ etc/config/gcc.config	(working copy)
@@ -128,39 +128,27 @@
   endif
 endif   # gcc > 2
 
-# debug/optimization options
-DEBUG_CXXFLAGS  = -g
-DEBUG_CPPFLAGS  =
-
-OPTMZ_CXXFLAGS  = -O2
-OPTMZ_CPPFLAGS  =
-
-# shared/static library options
-SHARED_CXXFLAGS = 
-SHARED_CPPFLAGS =
 ifeq ($(OSNAME),Linux)
-  SHARED_LDFLAGS = -Wl,-R$(LIBDIR)
+  RPATH = -Wl,-R
 else
   ifeq ($(OSNAME),SunOS)
-    SHARED_LDFLAGS = -Wl,-R$(LIBDIR)
+    RPATH = -Wl,-R
   else
     ifeq ($(OSNAME),AIX)
       ifeq ($(shell [ $(OS_MAJOR) -gt 5 -o $(OS_MAJOR) -eq 5 -a $(OS_MINOR) \
 -ge 3 ] && echo 1), 1)
         # -bsrv4, -R only available on AIX 5.3 and newer
-        SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
+        RPATH = -Wl,-bsvr4,-R
       endif
     else
       ifeq ($(OSNAME),HP-UX)
-        SHARED_LDFLAGS = -Wl,+b$(LIBDIR)
+        RPATH = -Wl,+b
       else
         ifeq ($(OSNAME),IRIX64)
-          SHARED_LDFLAGS = -Wl,-rpath,$(LIBDIR)
+          RPATH = -Wl,-rpath,
         else
           ifeq ($(OSNAME),OSF1)
-            SHARED_LDFLAGS = -Wl,-rpath,$(LIBDIR)
-          else
-            SHARED_LDFLAGS =
+            RPATH = -Wl,-rpath,
           endif
         endif
       endif
@@ -168,6 +156,18 @@
   endif
 endif
 
+# debug/optimization options
+DEBUG_CXXFLAGS  = -g
+DEBUG_CPPFLAGS  =
+
+OPTMZ_CXXFLAGS  = -O2
+OPTMZ_CPPFLAGS  =
+
+# shared/static library options
+SHARED_CXXFLAGS = 
+SHARED_CPPFLAGS =
+SHARED_LDFLAGS =
+
 ifeq ($(OSNAME),AIX)
   SHARED_SUFFIX   = .a
 endif
Index: etc/config/GNUmakefile.tst
===================================================================
--- etc/config/GNUmakefile.tst	(revision 484691)
+++ etc/config/GNUmakefile.tst	(working copy)
@@ -67,6 +67,10 @@
 # add to targets objects for any sources in the current working directory
 TARGET += $(patsubst %.cpp,%.o,$(wildcard *.cpp))
 
+ifneq ($(RPATH),)
+  LDFLAGS += $(RPATH)$(LIBDIR):$(BUILDDIR)/rwtest
+endif
+
 ##############################################################################
 #  TARGETS
 ##############################################################################
Index: etc/config/icc.config
===================================================================
--- etc/config/icc.config	(revision 484691)
+++ etc/config/icc.config	(working copy)
@@ -31,6 +31,7 @@
 LDSOFLAGS       = -shared
 LDLIBS          = -Bstatic -lcxa -lunwind -Bdynamic $(ICCDIR)/crtxn.o
 
+RPATH           = -Wl,-R
 
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g
@@ -42,7 +43,7 @@
 # shared/archive library options
 SHARED_CXXFLAGS =
 SHARED_CPPFLAGS =
-SHARED_LDFLAGS  = -Wl,-R$(LIBDIR)
+SHARED_LDFLAGS  = 
 
 STATIC_CXXFLAGS =
 STATIC_CPPFLAGS =
Index: etc/config/GNUmakefile.rwt
===================================================================
--- etc/config/GNUmakefile.rwt	(revision 484691)
+++ etc/config/GNUmakefile.rwt	(working copy)
@@ -54,6 +54,10 @@
 CXXPRELINK = $(CXX) $(CPPFLAGS) $(PRELINKFLAGS) $(OBJS) $(LDFLAGS)
 endif   # ($(PRELINKFLAGS),)
 
+ifneq ($(RPATH),)
+  LDFLAGS += $(RPATH)$(LIBDIR)
+endif
+
 ##############################################################################
 #  TARGETS
 ##############################################################################
Index: etc/config/osf_cxx.config
===================================================================
--- etc/config/osf_cxx.config	(revision 484691)
+++ etc/config/osf_cxx.config	(working copy)
@@ -25,6 +25,8 @@
 # (makefiles will append '=' followed by the name of the repository)
 CXX_REPOSITORY  = -ptr
 
+RPATH = -rpath 
+
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g
 DEBUG_CPPFLAGS  =
@@ -35,7 +37,7 @@
 # shared/static library option
 SHARED_CXXFLAGS = 
 SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
-SHARED_LDFLAGS  = -rpath $(LIBDIR)
+SHARED_LDFLAGS  = 
 
 STATIC_CXXFLAGS =
 STATIC_CPPFLAGS =
Index: etc/config/vacpp.config
===================================================================
--- etc/config/vacpp.config	(revision 484691)
+++ etc/config/vacpp.config	(working copy)
@@ -107,6 +107,16 @@
   LDSOFLAGS     = -G
 endif
 
+ifeq ($(OSNAME),AIX)
+  ifeq ($(shell [ $(OS_MAJOR) -gt 5 -o $(OS_MAJOR) -eq 5 -a $(OS_MINOR) -ge 3 \
+] && echo 1), 1)
+    # -bsrv4, -R only available on AIX 5.3 and newer
+    RPATH = -Wl,-bsvr4,-R
+  endif
+else   # assume Linux
+   RPATH = -Wl,-R
+endif
+
 # debug/optimization options
 DEBUG_CXXFLAGS  = -g
 DEBUG_CPPFLAGS  =
@@ -117,15 +127,7 @@
 # shared/archive library options
 SHARED_CXXFLAGS = 
 SHARED_CPPFLAGS =
-ifeq ($(OSNAME),AIX)
-  ifeq ($(shell [ $(OS_MAJOR) -gt 5 -o $(OS_MAJOR) -eq 5 -a $(OS_MINOR) -ge 3 \
-] && echo 1), 1)
-    # -bsrv4, -R only available on AIX 5.3 and newer
-    SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
-  endif
-else   # assume Linux
-  SHARED_LDFLAGS  = -Wl,-R$(LIBDIR)
-endif
+SHARED_LDFLAGS  =
 
 ifeq ($(rtl_enabled),1)
   SHARED_SUFFIX = .so
2006-12-08  Andrew Black  <[EMAIL PROTECTED]>

        * GNUmakefile ($(MAKEFILE_IN)): Echo RPATH into generated makefile.in
        * GNUmakefile.bin (LDFLAGS): Add $(RPATH) switch with a value of 
        $(LIBDIR) to $(LDFLAGS) if $(RPATH) is defined.
        * GNUmakefile.exm (LDFLAGS): Ditto.
        * GNUmakefile.ph (LDFLAGS): Ditto.
        * GNUmakefile.rwt (LDFLAGS): Ditto.
        * GNUmakefile.tst (LDFLAGS): Add $(RPATH) switch with a value of 
        $(LIBDIR):$(BUILDDIR)/rwtest to $(LDFLAGS) if $(RPATH) is defined.
        * acc.config (SHARED_LDFLAGS): Move rpath flag definition from here ...
        (RPATH): ... To here.
        * gcc.config (SHARED_LDFLAGS, RPATH): Ditto.
        * icc.config (SHARED_LDFLAGS): Ditto.
        * sunpro.config (SHARED_LDFLAGS): Ditto.
        * mipspro.config (SHARED_LDFLAGS): Ditto.
        * osf_cxx.config (SHARED_LDFLAGS): Ditto.
        * vacpp.config (SHARED_LDFLAGS): Ditto.

Reply via email to