From 37ba40b7f975f266d24fa916050fa27c88ab9dbf Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Wed, 30 Jan 2019 19:34:58 -0800 Subject: [PATCH] BUG: Do not double-quote arguments passed on to the linker 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 https://github.com/rust-lang/rust/issues/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 #12882 --- numpy/distutils/fcompiler/absoft.py | 2 +- numpy/distutils/fcompiler/gnu.py | 5 ++++- numpy/distutils/fcompiler/intel.py | 5 ++++- numpy/distutils/fcompiler/pg.py | 2 +- numpy/distutils/fcompiler/sun.py | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/numpy/distutils/fcompiler/absoft.py b/numpy/distutils/fcompiler/absoft.py index 2c3edfe02392..d14fee0e18e3 100644 --- a/numpy/distutils/fcompiler/absoft.py +++ b/numpy/distutils/fcompiler/absoft.py @@ -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): diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 0f7e48152bc3..c838f11d64ba 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -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): diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py index 217eac8fbea3..51f6812743a2 100644 --- a/numpy/distutils/fcompiler/intel.py +++ b/numpy/distutils/fcompiler/intel.py @@ -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): diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py index 99071800adad..bf100dfa5446 100644 --- a/numpy/distutils/fcompiler/pg.py +++ b/numpy/distutils/fcompiler/pg.py @@ -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): diff --git a/numpy/distutils/fcompiler/sun.py b/numpy/distutils/fcompiler/sun.py index d477d33087b0..561ea854f982 100644 --- a/numpy/distutils/fcompiler/sun.py +++ b/numpy/distutils/fcompiler/sun.py @@ -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