From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28562 invoked by alias); 4 Feb 2015 18:39:54 -0000 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 Received: (qmail 28532 invoked by uid 89); 4 Feb 2015 18:39:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: ausc60ps301.us.dell.com Received: from ausc60ps301.us.dell.com (HELO ausc60ps301.us.dell.com) (143.166.148.206) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 04 Feb 2015 18:39:51 +0000 X-LoopCount0: from 10.175.216.251 From: To: CC: Subject: Re: [patch] Fix Python 3 build error on 32-bit hosts Date: Wed, 04 Feb 2015 18:39:00 -0000 Message-ID: References: <20150204174311.GA24375@host1.jankratochvil.net> In-Reply-To: <20150204174311.GA24375@host1.jankratochvil.net> Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00097.txt.bz2 > On Feb 4, 2015, at 12:43 PM, Jan Kratochvil w= rote: >=20 > Hi, >=20 > on Fedora Rawhide (=3D=3D22) i686 using --with-python=3D/usr/bin/python3 = one gets: >=20 > gcc -g -I. -I. -I./common -I./config -DLOCALEDIR=3D"\"/usr/local/share/= locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../re= adline/.. -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libde= cnumber -I./gnulib/import -Ibuild-gnulib/import -DTUI=3D1 -pthread -I/= usr/include/guile/2.0 -I/usr/include/python3.4m -I/usr/include/python3.4m = -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unu= sed -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmis= sing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parame= ter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral= -Werror -c -o py-value.o -MT py-value.o -MMD -MP -MF .deps/py-value.Tpo -f= no-strict-aliasing -DNDEBUG -fwrapv ./python/py-value.c > ./python/py-value.c:1696:3: error: initialization from incompatible point= er type [-Werror] > valpy_hash, /*tp_hash*/ > ^ > ./python/py-value.c:1696:3: error: (near initialization for =1B$B!F=1B(Bv= alue_object_type.tp_hash=1B$B!G=1B(B) [-Werror] > cc1: all warnings being treated as errors > Makefile:2628: recipe for target 'py-value.o' failed >=20 > This is because in Python 2 tp_hash was: > typedef long (*hashfunc)(PyObject *); > while in Python 3 tp_hash is: > typedef Py_hash_t (*hashfunc)(PyObject *); >=20 > Py_hash_t is int for 32-bit hosts and long for 64-bit hosts. While on 32= -bit > hosts sizeof(long)=3D=3Dsizeof(int) still the hashfunc type is formally > incompatible. As this patch should have no compiled code change it is not > really necessary for gdb-7.9, it would fix there just this non-fatal > compilation warning: > ./python/py-value.c:1696:3: warning: initialization from incompatible po= inter type > valpy_hash, /*tp_hash*/ > ^ > ./python/py-value.c:1696:3: warning: (near initialization for =1B$B!F=1B= (Bvalue_object_type.tp_hash=1B$B!G=1B(B) >=20 > A question is whether the autoconf test isn't an overkill. One could use > instead just: > #if PYTHON_ABI_VERSION >=3D 3 I would say yes. This has been done in other cases where types or signatur= es changed between the two versions. Given that it=1B$B!G=1B(Bs specifical= ly a change in definition, it seems logical to test the Python version with= a #if and use the old or the new definition accordingly. paul