Skip to content

Commit

Permalink
BUG: Do not double-quote arguments passed on to the linker
Browse files Browse the repository at this point in the history
After the recent patch to CCompiler.spawn, the file-paths no longer need manual quoting - that's handled as needed within subprocess.

This also states our assumption that our paths do not contain commas.
If we care about this, we could adopt the approach used by rust-lang/rust#38795.

Tested for gcc locally by looking at the error messages of `subprocess.check_call(["gcc", r'-Wl,spaces and no quotes'])`

Other fortran compiler changes not tested, but assumed to be broken in the same way.

Fixes numpy#12882
  • Loading branch information
eric-wieser committed Jan 31, 2019
1 parent 87d0528 commit 37ba40b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion numpy/distutils/fcompiler/absoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_flags_linker_so(self):

def library_dir_option(self, dir):
if os.name=='nt':
return ['-link', '/PATH:"%s"' % (dir)]
return ['-link', '/PATH:%s' % (dir)]
return "-L" + dir

def library_option(self, lib):
Expand Down
5 changes: 4 additions & 1 deletion numpy/distutils/fcompiler/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ def runtime_library_dir_option(self, dir):
# Linux/Solaris/Unix support RPATH, Windows and AIX do not
raise NotImplementedError

# TODO: could use -Xlinker here, if it's supported
assert "," not in dir

sep = ',' if sys.platform == 'darwin' else '='
return '-Wl,-rpath%s"%s"' % (sep, dir)
return '-Wl,-rpath%s%s' % (sep, dir)


class Gnu95FCompiler(GnuFCompiler):
Expand Down
5 changes: 4 additions & 1 deletion numpy/distutils/fcompiler/intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def update_executables(self):
f + '.f', '-o', f + '.o']

def runtime_library_dir_option(self, dir):
return '-Wl,-rpath="%s"' % dir
# TODO: could use -Xlinker here, if it's supported
assert "," not in dir

return '-Wl,-rpath=%s' % dir


class IntelFCompiler(BaseIntelFCompiler):
Expand Down
2 changes: 1 addition & 1 deletion numpy/distutils/fcompiler/pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_flags_linker_so(self):
return ["-dynamic", '-undefined', 'dynamic_lookup']

def runtime_library_dir_option(self, dir):
return '-R"%s"' % dir
return '-R%s' % dir


if sys.version_info >= (3, 5):
Expand Down
2 changes: 1 addition & 1 deletion numpy/distutils/fcompiler/sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_libraries(self):
return opt

def runtime_library_dir_option(self, dir):
return '-R"%s"' % dir
return '-R%s' % dir

if __name__ == '__main__':
from distutils import log
Expand Down

0 comments on commit 37ba40b

Please sign in to comment.