Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Paul_Koning@Dell.com>
To: <jan.kratochvil@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [patch] Fix Python 3 build error on 32-bit hosts
Date: Wed, 04 Feb 2015 18:39:00 -0000	[thread overview]
Message-ID: <A857DE6E-96B1-4278-8CAF-280E2EFA861A@dell.com> (raw)
In-Reply-To: <20150204174311.GA24375@host1.jankratochvil.net>


> On Feb 4, 2015, at 12:43 PM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> 
> Hi,
> 
> on Fedora Rawhide (==22) i686 using --with-python=/usr/bin/python3 one gets:
> 
> gcc -g   -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import   -DTUI=1   -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-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-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 -fno-strict-aliasing -DNDEBUG -fwrapv ./python/py-value.c
> ./python/py-value.c:1696:3: error: initialization from incompatible pointer type [-Werror]
>   valpy_hash,            /*tp_hash*/
>   ^
> ./python/py-value.c:1696:3: error: (near initialization for ‘value_object_type.tp_hash’) [-Werror]
> cc1: all warnings being treated as errors
> Makefile:2628: recipe for target 'py-value.o' failed
> 
> 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 *);
> 
> Py_hash_t is int for 32-bit hosts and long for 64-bit hosts.  While on 32-bit
> hosts sizeof(long)==sizeof(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 pointer type
> 	   valpy_hash,            /*tp_hash*/
> 	   ^
> 	./python/py-value.c:1696:3: warning: (near initialization for ‘value_object_type.tp_hash’)
> 
> A question is whether the autoconf test isn't an overkill.  One could use
> instead just:
> 	#if PYTHON_ABI_VERSION >= 3

I would say yes.  This has been done in other cases where types or signatures changed between the two versions.  Given that it’s specifically 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


  reply	other threads:[~2015-02-04 18:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 17:43 Jan Kratochvil
2015-02-04 18:39 ` Paul_Koning [this message]
2015-02-04 18:58 ` Pedro Alves
2015-02-04 19:08   ` Pedro Alves
2015-02-04 19:20   ` [patchv2] " Jan Kratochvil
2015-02-04 19:27     ` Pedro Alves
2015-02-04 19:34       ` [commit] " Jan Kratochvil
2015-02-04 19:42         ` Pedro Alves
2015-02-04 19:51         ` Phil Muldoon
2015-02-04 21:06     ` Paul_Koning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A857DE6E-96B1-4278-8CAF-280E2EFA861A@dell.com \
    --to=paul_koning@dell.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox