You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Andrew Black <ab...@roguewave.com> on 2006/11/03 22:41:22 UTC

[PATCH] Library path fix

Greetings all.

Attached is a patch that aims to fix a bug that manifests itself when 
running 64-bit builds on SPARC Solaris.  The issue that arises is that 
dynamic builds of this type use the LD_LIBRARY_PATH_64 variable to 
determine where to locate shared libraries, rather than the 
LD_LIBRARY_PATH variable used almost everywhere else.  This patch 
attempts to replace all instances of LD_LIBRARY_PATH with the new make 
variable LD_PATH_REF.

--Andrew Black

Changlog:
	* GNUmakefile (LD_PATH_REF): Document variable, define default value
	  ($(MAKEFILE_IN)): Define LD_PATH_REF in generated file
	  (post): use $(LD_PATH_REF) rather than LD_LIBRARY_PATH
	* GNUmakefile.cfg (run): Ditto.
	* makefile.rules (%.out, run): Ditto.
	* sunpro.config [sparc && wide]: Set LD_PATH_REF to LD_LIBRARY_PATH_64

Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Martin Sebor wrote:
> 
>> For gcc you need to guard the changes and enable them only for
>> Linux and Solaris. On other platforms (AIX, HP-UX, IRIX, Tru64)
>> you should use the same flag as for the native compilers.
>>
>> Other than that I think it's good to commit.
>>
>> Btw., it would be nice to set up nightly testing with gcc on
>> the other platforms above.
>>
>> Martin
> 
> 
> Greetings Martin
> 
> The revised patch (attached) should add the suggested logic to the 
> gcc.config file.  One of our coworkers has an Apple laptop with him 
> today, so I asked to use it for a few minutes to consult the ld man 
> page.  As best I can tell from this reading, there is no equivalent to 
> the -R flag on Darwin.  In this light, would it make sense to remove the 
> changes to makefile.rules from the patch prior to committing?  The 
> changes to this file remove the setting of the LD_LIBRARY_PATH variable 
> for the %.output and run targets.

It should be safe to leave the existing LD_LIBRARY_PATH logic in
place so long as the dynamic linker considers the hardwired rpath
in addition to the paths in the variable (i.e., I agree that you
should revert the change to makefile.rules).

Martin

> 
> --Andrew Black
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/sunpro.config
> ===================================================================
> --- etc/config/sunpro.config	(revision 475263)
> +++ etc/config/sunpro.config	(working copy)
> @@ -17,7 +17,7 @@
>  CXXFLAGS        = -library=%none
>  CXXPRELINK      = 
>  CPPFLAGS        =
> -LDFLAGS         = -library=%none -L$(LIBDIR)
> +LDFLAGS         = -library=%none
>  LDSOFLAGS       = -G
>  
>  # use CC to invoke the compiler (needed to pick up template
> @@ -62,8 +62,8 @@
>      LIBTHREAD  = -lthread
>  endif
>  
> -MULTI_LDFLAGS_POSIX    = -mt $(LIBTHREAD)
> -MULTI_LDFLAGS_SOLARIS  = -mt $(LIBPTHREAD)
> +MULTI_LDFLAGS_POSIX    = -mt $(LIBPTHREAD)
> +MULTI_LDFLAGS_SOLARIS  = -mt $(LIBTHREAD)
>  MULTI_LDFLAGS_DCE      =
>  
>  # POSIX
> Index: etc/config/acc.config
> ===================================================================
> --- etc/config/acc.config	(revision 475263)
> +++ etc/config/acc.config	(working copy)
> @@ -58,14 +58,14 @@
>  CXXFLAGS        = -AA "$$"(_CXXOPTS)
>  CXXPRELINK      = 
>  CPPFLAGS        = "$$"(_CPPOPTS)
> -LDFLAGS         = -AA +nostl -Wl,+s -L$(LIBDIR) "$$"(_LDOPTS)
> +LDFLAGS         = -AA +nostl -Wl,+s "$$"(_LDOPTS)
>  else
>  CXXFLAGS        = -Aa +nostl "$$"(_CXXOPTS)
>  CXXPRELINK      = 
>  CPPFLAGS        = -I$(TOPDIR)/include/ansi -I/usr/include "$$"(_CPPOPTS)
>  # -Wl,+s allows the dynamic loader to consider LD_LIBRARY_PATH (LP64)
>  # and SHLIB_PATH when loading an executable into memory
> -LDFLAGS         = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L$(LIBDIR) "$$"(_LDOPTS)
> +LDFLAGS         = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings "$$"(_LDOPTS)
>  endif
>  
>  
> @@ -79,7 +79,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,+b$(LIBDIR)
>  SHARED_SUFFIX   = .sl
>  
>  STATIC_CXXFLAGS =
> Index: etc/config/mipspro.config
> ===================================================================
> --- etc/config/mipspro.config	(revision 475263)
> +++ etc/config/mipspro.config	(working copy)
> @@ -27,7 +27,7 @@
>  
>  
>  # disable warnings about libs that aren't being used to resolve any symbols
> -LDFLAGS         = -Wl,-woff,84 -L$(LIBDIR)
> +LDFLAGS         = -Wl,-woff,84
>  
>  # use the undocumented -LANG:std=off option to prevent linking
>  # with the native C++ Standard Library
> @@ -47,7 +47,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,-rpath,$(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/gcc.config
> ===================================================================
> --- etc/config/gcc.config	(revision 475263)
> +++ etc/config/gcc.config	(working copy)
> @@ -132,7 +132,31 @@
>  # shared/static library options
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +ifeq ($(OSNAME),Linux)
> +  SHARED_LDFLAGS = -Wl,-R$(LIBDIR)
> +else
> +  ifeq ($(OSNAME),SunOS)
> +    SHARED_LDFLAGS = -Wl,-R$(LIBDIR)
> +  else
> +    ifeq ($(OSNAME),AIX)
> +      SHARED_LDFLAGS = -Wl,-bsvr4,-R$(LIBDIR)
> +    else
> +      ifeq ($(OSNAME),HP-UX)
> +        SHARED_LDFLAGS = -Wl,+b$(LIBDIR)
> +      else
> +        ifeq ($(OSNAME),IRIX64)
> +          SHARED_LDFLAGS = -Wl,-rpath,$(LIBDIR)
> +        else
> +          ifeq ($(OSNAME),OSF1)
> +            SHARED_LDFLAGS = -Wl,-rpath,$(LIBDIR)
> +          else
> +            SHARED_LDFLAGS =
> +          endif
> +        endif
> +      endif
> +    endif
> +  endif
> +endif
>  
>  ifeq ($(OSNAME),AIX)
>    SHARED_SUFFIX   = .a
> Index: etc/config/icc.config
> ===================================================================
> --- etc/config/icc.config	(revision 475263)
> +++ etc/config/icc.config	(working copy)
> @@ -42,7 +42,7 @@
>  # shared/archive library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,-R$(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/makefile.rules
> ===================================================================
> --- etc/config/makefile.rules	(revision 475263)
> +++ etc/config/makefile.rules	(working copy)
> @@ -86,7 +86,7 @@
>  
>  # produce a .out file by running the executable
>  %.out: %
> -	LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR) ./$< >$@ 2>&1
> +	./$< >$@ 2>&1
>  
>  # create a script that when run first builds the executable and then runs it
>  # done to save even more space than `NO_DOT_O' on constrained systems
> @@ -111,10 +111,9 @@
>  # for all "top level" tests that failed to build, find and build all
>  # subtests (the little tests the main test consists of)
>  run runall run_all: $(BINDIR)/exec
> -	@(LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR);                    \
> -        PATH=$$PATH:.;                                                    \
> +	@(PATH=$$PATH:.;                                                    \
>          TOPDIR=$(TOPDIR);                                                 \
> -        export LD_LIBRARY_PATH PATH TOPDIR;                               \
> +        export PATH TOPDIR;                                               \
>          report=../$(REPORTFILE)-`date +%m.%d.%y-%H:%M`;                   \
>          if [ -z "$(RUNTARGET)" ];  then                                   \
>              trap "rm $$report" 2 ;                                        \
> Index: etc/config/osf_cxx.config
> ===================================================================
> --- etc/config/osf_cxx.config	(revision 475263)
> +++ etc/config/osf_cxx.config	(working copy)
> @@ -35,7 +35,7 @@
>  # shared/static library option
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -rpath $(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/vacpp.config
> ===================================================================
> --- etc/config/vacpp.config	(revision 475263)
> +++ etc/config/vacpp.config	(working copy)
> @@ -111,7 +111,7 @@
>  # shared/archive library options
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  = 
> +SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
>  
>  ifeq ($(rtl_enabled),1)
>    SHARED_SUFFIX = .so


Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Greetings all.
> 
> After checking in this patch, I was performing a test build on AIX 5.2 
> with GCC, and discovered that the version of ld available with this OS 
> doesn't support the -bsrv4 and -R switches.  Attached is a patch that 
> aims to resolve this issue, along with a related issue with vacpp on 
> Linux (-bsrv4 is an AIX specific switch).

Please prefer the := form of variable assignment when possible in
order to have the expression on the right hand side evaluated just
once rather than each time the variable is expanded.

Before committing please also adjust the length of your ChangeLog
lines to less than 80 characters.

Thanks
Martin

> 
> --Andrew Black
> 
> Changelog:
>     * gcc.config [AIX] (OS_MAJOR, OS_MINOR): Retrieve and store OS major 
> and minor version.
>     [AIX] (SHARED_CPPFLAGS): Only set if OS is 5.3 or newer (Earlier 
> versions of ld don't support -bsrv4, -R switches).
>     * vacpp.config [AIX] (OS_MAJOR, OS_MINOR): Retrieve and store OS 
> major and minor version.
>     [AIX] (SHARED_CPPFLAGS): Only set if OS is 5.3 or newer (Earlier 
> versions of ld don't support -bsrv4, -R switches).
>     [!AIX] (SHARED_CPPFLAGS): Use -R switch (assuming Linux ld).
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/gcc.config
> ===================================================================
> --- etc/config/gcc.config	(revision 480289)
> +++ etc/config/gcc.config	(working copy)
> @@ -12,6 +12,12 @@
>  CXX_MAJOR      := $(shell echo "$(CCVER)" | sed "s/^\([1-9][0-9]*\).*/\1/")
>  CXX_MINOR      := $(shell echo "$(CCVER)" | sed "s/[1-9]*\.\([0-9]*\).*/\1/")
>  
> +# determine the major and minor version of the OS on AIX
> +ifeq ($(OSNAME),AIX)
> +    OS_MAJOR = $(shell uname -v)
> +    OS_MINOR = $(shell uname -r)
> +endif
> +
>  # -W and -Wextra are the same
>  WARNFLAGS       = -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings
>  
> @@ -139,7 +145,10 @@
>      SHARED_LDFLAGS = -Wl,-R$(LIBDIR)
>    else
>      ifeq ($(OSNAME),AIX)
> -      SHARED_LDFLAGS = -Wl,-bsvr4,-R$(LIBDIR)
> +      ifeq ($(shell expr $(OS_MAJOR) \< 5 \| $(OS_MINOR) \< 3),0)
> +        # -bsrv4, -R only available on AIX 5.3 and newer
> +        SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
> +      endif
>      else
>        ifeq ($(OSNAME),HP-UX)
>          SHARED_LDFLAGS = -Wl,+b$(LIBDIR)
> Index: etc/config/vacpp.config
> ===================================================================
> --- etc/config/vacpp.config	(revision 480289)
> +++ etc/config/vacpp.config	(working copy)
> @@ -41,6 +41,12 @@
>  CXX_MAJOR       = $(shell echo "$(CCVER)" | sed "s/^\([1-9][0-9]*\).*/\1/")
>  CXX_MINOR       = $(shell echo "$(CCVER)" | sed "s/[1-9]*\.\([0-9]*\).*/\1/")
>  
> +# determine the major and minor version of the OS on AIX
> +ifeq ($(OSNAME),AIX)
> +    OS_MAJOR = $(shell uname -v)
> +    OS_MINOR = $(shell uname -r)
> +endif
> +
>  # suppress bogus warnings:
>  # 1540-0152: A template dependent name that is a type must be qualified
>  #            with "typename".
> @@ -111,7 +117,14 @@
>  # shared/archive library options
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
> +ifeq ($(OSNAME),AIX)
> +  ifeq ($(shell expr $(OS_MAJOR) \< 5 \| $(OS_MINOR) \< 3),0)
> +    # -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
>  
>  ifeq ($(rtl_enabled),1)
>    SHARED_SUFFIX = .so


Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Greetings all.

After checking in this patch, I was performing a test build on AIX 5.2 
with GCC, and discovered that the version of ld available with this OS 
doesn't support the -bsrv4 and -R switches.  Attached is a patch that 
aims to resolve this issue, along with a related issue with vacpp on 
Linux (-bsrv4 is an AIX specific switch).

--Andrew Black

Changelog:
	* gcc.config [AIX] (OS_MAJOR, OS_MINOR): Retrieve and store OS major 
and minor version.
	[AIX] (SHARED_CPPFLAGS): Only set if OS is 5.3 or newer (Earlier 
versions of ld don't support -bsrv4, -R switches).
	* vacpp.config [AIX] (OS_MAJOR, OS_MINOR): Retrieve and store OS major 
and minor version.
	[AIX] (SHARED_CPPFLAGS): Only set if OS is 5.3 or newer (Earlier 
versions of ld don't support -bsrv4, -R switches).
	[!AIX] (SHARED_CPPFLAGS): Use -R switch (assuming Linux ld).

Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Martin Sebor wrote:
> For gcc you need to guard the changes and enable them only for
> Linux and Solaris. On other platforms (AIX, HP-UX, IRIX, Tru64)
> you should use the same flag as for the native compilers.
> 
> Other than that I think it's good to commit.
> 
> Btw., it would be nice to set up nightly testing with gcc on
> the other platforms above.
> 
> Martin

Greetings Martin

The revised patch (attached) should add the suggested logic to the 
gcc.config file.  One of our coworkers has an Apple laptop with him 
today, so I asked to use it for a few minutes to consult the ld man 
page.  As best I can tell from this reading, there is no equivalent to 
the -R flag on Darwin.  In this light, would it make sense to remove the 
changes to makefile.rules from the patch prior to committing?  The 
changes to this file remove the setting of the LD_LIBRARY_PATH variable 
for the %.output and run targets.

--Andrew Black

Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Andrew Black wrote:
> [...]
> 
>>
>> I've tested on Linux with GCC and ICC using the '-Wl,-R$(LIBDIR)' 
>> switch to the compiler, and the desired behavior in the resulting 
>> executables is obtained.  I'll check the sunpro patch in shortly.  I 
>> intend to post a follow up patch at some point to make this same 
>> change for other compilers.
> 
> 
> Greetings all.
> 
> Attached is the follow-up patch.  Unfortunately, there are a few gaps in 
> it.  One set of gaps is that it doesn't add the appropriate switch to 
> the como.config, eccp.config, and reliant_cds.config files.  Another set 
> of gaps is that compilers haven't been tested off of their 'home' 
> platform (Sunpro on Solaris, GCC and ICC on Linux, and so on).  Most 
> linkers use -R, but HPUX uses +b, Compaq and IRIX use -rpath, and AIX 
> requires -bsrv4 prior to -R.

For gcc you need to guard the changes and enable them only for
Linux and Solaris. On other platforms (AIX, HP-UX, IRIX, Tru64)
you should use the same flag as for the native compilers.

Other than that I think it's good to commit.

Btw., it would be nice to set up nightly testing with gcc on
the other platforms above.

Martin

> 
> --Andrew Black
> 
> Log:
>     * makefile.rules (%.out): Remove runtime alterations of 
> $LD_LIBRARY_PATH.
>     (run runall run_all): Ditto.
>     * sunpro.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch.  
> Switch is added if needed in makefile.common.
>     (MULTI_LDFLAGS_POSIX, MULTI_LDFLAGS_SOLARIS): Use $(LIBPTHREAD) for 
> MULTI_LDFLAGS_POSIX and $(LIBTHREAD) for MULTI_LDFLAGS_SOLARIS.  Had 
> been reversed at some point by mistake.
>     * acc.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch.  Switch 
> is added if needed in makefile.common.
>     (SHARED_LDFLAGS): Add rpath switch to include $(LIBDIR) in ld search 
> path of executables.
>     * gcc.config (SHARED_LDFLAGS): Ditto.
>     * icc.config (SHARED_LDFLAGS): Ditto.
>     * mipspro.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch. 
> Switch is added if needed in makefile.common.
>     (SHARED_LDFLAGS): Add rpath switch to include $(LIBDIR) in ld search 
> path of executables.
>     * osf_cxx.config (SHARED_LDFLAGS): Ditto.
>     * vacpp.config (SHARED_LDFLAGS): Ditto.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/acc.config
> ===================================================================
> --- etc/config/acc.config	(revision 475263)
> +++ etc/config/acc.config	(working copy)
> @@ -58,14 +58,14 @@
>  CXXFLAGS        = -AA "$$"(_CXXOPTS)
>  CXXPRELINK      = 
>  CPPFLAGS        = "$$"(_CPPOPTS)
> -LDFLAGS         = -AA +nostl -Wl,+s -L$(LIBDIR) "$$"(_LDOPTS)
> +LDFLAGS         = -AA +nostl -Wl,+s "$$"(_LDOPTS)
>  else
>  CXXFLAGS        = -Aa +nostl "$$"(_CXXOPTS)
>  CXXPRELINK      = 
>  CPPFLAGS        = -I$(TOPDIR)/include/ansi -I/usr/include "$$"(_CPPOPTS)
>  # -Wl,+s allows the dynamic loader to consider LD_LIBRARY_PATH (LP64)
>  # and SHLIB_PATH when loading an executable into memory
> -LDFLAGS         = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L$(LIBDIR) "$$"(_LDOPTS)
> +LDFLAGS         = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings "$$"(_LDOPTS)
>  endif
>  
>  
> @@ -79,7 +79,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,+b$(LIBDIR)
>  SHARED_SUFFIX   = .sl
>  
>  STATIC_CXXFLAGS =
> Index: etc/config/gcc.config
> ===================================================================
> --- etc/config/gcc.config	(revision 475263)
> +++ etc/config/gcc.config	(working copy)
> @@ -132,7 +132,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,-R$(LIBDIR)
>  
>  ifeq ($(OSNAME),AIX)
>    SHARED_SUFFIX   = .a
> Index: etc/config/icc.config
> ===================================================================
> --- etc/config/icc.config	(revision 475263)
> +++ etc/config/icc.config	(working copy)
> @@ -42,7 +42,7 @@
>  # shared/archive library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,-R$(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/makefile.rules
> ===================================================================
> --- etc/config/makefile.rules	(revision 475263)
> +++ etc/config/makefile.rules	(working copy)
> @@ -86,7 +86,7 @@
>  
>  # produce a .out file by running the executable
>  %.out: %
> -	LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR) ./$< >$@ 2>&1
> +	./$< >$@ 2>&1
>  
>  # create a script that when run first builds the executable and then runs it
>  # done to save even more space than `NO_DOT_O' on constrained systems
> @@ -111,10 +111,9 @@
>  # for all "top level" tests that failed to build, find and build all
>  # subtests (the little tests the main test consists of)
>  run runall run_all: $(BINDIR)/exec
> -	@(LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR);                    \
> -        PATH=$$PATH:.;                                                    \
> +	@(PATH=$$PATH:.;                                                    \
>          TOPDIR=$(TOPDIR);                                                 \
> -        export LD_LIBRARY_PATH PATH TOPDIR;                               \
> +        export PATH TOPDIR;                                               \
>          report=../$(REPORTFILE)-`date +%m.%d.%y-%H:%M`;                   \
>          if [ -z "$(RUNTARGET)" ];  then                                   \
>              trap "rm $$report" 2 ;                                        \
> Index: etc/config/mipspro.config
> ===================================================================
> --- etc/config/mipspro.config	(revision 475263)
> +++ etc/config/mipspro.config	(working copy)
> @@ -27,7 +27,7 @@
>  
>  
>  # disable warnings about libs that aren't being used to resolve any symbols
> -LDFLAGS         = -Wl,-woff,84 -L$(LIBDIR)
> +LDFLAGS         = -Wl,-woff,84
>  
>  # use the undocumented -LANG:std=off option to prevent linking
>  # with the native C++ Standard Library
> @@ -47,7 +47,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -Wl,-rpath,$(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/osf_cxx.config
> ===================================================================
> --- etc/config/osf_cxx.config	(revision 475263)
> +++ etc/config/osf_cxx.config	(working copy)
> @@ -35,7 +35,7 @@
>  # shared/static library option
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -rpath $(LIBDIR)
>  
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =
> Index: etc/config/sunpro.config
> ===================================================================
> --- etc/config/sunpro.config	(revision 475263)
> +++ etc/config/sunpro.config	(working copy)
> @@ -17,7 +17,7 @@
>  CXXFLAGS        = -library=%none
>  CXXPRELINK      = 
>  CPPFLAGS        =
> -LDFLAGS         = -library=%none -L$(LIBDIR)
> +LDFLAGS         = -library=%none
>  LDSOFLAGS       = -G
>  
>  # use CC to invoke the compiler (needed to pick up template
> @@ -62,8 +62,8 @@
>      LIBTHREAD  = -lthread
>  endif
>  
> -MULTI_LDFLAGS_POSIX    = -mt $(LIBTHREAD)
> -MULTI_LDFLAGS_SOLARIS  = -mt $(LIBPTHREAD)
> +MULTI_LDFLAGS_POSIX    = -mt $(LIBPTHREAD)
> +MULTI_LDFLAGS_SOLARIS  = -mt $(LIBTHREAD)
>  MULTI_LDFLAGS_DCE      =
>  
>  # POSIX
> Index: etc/config/vacpp.config
> ===================================================================
> --- etc/config/vacpp.config	(revision 475263)
> +++ etc/config/vacpp.config	(working copy)
> @@ -111,7 +111,7 @@
>  # shared/archive library options
>  SHARED_CXXFLAGS = 
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  = 
> +SHARED_LDFLAGS  = -Wl,-bsvr4,-R$(LIBDIR)
>  
>  ifeq ($(rtl_enabled),1)
>    SHARED_SUFFIX = .so


Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Andrew Black wrote:
[...]
> 
> I've tested on Linux with GCC and ICC using the '-Wl,-R$(LIBDIR)' switch 
> to the compiler, and the desired behavior in the resulting executables 
> is obtained.  I'll check the sunpro patch in shortly.  I intend to post 
> a follow up patch at some point to make this same change for other 
> compilers.

Greetings all.

Attached is the follow-up patch.  Unfortunately, there are a few gaps in 
it.  One set of gaps is that it doesn't add the appropriate switch to 
the como.config, eccp.config, and reliant_cds.config files.  Another set 
of gaps is that compilers haven't been tested off of their 'home' 
platform (Sunpro on Solaris, GCC and ICC on Linux, and so on).  Most 
linkers use -R, but HPUX uses +b, Compaq and IRIX use -rpath, and AIX 
requires -bsrv4 prior to -R.

--Andrew Black

Log:
	* makefile.rules (%.out): Remove runtime alterations of $LD_LIBRARY_PATH.
	(run runall run_all): Ditto.
	* sunpro.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch.  Switch 
is added if needed in makefile.common.
	(MULTI_LDFLAGS_POSIX, MULTI_LDFLAGS_SOLARIS): Use $(LIBPTHREAD) for 
MULTI_LDFLAGS_POSIX and $(LIBTHREAD) for MULTI_LDFLAGS_SOLARIS.  Had 
been reversed at some point by mistake.
	* acc.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch.  Switch is 
added if needed in makefile.common.
	(SHARED_LDFLAGS): Add rpath switch to include $(LIBDIR) in ld search 
path of executables.
	* gcc.config (SHARED_LDFLAGS): Ditto.
	* icc.config (SHARED_LDFLAGS): Ditto.
	* mipspro.config (LDFLAGS): Remove redundant -L$(LIBDIR) switch. 
Switch is added if needed in makefile.common.
	(SHARED_LDFLAGS): Add rpath switch to include $(LIBDIR) in ld search 
path of executables.
	* osf_cxx.config (SHARED_LDFLAGS): Ditto.
	* vacpp.config (SHARED_LDFLAGS): Ditto.

Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Martin Sebor wrote:
> Andrew Black wrote:
> [...]
>> The SunPro documentation (on Solaris) states that the option is passed 
>> to ld, and both Solaris and Linux use that flag for the same purpose. 
>> Do we have SunPro installed on any of our Linux build servers?  I am 
>> not aware of it being available anywhere, but I could be mistaken.  If 
>> it is available, I'll run a test build there prior to committing the 
>> patch.
> 
> If Linux has -R too it should be safe to check it in (Poul says
> we don't have a Linux machine with Sun C++ installed so we don't
> have an easy way of verifying it unless you want to check it
> with gcc).

I've tested on Linux with GCC and ICC using the '-Wl,-R$(LIBDIR)' switch 
to the compiler, and the desired behavior in the resulting executables 
is obtained.  I'll check the sunpro patch in shortly.  I intend to post 
a follow up patch at some point to make this same change for other 
compilers.

--Andrew Black

> 
> Martin
> 
>>
>> --Andrew Black
> 

Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
[...]
> The SunPro documentation (on Solaris) states that the option is passed 
> to ld, and both Solaris and Linux use that flag for the same purpose. Do 
> we have SunPro installed on any of our Linux build servers?  I am not 
> aware of it being available anywhere, but I could be mistaken.  If it is 
> available, I'll run a test build there prior to committing the patch.

If Linux has -R too it should be safe to check it in (Poul says
we don't have a Linux machine with Sun C++ installed so we don't
have an easy way of verifying it unless you want to check it
with gcc).

Martin

> 
> --Andrew Black


Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Martin Sebor wrote:
> Andrew Black wrote:
>> Greetings all.
>>
>> According to the thread from the Sun Studio C++ forum, it is 
>> recommended that that reliance on the LD_LIBRARY_PATH variables be 
>> avoided.  Rather,  it is recommended that such references be added to 
>> executables using the RPATH setting.
>>
>> To this end, a revised patch and ChangeLog have been included below 
>> that attempt to resolve this issue in the recommended manner.
> 
> Cool! Have you checked to make sure the -R option works on
> Linux? If so, go ahead and commit it. Otherwise let's either
> guard the change for that OS or remove it.
> 
> Thanks
> Martin

The SunPro documentation (on Solaris) states that the option is passed 
to ld, and both Solaris and Linux use that flag for the same purpose. 
Do we have SunPro installed on any of our Linux build servers?  I am not 
aware of it being available anywhere, but I could be mistaken.  If it is 
available, I'll run a test build there prior to committing the patch.

--Andrew Black

Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Greetings all.
> 
> According to the thread from the Sun Studio C++ forum, it is recommended 
> that that reliance on the LD_LIBRARY_PATH variables be avoided.  Rather, 
>  it is recommended that such references be added to executables using 
> the RPATH setting.
> 
> To this end, a revised patch and ChangeLog have been included below that 
> attempt to resolve this issue in the recommended manner.

Cool! Have you checked to make sure the -R option works on
Linux? If so, go ahead and commit it. Otherwise let's either
guard the change for that OS or remove it.

Thanks
Martin

> 
> --Andrew Black
> 
> Martin Sebor wrote:
> 
>> Since the Sun C++ user manual doesn't explain which variable
>> is set in a typical installation of the compiler I posted the
>> question below to the Sun Studio C++ forum to help us decide
>> how to proceed:
>> http://forum.sun.com/jive/thread.jspa?threadID=111021
>>
>> Martin
> 
> 
> ChangeLog:
>     * sunpro.config (SHARED_LDFLAGS): Add -R$(LIBDIR) switch so 
> $(LIBDIR) is included in the runtime library search path of linked 
> executables.
> 
> Index: etc/config/sunpro.config
> ===================================================================
> --- etc/config/sunpro.config    (revision 474551)
> +++ etc/config/sunpro.config    (working copy)
> @@ -35,7 +35,7 @@
>  # shared/static library options
>  SHARED_CXXFLAGS =
>  SHARED_CPPFLAGS =
> -SHARED_LDFLAGS  =
> +SHARED_LDFLAGS  = -R$(LIBDIR)
> 
>  STATIC_CXXFLAGS =
>  STATIC_CPPFLAGS =


Re: [PATCH] Library path fix

Posted by Andrew Black <ab...@roguewave.com>.
Greetings all.

According to the thread from the Sun Studio C++ forum, it is recommended 
that that reliance on the LD_LIBRARY_PATH variables be avoided.  Rather, 
  it is recommended that such references be added to executables using 
the RPATH setting.

To this end, a revised patch and ChangeLog have been included below that 
attempt to resolve this issue in the recommended manner.

--Andrew Black

Martin Sebor wrote:
> Since the Sun C++ user manual doesn't explain which variable
> is set in a typical installation of the compiler I posted the
> question below to the Sun Studio C++ forum to help us decide
> how to proceed:
> http://forum.sun.com/jive/thread.jspa?threadID=111021
> 
> Martin

ChangeLog:
	* sunpro.config (SHARED_LDFLAGS): Add -R$(LIBDIR) switch so $(LIBDIR) 
is included in the runtime library search path of linked executables.

Index: etc/config/sunpro.config
===================================================================
--- etc/config/sunpro.config	(revision 474551)
+++ etc/config/sunpro.config	(working copy)
@@ -35,7 +35,7 @@
  # shared/static library options
  SHARED_CXXFLAGS =
  SHARED_CPPFLAGS =
-SHARED_LDFLAGS  =
+SHARED_LDFLAGS  = -R$(LIBDIR)

  STATIC_CXXFLAGS =
  STATIC_CPPFLAGS =

Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Since the Sun C++ user manual doesn't explain which variable
is set in a typical installation of the compiler I posted the
question below to the Sun Studio C++ forum to help us decide
how to proceed:
http://forum.sun.com/jive/thread.jspa?threadID=111021

Martin

Martin Sebor wrote:
> Andrew Black wrote:
> 
>> Greetings all.
>>
>> Attached is a patch that aims to fix a bug that manifests itself when 
>> running 64-bit builds on SPARC Solaris.  The issue that arises is that 
>> dynamic builds of this type use the LD_LIBRARY_PATH_64 variable to 
>> determine where to locate shared libraries, rather than the 
>> LD_LIBRARY_PATH variable used almost everywhere else.
> 
> 
> According to the Environment Variables section of the Sun ld man
> page: http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9jt?a=view
> the runtime loader does use LD_LIBRARY_PATH for both 32 and 64-bit
> libs, but only when the suffix version of the variable is not
> defined. I.e., the variable with the _64 suffix (or _32 for 32-bit
> executables) takes precedence over the general LD_LIBRARY_PATH. We
> appear to set both in our environment so the stdcxx infrastructure
> needs to use the width-specific variable. But in an environment
> where only LD_LIBRARY_PATH is set stdcxx should probably use it
> in favor of the specific variable, otherwise we might cause the
> loader to fail to find the libraries pointed to by the generic
> variable. Another alternative might be for us to set the suffixed
> variable to the concatenation of the generic one and our paths if
> it's not defined.
> 
> I.e., in shell, something like
> 
>     if [ -z $LD_LIBRARY_PATH_64 ]; then
>         LD_LIBRARY_PATH_64=$LIBDIR:$LD_LIBRARY_PATH
>     else
>         LD_LIBRARY_PATH_64=$LIBDIR:$LD_LIBRARY_PATH_64
>     fi
> 
> Also, I would like to suggest a different name for the variable.
> How about LDSOVAR? (It's a VARiable specific to LD.SO, the Shared
> Object LoaDer aka dynamic linker). It would go with LDSOFLAGS.
> 
> Martin


Re: [PATCH] Library path fix

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Greetings all.
> 
> Attached is a patch that aims to fix a bug that manifests itself when 
> running 64-bit builds on SPARC Solaris.  The issue that arises is that 
> dynamic builds of this type use the LD_LIBRARY_PATH_64 variable to 
> determine where to locate shared libraries, rather than the 
> LD_LIBRARY_PATH variable used almost everywhere else.

According to the Environment Variables section of the Sun ld man
page: http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9jt?a=view
the runtime loader does use LD_LIBRARY_PATH for both 32 and 64-bit
libs, but only when the suffix version of the variable is not
defined. I.e., the variable with the _64 suffix (or _32 for 32-bit
executables) takes precedence over the general LD_LIBRARY_PATH. We
appear to set both in our environment so the stdcxx infrastructure
needs to use the width-specific variable. But in an environment
where only LD_LIBRARY_PATH is set stdcxx should probably use it
in favor of the specific variable, otherwise we might cause the
loader to fail to find the libraries pointed to by the generic
variable. Another alternative might be for us to set the suffixed
variable to the concatenation of the generic one and our paths if
it's not defined.

I.e., in shell, something like

     if [ -z $LD_LIBRARY_PATH_64 ]; then
         LD_LIBRARY_PATH_64=$LIBDIR:$LD_LIBRARY_PATH
     else
         LD_LIBRARY_PATH_64=$LIBDIR:$LD_LIBRARY_PATH_64
     fi

Also, I would like to suggest a different name for the variable.
How about LDSOVAR? (It's a VARiable specific to LD.SO, the Shared
Object LoaDer aka dynamic linker). It would go with LDSOFLAGS.

Martin