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: Michael Haubenwallner <michael.haubenwallner@…> 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.c first includes "../mem.h"
  • mem.h includes <stdlib.h> includes <standards.h>

Due to nothing relevant being defined yet, <standards.h> defines _LARGE_FILE_API

  • stdlib.h includes <sys/types.h>
  • sys/types.h does {typedef long fpos_t;}, because _LARGE_FILES is not defined

If _LARGE_FILES were defined before, sys/types.h would have done {typedef long long fpos_t;} here.

  • sys/types.h does {typedef long long fpos64_t;} due to _LARGE_FILE_API being defined
  • modules/regex.c includes "../native.h" includes "function.h" includes "frames.h" includes "lists.h" includes <Python.h> includes [<pyconfig.h>, <stdio.h>]
  • pyconfig.h defines _LARGE_FILES
  • stdio.h does not redefine the fpos_t things
  • stdio.h does {#define fgetpos fgetpos64} due to _LARGE_FILES being defined now
  • stdio.h declares {extern int fgetpos(FILE*,fpos_t);}, but remember fgetpos is defined to fgetpos64
  • stdio.h declares {extern int fgetpos64(FILE*,fpos64_t);} due to _LARGE_FILE_API being 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!

Attachments (2)

boost-build-gcc.log.gz (1.3 KB ) - added by Michael Haubenwallner <michael.haubenwallner@…> 8 years ago.
compiler errors with gcc
boost-build-xlc.log.gz (1.3 KB ) - added by Michael Haubenwallner <michael.haubenwallner@…> 8 years ago.
compiler errors with xlc

Download all attachments as: .zip

Change History (2)

by Michael Haubenwallner <michael.haubenwallner@…>, 8 years ago

Attachment: boost-build-gcc.log.gz added

compiler errors with gcc

by Michael Haubenwallner <michael.haubenwallner@…>, 8 years ago

Attachment: boost-build-xlc.log.gz added

compiler errors with xlc

Note: See TracTickets for help on using tickets.