[Python-Dev] Cross Compiling
Adam Langley
lists.pythondev@imperialviolet.org
Sun, 20 Jul 2003 12:11:41 +0100
The configure script (for 2.2.3 at least) has defaults for its tests
of sizeof(int) and the like which are completely broken for cross
compiling. (They are generally values for a 32-bit system).
It's quite understandable why this configure code cannot be used with
a cross gcc:
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", sizeof(int));
exit(0);
So can I suggest a better(?) way of doing this (for systems with a GNU
toolchain at least):
sizeof.c:
#include <asm/types.h>
#include <sys/types.h>
#include <pthread.h>
#include <time.h>
const __u8 sizeof_int[sizeof(int)];
const __u8 sizeof_long[sizeof(long)];
const __u8 sizeof_voidp[sizeof(void *)];
const __u8 sizeof_char[sizeof(char )];
const __u8 sizeof_short[sizeof(short)];
const __u8 sizeof_float[sizeof(float)];
const __u8 sizeof_double[sizeof(double)];
const __u8 sizeof_long_long[sizeof(long long)];
const __u8 sizeof_off_t[sizeof(off_t)];
const __u8 sizeof_time_t[sizeof(time_t)];
const __u8 sizeof_pthread_t[sizeof(pthread_t)];
% gcc -g -c sizeof.c
% objdump -t sizeof.o | grep 'sizeof_[^ ]+$' | awk '{ print $5 " " $1; }'
sizeof_int 0000000000000004
sizeof_long 0000000000000008
sizeof_voidp 0000000000000008
sizeof_char 0000000000000001
sizeof_short 0000000000000002
sizeof_float 0000000000000004
sizeof_double 0000000000000008
sizeof_long_long 0000000000000008
sizeof_off_t 0000000000000008
sizeof_time_t 0000000000000008
sizeof_pthread_t 0000000000000008
I'm afraid that I lack the required autoconf-fu to supply a helpfuly
patch to configure.in.
--
Adam Langley agl@imperialviolet.org
http://www.imperialviolet.org (+44) (0)7906 332512
PGP: 9113 256A CC0F 71A6 4C84 5087 CDA5 52DF 2CB6 3D60