Python 2.7.x with GCC 8.x and EasyBuild

An attempted build of Python-2.7.13 with GCC-8.2.0 led to an unexpected error where the build failed to generation of POSIX vars. This is kind of important and unsurprisingly, others on in the Python community have noticed it as well both this year, and in a directly related matter from late 2016, with a recommended patchfile provided on the Python-Dev mailing list.

My own contribution to this process is to incorporate the hard and insightful work done by those linked above, with developing an EasyBuild recipe for Python 2.7.x with GCC 8.x. At the moment, EasyBuild does not offer support for GCC8.x, however for those who have their own similar installation processes to the default, the following build script and pathfile might be useful.

Python-2.7.13-GCC-8.2.0-bare.eb


# Built with EasyBuild version 3.7.1 on 2018-12-12_14-27-32
name = 'Python'
version = '2.7.13'
versionsuffix = '-bare'
homepage = 'http://python.org/'
description = "Python is a programming language that lets you work more quickly and integrate your systems more effectively."
toolchain = {'name': 'GCC', 'version': '8.2.0'}
source_urls = ['http://www.python.org/ftp/%(namelower)s/%(version)s/']
sources = [SOURCE_TGZ]
# python needs bzip2 to build the bz2 package
dependencies = [
('bzip2', '1.0.6'),
('zlib', '1.2.11'),
('libreadline', '7.0'),
('ncurses', '6.1'),
('SQLite', '3.25.3'),
('Tk', '8.6.9'),
# ('OpenSSL', '1.0.1k'), # OS dependency should be preferred if the os version is more recent then this version, it's
# nice to have an up to date openssl for security reasons
]
patches = [
'GCC8-Python2.7.x.patch'
]
osdependencies = [('openssl-devel', 'libssl-dev')]
# bare installation: only pip & setuptools included.
exts_list = [
('setuptools', '36.7.2', {
'source_urls': ['https://pypi.python.org/packages/source/s/setuptools/'],
}),
('pip', '9.0.1', {
'source_urls': ['https://pypi.python.org/packages/source/p/pip/'],
})
]
moduleclass = 'lang'

GCC8-Python2.7.x.patch

The patch file is the same as provided in the Python-Dev link, above.


diff Include/objimpl.h Include/objimpl.h
index 55e83eced6..aa906144dc 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -248,6 +248,18 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *
, Py_ssize_t);
/* for source compatibility with 2.2 */
#define _PyObject_GC_Del PyObject_GC_Del
+/* Former over-aligned definition of PyGC_Head, used to compute the
+ size of the padding for the new version below. */
+union _gc_head;
+union _gc_head_old {
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ Py_ssize_t gc_refs;
+ } gc;
+ long double dummy;
+};
+
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ Py_ssize_t gc_refs;
+ } gc;
+ long double dummy;
+};
+
/* GC information is stored BEFORE the object structure. */
typedef union _gc_head {
struct {
@@ -255,7 +267,8 @@ typedef union _gc_head {
union _gc_head *gc_prev;
Py_ssize_t gc_refs;
} gc;
- long double dummy; /* force worst-case alignment */
+ double dummy; /* force worst-case alignment */
+ char dummy_padding[sizeof(union _gc_head_old)];
} PyGC_Head;
extern PyGC_Head *_PyGC_generation0;

GCC-8.2.0.eb


# Built with EasyBuild version 3.6.2 on 2018-10-24_10-03-02
easyblock = 'Bundle'
name = 'GCC'
version = '8.2.0'
binutilsver = '2.30'
#versionsuffix = '-%s' % binutilsver
homepage = 'http://gcc.gnu.org/'
description = """The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, and Ada, as well as libraries for these languages (libstdc++, libgcj,...)."""
toolchain = {'name': 'dummy', 'version': ''}
dependencies = [
('GCCcore', version),
# binutils built on top of GCCcore, which was built on top of (dummy-built) binutils
('binutils', binutilsver, '', ('GCCcore', version)),
]
altroot = 'GCCcore'
altversion = 'GCCcore'
# this bundle serves as a compiler-only toolchain, so it should be marked as compiler (important for HMNS)
moduleclass = 'compiler'