Opened 8 years ago
#10122 new Patches
Recent Python versions trigger compiler error on AIX when compiling modules/regex.c: conflicting types for 'fgetpos64'
| Reported by: | Owned by: | Vladimir Prus | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | build |
| Version: | Boost 1.55.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
Since bugs.python.org/issue11184, recent Python releases (like Python-2.7.6) now have proper large-file support for AIX, defining _LARGE_FILES in <pyconfig.h>, exposed to the user via <Python.h>.
Now, bootstrapping boost.build for AIX using such a Python release causes the compiler errors shown in attached files when compiling modules/regex.c.
The problem with modules/regex.c is:
modules/regex.cfirst includes"../mem.h"mem.hincludes<stdlib.h>includes<standards.h>
Due to nothing relevant being defined yet, <standards.h> defines _LARGE_FILE_API
stdlib.hincludes<sys/types.h>sys/types.hdoes {typedef long fpos_t;}, because_LARGE_FILESis not defined
If _LARGE_FILES were defined before, sys/types.h would have done {typedef long long fpos_t;} here.
sys/types.hdoes {typedef long long fpos64_t;} due to_LARGE_FILE_APIbeing definedmodules/regex.cincludes"../native.h"includes"function.h"includes"frames.h"includes"lists.h"includes<Python.h>includes [<pyconfig.h>,<stdio.h>]pyconfig.hdefines_LARGE_FILESstdio.hdoes not redefine thefpos_tthingsstdio.hdoes {#define fgetpos fgetpos64} due to_LARGE_FILESbeing defined nowstdio.hdeclares {extern int fgetpos(FILE*,fpos_t);}, but rememberfgetposis defined tofgetpos64stdio.hdeclares {extern int fgetpos64(FILE*,fpos64_t);} due to_LARGE_FILE_APIbeing defined
This problem is the same for the other functions the compilers yell about.
Also, the same errors occur with current git master.
For the fix:
It is important to have all the ABI specific precompiler macros being defined before including any system header. Actually, the first thing "jam.h" does is to include <Python.h>. But with modules/regex.c first including "../mem.h" including <stdlib.h>, this rule is not followed. So the fix here is:
--- a/src/engine/mem.h
+++ b/src/engine/mem.h
@@ -8,6 +8,8 @@
#ifndef BJAM_MEM_H
#define BJAM_MEM_H
+#include "jam.h"
+
#ifdef OPT_BOEHM_GC
/* Use Boehm GC memory allocator. */
While the fix for this very problem is quite simple, it doesn't look like if <Python.h> being included first everywhere else in build.git/src/engine is on purpose actually...
Thank you!

compiler errors with gcc