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
configure: allow user-provided CFLAGS to override AC_PROG_CC defaults #52458
Comments
configure.in uses AC_PROG_CC, extract of the autoconf manual: If using the GNU C compiler, set shell variable GCC to Python does already set the optimization level in its OPT variable: for gcc, it uses -O3 by default, and not -O option (in this case, gcc disables all optimisations, it's like -O0) if --with-pydebug is used. Because of AC_PROG_CC, Python is compiled with -O2 even if --with-pydebug is used, which is bad because it's harder to debug an optimized program: most variable are unavailable (gcc prints "<optimized out>"). Another problem is that AC_PROG_CC eats user CFLAGS. It's not possible to specify: ./configure CFLAGS="myflags". On the autoconf mailing list, I saw a simple "trick": Save CFLAGS before you call AC_PROG_CC, and restore it after, Attached patch implements that. Results:
It works :-) |
Setting CFLAGS is broken in Python configure system, so it's better not to rely on it (or to fix it, but that's a major task - the whole CFLAGS and LDFLAGS system used in Python's configure has over the years turned into a complete mess). You should get the same result by using ./configure OPT="-O0". |
What do you mean by "a complete mess"? Did you try my patch? Is it enough to fix this issue? A least, my patch is enough to disable all compilation optimization if --with-pydebug option is used (which was my first goal). |
STINNER Victor wrote:
There's a discussion on some other ticket about this. Basically, It adds all sorts of non-standard variables which are then combined
No. It doesn't allow overriding the CFLAGS settings actually
It unconditionally overrides CFLAGS - even if it is not set and Other than that it does help a little work around the mess :-) |
MaL> It unconditionally overrides CFLAGS - even if it is not I commited my patch: r79392 (trunk). I'm waiting for the buildbots before porting to other branches :-) On my Linux, .c files are now compiled with:
|
The buildbots look happy => r79401 (py3k), blocked in 2.6 and 3.1 The issue title was "configure: ignore AC_PROG_CC hardcoded CFLAGS", and not "fix configure", so I can close the issue. Marc-Andre: open a new issue if you are motivated to fix "configure mess" :-) |
STINNER Victor wrote:
The patch you checked in still unconditionally overrides the Please fix that or revert the patch. |
STINNER Victor wrote:
The issue now is: AC_PROG_CC no longer initializes CFLAGS if not set.
Some other day... |
MaL> The patch you checked in still unconditionally overrides the Sorry, but I don't understand. Why should it be initialized? I don't like the default value because it enables optimization when --with-pydebug is used and I consider that as a bug. If no configure option is used, Python adds -O3 as before. About -g: Python always add it, so the -g from AC_PROG_CC was redundant. In Makefile.pre.in, prefixes and suffixes are added to the CFLAGS: "CFLAGS= |
STINNER Victor wrote:
Sorry, perhaps I wasn't clear enough. The purpose of AC_PROG_CC is to setup the env vars depending on Since CFLAGS will most of the time not be set by the user
Right, but it's possible that AC_PROG_CC adds other flags I'd suggest to only override the CFLAGS setting in case it In addition, it may be useful to have --with-pydebug replace OPT
Right. That's for historic reasons. OPT is very old, BASECFLAGS |
Note these changes to restore CFLAGS have the side effect of breaking OS X universal builds; see bpo-8366. |
Victor, could you please fix the patch or revert it ? Thanks. |
Reopening the ticket: it shouldn't have been closed. I'm also making this a release blocker, since this needs to be fixed before the next release - the CC variable has to be initialized by the build system and breaking this in general for all default builds just to get a debug build without optimizations is not warranted. |
To be totally fair, it is likely that part of the OS X breakage was caused by the original code inadvertently working around the original CFLAGS misbehavior. From an OS X perspective, it may be best to just fix the new issue and move on. |
Issue bpo-8366 was caused by a fix of issue bpo-1628484 (and ok, indirectly by my change). Issue bpo-8366 is now fixed. Can I close this issue again or do you think that there is still something to do? |
I think the issue can be closed again. |
Even if this issue doesn't fix all the configure "complete mess", I think that it improves it a little bit. Open new issues if you would like to fix other parts of the configure script. |
Viktor, you are still missing the point and please stop closing the issue again and again. Please change the configure.in script to only override the CFLAGS in case they were set before entering the AC_PROG_CC part ! I've explained that over and over again and I don't understand why you are being completely ignorant of the implications of your change. The Mac OS X fix is unrelated to this change. |
Marc-Andre Lemburg wrote:
Sorry, this should have read: ... if CFLAGS *were* set before entering AC_PROG_CC ...
One of the main purposes of AC_PROG_CC is to setup CFLAGS in case |
Sorry but i don't really understand the problem of my patch, and I don't want to spend time of this. Revert my patch if you think that it introduced a regression. |
STINNER Victor wrote:
See the new implementation for what I meant... r80665 - in python/trunk: configure configure.in [bpo-8211] configure: ignore AC_PROG_CC hardcoded CFLAGS Only override the AC_PROG_CC determined CFLAGS if they were set by the user. |
Since r80665, a ./configure --with-pydebug seems to give compilation with -O2 (tested on OS X and Linux). Is this intentional? I'm getting, e.g., gcc -c -g -O2 -g -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c |
Mark Dickinson wrote:
Yes. I've restored the previous behavior of configure to Please open a new ticket to have --with-pydebug disable use |
Marc-Andre Lemburg wrote:
Note that using the following line will disable the AC_PROG_CC ./configure --with-pydebug CFLAGS='' This is a new feature that was introduced previously by Victor |
Just to be clear, the previous behaviour has *not* been restored. Up until r80665, a '--with-pydebug' build did not include optimization. Since r80665, it does. |
Ah, I understand now: -O2 started appearing in debug builds in r79218, which changed the Makefile to respect CFLAGS. I tested a variety of revision, but failed to test revision in between that and Victor's change... |
Mark Dickinson wrote:
Right. I was referring to r79391, ie. the state before Victor checked |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: