From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17923 invoked by alias); 23 Nov 2010 01:14:07 -0000 Received: (qmail 17910 invoked by uid 22791); 23 Nov 2010 01:14:06 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_OC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Nov 2010 01:14:00 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 567762BABA5; Mon, 22 Nov 2010 20:13:58 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2OfxKZsLeb-d; Mon, 22 Nov 2010 20:13:58 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 247E62BABA4; Mon, 22 Nov 2010 20:13:58 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 181DC1457E1; Mon, 22 Nov 2010 17:13:55 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [RFA/Python] Fix procfs.c build failure on 32bit solaris (_FILE_OFFSET_BITS) Date: Tue, 23 Nov 2010 01:14:00 -0000 Message-Id: <1290474834-1945-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00336.txt.bz2 This is a bit ugly... A recent change introduced the include of "python-internal.h" from inside breakpoint.h. This in turn affected procfs.c: | In file included from /usr/include/sys/procfs.h:29:0, | from ../../src/gdb/core-regset.c:42: | /usr/include/sys/old_procfs.h:39:2: error: #error "Cannot use procfs in the large file compilation environment" What happens is that _FILE_OFFSET_BITS gets unconditionally re-defined by pyconfig.h to a value that procfs.c does not support. So far, we were able to get by with the following #undef: /* On sparc-solaris, /usr/include/sys/feature_tests.h defines _FILE_OFFSET_BITS, which pyconfig.h also defines. Same work around technique as above. */ #undef _FILE_OFFSET_BITS ...because procfs.c never included Python, even indirectly. But this is no longer sufficient, because the indirect dependency causes procfs.c to get a value of _FILE_OFFSET_BITS that it does not support. As I was looking at this, I looked at the configure script in Python 2.7, and it appears that disabling large-file support is not possible. Regardless of that, I think we want to be able to build GDB against pre-built versions of Python if we can... So the fix I applied was to make sure we restore the initial value of _FILE_OFFSET_BITS after having included Python.h. gdb/ChangeLog: * python/python-internal.h (_FILE_OFFSET_BITS): Restore initial value after having included "Python.h". It fixes the problem on sparc-solaris. Tested on x86_64-linux. OK to commit? --- gdb/python/python-internal.h | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 30d7533..026a05a 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -37,9 +37,16 @@ #undef _XOPEN_SOURCE /* On sparc-solaris, /usr/include/sys/feature_tests.h defines - _FILE_OFFSET_BITS, which pyconfig.h also defines. Same work - around technique as above. */ + _FILE_OFFSET_BITS, which pyconfig.h also defines. We cannot apply + the same technique as above, because the actual value is important. + If we let Python define _FILE_OFFSET_BITS to a value that is not + compatible with procfs, we will get a compilation error while trying + to include sys/procfs.h. To avoid that, we save the current value, + and restore it after Python.h has been included. */ +#ifdef _FILE_OFFSET_BITS +#define OLD_FILE_OFFSET_BITS _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS +#endif #if HAVE_LIBPYTHON2_4 #include "python2.4/Python.h" @@ -62,6 +69,13 @@ typedef int Py_ssize_t; #error "Unable to find usable Python.h" #endif +/* Restore the original _FILE_OFFSET_BITS value if applicable. */ +#ifdef OLD_FILE_OFFSET_BITS +#undef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS OLD_FILE_OFFSET_BITS +#undef OLD_FILE_OFFSET_BITS +#endif + /* If Python.h does not define WITH_THREAD, then the various GIL-related functions will not be defined. However, PyGILState_STATE will be. */ -- 1.7.1