]> granicus.if.org Git - python/commitdiff
When using GCC, use the right option to add a directory to the list of dirs
authorFred Drake <fdrake@acm.org>
Tue, 11 Dec 2001 05:04:24 +0000 (05:04 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 11 Dec 2001 05:04:24 +0000 (05:04 +0000)
searched for a dependency for runtime linking.
This closes SF bug #445902.

Lib/distutils/unixccompiler.py

index a9b5de51cea57d815fb587bc0d1c992a467c600e..356587d6003a6640751dc3e1f6da7fc7c606fb2e 100644 (file)
@@ -20,6 +20,7 @@ __revision__ = "$Id$"
 import string, re, os
 from types import *
 from copy import copy
+from distutils import sysconfig
 from distutils.dep_util import newer
 from distutils.ccompiler import \
      CCompiler, gen_preprocess_options, gen_lib_options
@@ -249,7 +250,23 @@ class UnixCCompiler (CCompiler):
         return "-L" + dir
 
     def runtime_library_dir_option (self, dir):
-        return "-R" + dir
+        # XXX Hackish, at the very least.  See Python bug #445902:
+        # http://sourceforge.net/tracker/index.php
+        #   ?func=detail&aid=445902&group_id=5470&atid=105470
+        # Linkers on different platforms need different options to
+        # specify that directories need to be added to the list of
+        # directories searched for dependencies when a dynamic library
+        # is sought.  GCC has to be told to pass the -R option through
+        # to the linker, whereas other compilers just know this.
+        # Other compilers may need something slightly different.  At
+        # this time, there's no way to determine this information from
+        # the configuration data stored in the Python installation, so
+        # we use this hack.
+        compiler = os.path.basename(sysconfig.get_config_var("CC"))
+        if compiler == "gcc" or compiler == "g++":
+            return "-Wl,-R" + dir
+        else:
+            return "-R" + dir
 
     def library_option (self, lib):
         return "-l" + lib