Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete Python LDFLAGS and CPPFLAGS used for extension modules on posix #59223

Closed
marcusva mannequin opened this issue Jun 6, 2012 · 3 comments
Closed

Incomplete Python LDFLAGS and CPPFLAGS used for extension modules on posix #59223

marcusva mannequin opened this issue Jun 6, 2012 · 3 comments
Assignees
Labels
build The build process and cross-build extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@marcusva
Copy link
Mannequin

marcusva mannequin commented Jun 6, 2012

BPO 15018
Nosy @jcea, @tarekziade, @merwok, @koobs, @zooba

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/merwok'
closed_at = <Date 2021-02-03.18:16:16.096>
created_at = <Date 2012-06-06.12:51:42.648>
labels = ['extension-modules', 'type-bug', 'library', 'build']
title = 'Incomplete Python LDFLAGS and CPPFLAGS used for extension modules on posix'
updated_at = <Date 2021-02-03.18:16:16.095>
user = 'https://bugs.python.org/marcusva'

bugs.python.org fields:

activity = <Date 2021-02-03.18:16:16.095>
actor = 'steve.dower'
assignee = 'eric.araujo'
closed = True
closed_date = <Date 2021-02-03.18:16:16.096>
closer = 'steve.dower'
components = ['Build', 'Distutils', 'Extension Modules']
creation = <Date 2012-06-06.12:51:42.648>
creator = 'marcusva'
dependencies = []
files = []
hgrepos = []
issue_num = 15018
keywords = []
message_count = 3.0
messages = ['162405', '224660', '386294']
nosy_count = 7.0
nosy_names = ['jcea', 'tarek', 'eric.araujo', 'rpetrov', 'marcusva', 'koobs', 'steve.dower']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue15018'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

@marcusva
Copy link
Mannequin Author

marcusva mannequin commented Jun 6, 2012

If CPython is built and installed with additional CPPFLAGS and/or LDFLAGS on a posix platform, those flags are not passed to C extension modules, leaving users (in the worst case) lost without the ability to build and install C extension modules, if the flags are important for detecting include files or linking.

Example:

  • Python shall be built with GNU pthreads (--with-pth)
  • The pth libs are not installed in any default location, CPP and LD know about, but somewhere else (e.g. /usr/local/lib/pth/ and /usr/local/include/pth/)
  • Appropriate CPPFLAGS="-I/usr/local/include/pth" and LDFLAGS="-L/usr/local/lib/pth" are defined in the environment for the build.

Python gets built and installed. Result in /wherever/pythonX.X/config/Makefile:

...
OPT=
BASECFLAGS= -fno-strict-aliasing
CFLAGS= $(BASECFLAGS) -pipe $(OPT) $(EXTRA_CFLAGS)
...
CPPFLAGS= -I. -IInclude -I$(srcdir)/Include -I/usr/local/include/pth
LDFLAGS= -L/usr/local/lib/pth
...

Invocation of python-config --cflags:

# python-config --cflags
-I/whereever/include/pythonX.X -I/whereever/include/pythonX.X -fno-strict-aliasing -pipe

Invocation of python-config --ldflags:

# python-config --ldflags
-L/whereever/lib/pythonX.X/config -lpth -lutil -lm -lpythonX.X

So far, so problematic. Since Python.h incorporates pth.h, compiling something without defining the necessary CPPFLAGS manually will fail. Same for linking.

The issue is *not* limited to --with-pth, but to any CPPFLAGS/LDFLAGS settings that are necessary to get CPython to work on the target platform. One might argue that CPPFLAGS should go to CFLAGS, but that contradicts the purpose of CPPFLAGS and CFLAGS.

At least for posix-alike platforms (those for which _init_posix() is called in distutils/sysconfig.py), it is necessary that both, python-config as well as the distutils internals add the appropriate CPPFLAGS.

It might be argued that one should use CFLAGS instead of CPPFLAGS for such important additional flags, but what shall be done with LDFLAGS then?

@marcusva marcusva mannequin assigned merwok Jun 6, 2012
@marcusva marcusva mannequin added build The build process and cross-build stdlib Python modules in the Lib dir extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Jun 6, 2012
@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Aug 3, 2014

Who is best placed to comment on build issues?

@zooba
Copy link
Member

zooba commented Feb 3, 2021

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

@zooba zooba closed this as completed Feb 3, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants