Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 420575 - dev-lang/python:2.7 should not patch distutils to omit -fno-strict-aliasing
Summary: dev-lang/python:2.7 should not patch distutils to omit -fno-strict-aliasing
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-10 20:10 UTC by Marien Zwart (RETIRED)
Modified: 2023-07-28 22:27 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
updated patch (21_all_distutils_c++.patch,12.96 KB, text/plain)
2012-06-10 20:10 UTC, Marien Zwart (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marien Zwart (RETIRED) gentoo-dev 2012-06-10 20:10:26 UTC
Created attachment 314891 [details]
updated patch

dev-lang/python-2.7.3-r2 and -r3 (and probably other versions) apply a patch (21_all_distutils_c++.patch in the patchset) that changes distutils so that -fno-strict-aliasing is no longer passed to the compiler when building extension codes. This change is dangerous and the patch should be adjusted so at least BASECFLAGS is included (updated patch attached). As judging from discussion on #gentoo-python some people consider this a feature let me explain why this is not something we want to deviate from upstream on.

First a practical example of why this is dangerous. Building twisted-12.1.0 without -fno-strict-aliasing, with gcc 4.6.3 on a ~amd64 system, results in its sendmsg module misbehaving non-obviously: a python call like send1msg(fd, "blonk", 0, [(SOL_SOCKET, SCM_RIGHTS, pack("i", pipeIn))]) results in a syscall with cmsg_level=SOL_IP (not SOL_SOCKET), which doesn't work. There is no compile-time warning (with -Wall added to CFLAGS). The testsuite catches this, but not every package is going to have one that does. Also, on amd64 stable (gcc 4.5) the same code *does* work without -fno-strict-aliasing. So just the developer running tests before committing does not save you.

Some further explanation can be found in http://python.org/dev/peps/pep-3123/ , which describes how python 2 is broken by design without -fno-strict-aliasing. Something worth noting here is that any code handling a PyObject* and a more specific PyFooObject* to the same object is broken when compiled without -fno-strict-aliasing, but the compiler can only warn you about that if it can see the cast between those distinct pointer types. If the cast is in a function in a different compilation unit it may warn you then, but applying -fno-strict-aliasing to the function with the cast won't make the code in the other file work.

Attached is an updated version of 21_all_distutils_c++.patch that re-inserts -fno-strict-aliasing. For your reviewing convenience https://dev.gentoo.org/~marienz/21_all_distutils_c++.interdiff compares the old patch to the new. I propose revbumping python 2.7.3 with this modified patch (or the interdiff as an additional patch, if you prefer).
Comment 1 Mike Gilbert gentoo-dev 2015-08-22 17:22:53 UTC
I support this change.

The previous python maintainer did not want to do it because there may be some code that does not require -fno-strict-aliasing to compile correctly, and strict aliasing may have some benefit. After thinking on it for a year or two, this just seems silly to me.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-04-20 21:50:48 UTC
Ping.  Do we want to proceed here?
Comment 3 David Seifert gentoo-dev 2023-07-28 22:27:20 UTC
I don't think this bug matters anymore.