New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python/dtoa.c:158: #error "Failed to find an exact-width 32-bit integer type" (FreeBSD 4.11 + gcc 2.95.4) #54261
Comments
Building Python 2.7 fails on FreeBSD 4.11 with gcc 2.95.4 as below: """ This error occurs when HAVE_UINT32_T or HAVE_INT32_T are not defined. """
#if (defined UINT32_MAX || defined uint32_t)
#ifndef PY_UINT32_T
#define HAVE_UINT32_T 1
#define PY_UINT32_T uint32_t
#endif
#endif
"""
"""
#if (defined INT32_MAX || defined int32_t)
#ifndef PY_INT32_T
#define HAVE_INT32_T 1
#define PY_INT32_T int32_t
#endif
#endif
""" This doesn't work for FreeBSD 4, where exact-width integer types are defined #typedef and does not provide *_MAX for them. I don't think this is the right fix but adding following macro to pyport.h fixed the problem. """
#define UINT32_MAX 0xffffffff
#define INT32_MAX 0x7fffffff
""" |
Thanks for the report. Some questions:
checking for uint32_t... yes what do you get here? (Aside: those .... 'no's look odd to me; I think there may be an autoconf bug here.)
IIRC, the theory is that if stdint.h or inttypes.h #defines/typedefs uint32_t, then the UINT32_T_MAX macro should also be #defined somewhere in one of those header files; OTOH if neither stdint nor inttypes includes declarations for uint32_t then the configure script should find something suitable, and #define uint32_t. |
Yes, I can reproduce this in 2.7, 3.1 and 3.2.
Same here. It looks like a bug in autoconf: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560105 My output is below: """
They are declared in inttypes.h. """
/*
* This file is in the public domain.
* $FreeBSD: src/sys/sys/inttypes.h,v 1.2 1999/08/28 00:51:47 peter Exp $
*/
#ifndef _SYS_INTTYPES_H_
#define _SYS_INTTYPES_H_
#include <machine/ansi.h>
typedef __int8_t int8_t; typedef __uint8_t uint8_t; typedef __intptr_t intptr_t; #endif /* !SYS_INTTYPES_H */ |
Forgot to mention that there's no _MAX macro for exact-width integer types. $ egrep -r 'INT[0-9].*_MAX' /usr/include/ | wc -l
0 How about adding those macros when the system does not provide them? |
FreeBSD 5.0 has stdint.h, which includes machine/_stdint.h. In the It looks like FreeBSD has had the correct setup for more than 7 years: http://svn.freebsd.org/viewvc/base/release/5.0.0/sys/i386/include/ I would be moderately against making changes in Python for dated systems. |
I understand FreeBSD 4.x is old platform (4.11, the last 4.x series, is released 5 years ago) but, in my opinion, as long as it does not make Python code cluttered, supporting old platforms is not that bad idea. Anyway, I would like to leave the decision to the core developers. |
You mean the core developers other than Stefan? ;-) I don't have any objection to a patch for this problem, provided that that patch is specifically targeted at FreeBSD 4, and clearly doesn't change behaviour on any other platform. On one hand I agree that FreeBSD 4 isn't a high priority platform; on the other, it's not *that* obscure, and failure to build the Python core (rather than the extension modules) is quite a big deal. It's also a regression from 2.6, IIUC. And it should be easy to fix, with a single block of code in pyport.h. |
Same problem on SGI IRIX 6.5.28 GCC 3.3. Adding the following to pyport.h got me through as well. #define UINT32_MAX 0xffffffff
#define INT32_MAX 0x7fffffff |
This patch is specifically targeted at FreeBSD 4. I don't know how to accommodate SGI IRIX's case. |
Thanks for the patch. This looks fine, in principle. A couple of comments and questions: (1) I think the patch should provide *MIN values alongside the *MAX values (for signed types only, of course). (2) Are we sure that these values are valid on all FreeBSD 4 platforms, or should these definitions be further restricted to Free BSD 4 / x86? (3) Are the types of the constants definitely correct? E.g., UINT64_MAX should have type uint64_t. That gets a bit tricky, since we can't use casts (which would prevent these constants being used in preprocessor #ifs), so we need to determine exactly what basic types uint32_t and uint64_t match, and make sure to use the correct suffix (e.g., ULL, LL, UL, L). For uint32_t I guess this is easy: it'll almost certainly be the same type as unsigned int. Is uint64_t defined as unsigned long long, or as unsigned long? |
This is also an issue on the Tru64 / alpha on Snakebite: that platform has inttypes.h but no stdint.h, and inttypes.h has typedefs for uint32_t and friends, but no defines for UINT32_MAX, etc. So the pyport.h check: #if (defined UINT32_MAX || defined uint32_t)
fails (uint32_t is a typedef rather than a #define). To make matters worse, the autoconf macro AC_TYPE_UINT32_T correctly detects that uint32_t exists, so doesn't bother to define it. The ideal place to fix this would be in the configure scripts. |
Here's a patch (against the default branch). It adds simple AC_CHECK_TYPE configure-time typechecks for uint32_t and friends. |
New changeset 6f9aba5f8d32 by Mark Dickinson in branch 'default': |
Committed to default. I want to look at the buildbot results and try some manual snakebite tests before deciding whether to backport. |
New changeset 48fbe78167cd by Mark Dickinson in branch '2.7': |
New changeset d82b73366227 by Mark Dickinson in branch '3.2': New changeset 48de792747dc by Mark Dickinson in branch '3.3': New changeset 22d891a2d533 by Mark Dickinson in branch 'default': |
Fixed in all branches. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: