nanomsg-python icon indicating copy to clipboard operation
nanomsg-python copied to clipboard

Create custom `build_ext` for correct rpath linking on mac

Open noahness opened this issue 5 years ago • 0 comments

Workaround distutils bug 36353; see https://bugs.python.org/issue36353. On MacOS, the build_ext --rpath option is getting converted to -L rather than -Wl,-rpath=. This change sub-classes build_ext and correctly passes appropriate rpath options to clang linker.

Snippet from distutils.unixccompiler.py:

  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
        elif sys.platform[:7] == "freebsd":
            return "-Wl,-rpath=" + dir
        elif sys.platform[:5] == "hp-ux":
            if self._is_gcc(compiler):
                return ["-Wl,+s", "-L" + dir]
            return ["+s", "-L" + dir]

Workaround code taken from https://github.com/python/cpython/pull/12418.

noahness avatar Mar 03 '20 23:03 noahness