diff --git a/changelog.d/2627.change.rst b/changelog.d/2627.change.rst new file mode 100644 index 0000000000..1da9a681a3 --- /dev/null +++ b/changelog.d/2627.change.rst @@ -0,0 +1 @@ +Honor `runtime_library_dirs` on macOS by passing `-rpath` to the linker diff --git a/setuptools/_distutils/unixccompiler.py b/setuptools/_distutils/unixccompiler.py index 4d7a6de740..7fe2eeefed 100644 --- a/setuptools/_distutils/unixccompiler.py +++ b/setuptools/_distutils/unixccompiler.py @@ -233,8 +233,7 @@ def runtime_library_dir_option(self, dir): # we use this hack. compiler = os.path.basename(sysconfig.get_config_var("CC")) if sys.platform[:6] == "darwin": - # MacOSX's linker doesn't understand the -R flag at all - return "-L" + dir + return "-Wl,-rpath," + dir elif sys.platform[:7] == "freebsd": return "-Wl,-rpath=" + dir elif sys.platform[:5] == "hp-ux":