This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: distutils doesn't add "-Wl," prefix to "-R" on Linux if the C compiler isn't named 'gcc'
Type: enhancement Stage: resolved
Components: Distutils Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Calvin Walton, dstufft, eric.araujo, fbissey, ketsubouchi, steve.dower
Priority: normal Keywords: patch

Created on 2015-09-24 21:32 by Calvin Walton, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
distutils-compiler-name.patch Calvin Walton, 2015-09-24 22:11 distutils-compiler-name-2.7.patch
distutils-compiler-name.patch Calvin Walton, 2015-09-24 22:11 distutils-compiler-name-3.x.patch
Pull Requests
URL Status Linked Edit
PR 21957 closed ketsubouchi, 2020-08-26 00:21
Messages (4)
msg251546 - (view) Author: Calvin Walton (Calvin Walton) * Date: 2015-09-24 21:32
On Exherbo, the main C/C++ compilers are named e.g. "x86_64-pc-linux-gnu-cc" and "x86_64-pc-linux-gnu-c++", and they are symlinks to either (usually) gcc or (rarely) clang.

Since distutils (in unixccompiler.py) is checking for the substring "gcc" or "g++" in the compiler name, this does not match our compiler - and the "-Wl," prefix is missing, resulting in link errors in some cases.

(We are particularly noticing this when doing gobject-introspection builds via cmake, where giscanner uses distutils to build the link command)

As far as I know, all major compilers on Linux require the -Wl, option to pass through linker options - clang actually interprets -R without -Wl, to mean something completely different. We are planning to locally patch distutils to have an additional condition to the gcc check, `sys.platform[:5] == "linux" or self._is_gcc(compiler):` in our distribution to work around the issue.

I'll attach patches once they're prepared, but I'd appreciate feedback about the problem.
msg291199 - (view) Author: François Bissey (fbissey) Date: 2017-04-05 22:09
I am seeing this with clang on linux. It breaks the building pyzmq. I'll concur with Calvin that using just "-R" is wrong in the first place. Some compiler may pass it directly to the linker. But even in the linker, interpreting "-R" as a rpath if the argument is a directory, is a legacy behavior. "-R" is supposed to be used to add remarks (see ld's man page).
On linux it should just be "-Wl,-rpath" and it should work with all compilers.
msg375686 - (view) Author: Kenta Tsubouchi (ketsubouchi) Date: 2020-08-20 05:26
This patch seems good for proprietary compilers in linux.
Because such compilers need gcc-style link option.
So I'll make PR.
msg386243 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:05
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69416
2021-02-03 18:05:43steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386243

resolution: out of date
stage: patch review -> resolved
2020-08-26 00:21:26ketsubouchisetstage: patch review
pull_requests: + pull_request21067
2020-08-20 05:26:01ketsubouchisetversions: - Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
nosy: + ketsubouchi

messages: + msg375686

type: enhancement
2017-04-05 22:09:39fbisseysetnosy: + fbissey
messages: + msg291199
2015-09-24 22:11:55Calvin Waltonsetfiles: + distutils-compiler-name.patch
2015-09-24 22:11:27Calvin Waltonsetfiles: + distutils-compiler-name.patch
keywords: + patch
2015-09-24 21:32:11Calvin Waltoncreate