Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d15db5c

Browse files
committed
When using GCC, use the right option to add a directory to the list of dirs
searched for a dependency for runtime linking. This closes SF bug #445902.
1 parent 29d2606 commit d15db5c

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Lib/distutils/unixccompiler.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import string, re, os
2121
from types import *
2222
from copy import copy
23+
from distutils import sysconfig
2324
from distutils.dep_util import newer
2425
from distutils.ccompiler import \
2526
CCompiler, gen_preprocess_options, gen_lib_options
@@ -249,7 +250,23 @@ def library_dir_option (self, dir):
249250
return "-L" + dir
250251

251252
def runtime_library_dir_option (self, dir):
252-
return "-R" + dir
253+
# XXX Hackish, at the very least. See Python bug #445902:
254+
# http://sourceforge.net/tracker/index.php
255+
# ?func=detail&aid=445902&group_id=5470&atid=105470
256+
# Linkers on different platforms need different options to
257+
# specify that directories need to be added to the list of
258+
# directories searched for dependencies when a dynamic library
259+
# is sought. GCC has to be told to pass the -R option through
260+
# to the linker, whereas other compilers just know this.
261+
# Other compilers may need something slightly different. At
262+
# this time, there's no way to determine this information from
263+
# the configuration data stored in the Python installation, so
264+
# we use this hack.
265+
compiler = os.path.basename(sysconfig.get_config_var("CC"))
266+
if compiler == "gcc" or compiler == "g++":
267+
return "-Wl,-R" + dir
268+
else:
269+
return "-R" + dir
253270

254271
def library_option (self, lib):
255272
return "-l" + lib

0 commit comments

Comments
 (0)