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

./configure --with-pydebug on FreeBSD results in -O2 -pipe eventually ending up in CFLAGS. #59961

Closed
tpn opened this issue Aug 21, 2012 · 5 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@tpn
Copy link
Member

tpn commented Aug 21, 2012

BPO 15757
Nosy @tpn, @koobs

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/tpn'
closed_at = <Date 2021-12-10.09:42:24.482>
created_at = <Date 2012-08-21.21:29:40.535>
labels = ['type-bug']
title = './configure --with-pydebug on FreeBSD results in -O2 -pipe eventually ending up in CFLAGS.'
updated_at = <Date 2021-12-10.09:42:24.482>
user = 'https://github.com/tpn'

bugs.python.org fields:

activity = <Date 2021-12-10.09:42:24.482>
actor = 'iritkatriel'
assignee = 'trent'
closed = True
closed_date = <Date 2021-12-10.09:42:24.482>
closer = 'iritkatriel'
components = []
creation = <Date 2012-08-21.21:29:40.535>
creator = 'trent'
dependencies = []
files = []
hgrepos = []
issue_num = 15757
keywords = []
message_count = 5.0
messages = ['168805', '168807', '168810', '168849', '180130']
nosy_count = 2.0
nosy_names = ['trent', 'koobs']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue15757'
versions = ['Python 3.2', 'Python 3.3']

@tpn
Copy link
Member Author

tpn commented Aug 21, 2012

All the FreeBSD build slaves seem to be experiencing the same symptom: ./configure --with-pydebug eventually results in this:

gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes  -O2 -pipe -fno-strict-aliasing -Wall -march=native   -I. -I./Include    -DPy_BUILD_CORE -o [Modules/python.o](https://github.com/python/cpython/blob/main/Modules/python.o) ./Modules/python.c

What I find odd:

% grep -e '-O2' Makefile | wc -l
0

There are references to -O2 elsewhere, like in configure.ac|configure, but, the Makefile doesn't source any of those. (Right?)

This is occurring on all of my slaves as well as others, so I'm pretty sure it's not just specific to my environment.

@tpn tpn self-assigned this Aug 21, 2012
@tpn tpn added the type-bug An unexpected behavior, bug, or error label Aug 21, 2012
@tpn
Copy link
Member Author

tpn commented Aug 21, 2012

Ah!

% gmake
gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
^C

% make

% make
gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -O2 -pipe -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -O2 -pipe -I. -I./Include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -Wall -Wstrict-prototypes -O2 -pipe -I. -I./Include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
^C

So, the default BSD make likes to add in -O2 -pipe. I'll do a bit more digging.

@tpn
Copy link
Member Author

tpn commented Aug 21, 2012

So, looks like FreeBSD's /usr/share/mk/sys.mk is to blame here. It unconditionally sets CFLAGS to -O2 -pipe.

[trent@hydrogen/ttypts/1(~s/cpython)%] uname -a
FreeBSD hydrogen.snakebite.net 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r0: Mon Jul 16 06:28:19 UTC 2012 root@hydrogen.snakebite.net:/usr/obj/src/freebsd/9/r238513m/sys/AMD64 amd64

[trent@hydrogen/ttypts/1(~s/cpython)%] grep -A3 'bsd_make_test' Makefile
bsd_make_test:
@echo "CFLAGS: $(CFLAGS)"
@echo "EXTRA_CFLAGS: $(EXTRA_CFLAGS)"

[trent@hydrogen/ttypts/1(~s/cpython)%] make bsd_make_test
CFLAGS: -O2 -pipe
EXTRA_CFLAGS:

[trent@hydrogen/ttypts/1(~s/cpython)%] make CFLAGS= bsd_make_test
CFLAGS:
EXTRA_CFLAGS:

I can think of a few ways to work around this... some better than others.

  1. Change the FreeBSD buildbots to always invoke make via make CFLAGS=.

  2. Hack configure.* to automatically invoke make via make CFLAGS= when -O2 -pipe crops up in a --with-pydebug build.

Some of the less desirable ones:

  1. Switch FreeBSD to gmake.

  2. Patch FreeBSD make so that it is 'debug aware' and stops appending -O2 everywhere.

@skrah
Copy link
Mannequin

skrah mannequin commented Aug 22, 2012

So, looks like FreeBSD's /usr/share/mk/sys.mk is to blame here.
It unconditionally sets CFLAGS to -O2 -pipe.

I've been debugging this once, too. My conclusion was that if the OS is set up
that way, we shouldn't do anything about it in the Python source tree.

All important features of --with-pydebug should also work if -O0 is overridden
by -O2.

So I think that FreeBSD users who really want -O0 should change sys.mk
or set CFLAGS manually. For the buildbots it should not matter, except
that compile times are slower.

@skrah
Copy link
Mannequin

skrah mannequin commented Jan 17, 2013

Trent, do you want to keep this open? I think sys.mk is behaving exactly
as intended.

@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
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants