[Distutils] Runtime library directories

M.-A. Lemburg mal@lemburg.com
Sat Feb 17 05:24:02 2001


"A.M. Kuchling" wrote:
> 
> Something I noticed this evening: unixccompiler.py uses -R<dir> for
> runtime library directives.  That's good syntax for ld, but is it good
> syntax for C compilers?  GCC requires -Wl,-R<dir> instead to pass it
> to the linker; is this standard for Unix C compilers?  I suspect this
> patch below would be too simple to fix the problem, so how to fix
> this?

Are you sure that the ld -R flag is really what you want here ?

The docs say:

       -R filename
              Read  symbol  names  and their addresses from file­
              name, but do not relocate it or include it  in  the
              output.  This allows your output file to refer sym­
              bolically to absolute locations of  memory  defined
              in other programs.

I think that the -rpath ld option is what you are really looking
for:

       -rpath directory
              Add a directory to the runtime library search path.
              This  is  used  when linking an ELF executable with
              shared objects.  All -rpath arguments are  concate­
              nated  and passed to the runtime linker, which uses
              them to locate  shared  objects  at  runtime.   The
              -rpath option is also used when locating shared ob­
              jects which are needed by shared objects explicitly
              included  in  the  link; see the description of the
              -rpath-link option.  If -rpath  is  not  used  when
              linking  an ELF executable, the contents of the en­
              vironment variable LD_RUN_PATH will be used  if  it
              is defined.

              The  -rpath  option  may also be used on SunOS.  By
              default, on SunOS, the linker will form  a  runtime
              search patch out of all the -L options it is given.
              If a -rpath option is used, the runtime search path
              will  be  formed  exclusively  using the -rpath op­
              tions, ignoring the -L options.  This can be useful
              when  using  gcc,  which adds many -L options which
              may be on NFS mounted filesystems.

In any case, I'd say you switch on the compiler name and
leave the -R option in place for all non-gcc compilers until
more testing has been done in this area.

> --amk
> 
> Index: unixccompiler.py
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v
> retrieving revision 1.32
> diff -u -p -r1.32 unixccompiler.py
> --- unixccompiler.py    2000/09/27 02:08:14     1.32
> +++ unixccompiler.py    2001/02/17 04:51:37
> @@ -247,7 +247,7 @@ class UnixCCompiler (CCompiler):
>          return "-L" + dir
> 
>      def runtime_library_dir_option (self, dir):
> -        return "-R" + dir
> +        return "-Wl,-R" + dir
> 
>      def library_option (self, lib):
>          return "-l" + lib
> 
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG@python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/