[issue37680] distutils appends LDFLAGS environment variable before object file names

Omer Ozarslan report at bugs.python.org
Thu Jul 25 09:22:47 EDT 2019


New submission from Omer Ozarslan <omerfaruko at gmail.com>:

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.

----------
components: Distutils
files: python-issue.tar.gz
messages: 348436
nosy: dstufft, eric.araujo, ozars
priority: normal
severity: normal
status: open
title: distutils appends LDFLAGS environment variable before object file names
Added file: https://bugs.python.org/file48505/python-issue.tar.gz

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37680>
_______________________________________


More information about the Python-bugs-list mailing list