classification
Title: distutils appends LDFLAGS environment variable before object file names
Type: Stage: resolved
Components: Distutils Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, dstufft, eric.araujo, ozars, steve.dower
Priority: normal Keywords:

Created on 2019-07-25 13:22 by ozars, last changed 2021-02-03 18:10 by steve.dower. This issue is now closed.

Files
File name Uploaded Description Edit
python-issue.tar.gz ozars, 2019-07-25 13:22
python-issue-2.tar.gz ozars, 2019-07-25 13:34
Messages (3)
msg348436 - (view) Author: Omer Ozarslan (ozars) Date: 2019-07-25 13:22
distutils honors some environment variables during extension build, however, LDFLAGS is appended before declaring object files. This causes undefined symbols during importing an extension built with some static libraries using this environment variable. This is not apparent in the case of dynamic linking, but it can be observed by adding "-Wl,--as-needed" flag, since this will link libraries only if they are required. Therefore, it will be necessary to add them after object files in case of dynamic linking as well in that case.

I believe this part is the culprit as it appends LDFLAGS environment variable to executable name: https://github.com/python/cpython/blob/c994c8f/Lib/distutils/sysconfig.py#L211-L235

I attached a minimal example (it requires cython, which relies on distutils for compilation).

It would be nice if LDFLAGS is appended after object files, or a new environment variable (e.g. LDLIBS) is introduced to distutils to be appended after object files.
msg348438 - (view) Author: Omer Ozarslan (ozars) Date: 2019-07-25 13:34
Attached a better example. Run make (static_example|shared_example|working_shared_example).
msg386285 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:10
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
2021-02-03 18:10:54steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386285

resolution: out of date
stage: resolved
2019-07-25 15:12:15BTaskayasetnosy: + BTaskaya
2019-07-25 13:34:29ozarssetfiles: + python-issue-2.tar.gz

messages: + msg348438
2019-07-25 13:22:47ozarscreate