distutils & OS X universal binaries

"Martin v. Löwis" martin at v.loewis.de
Sat Dec 8 09:56:08 EST 2007


> One proposed fix is to make the endian variable code dynamically change
> at run time.

I would advise against that. Endianness depdency should be resolved at
compile time, with appropriate conditional compilation. Endianness won't
change at run-time (and no, not even for a fat binary - the x86 code
will always "see" the same endianness, and so will the ppc code).

> Is there a way to get distutils to pass different macros/definitions to
> the separate compilations.

No. distutils only invokes the compiler a single time, not multiple
times, for a specific universal object file. The gcc driver then invokes
different cc1 backends repeatedly.

> Failing that does anyone know off hand exactly how this problem is
> supposed to be handled? Ie if there are multiple compiles what
> distinguishes them. My understanding is that up to 4 different binaries
> are being squashed together in these universal binaries.

In the specific case, just use the WORDS_BIGENDIAN macro defined in
pyconfig.h; it will be defined if the target is bigendian, and
undefined otherwise. In the case of a universal build, it will be
undefined in the x86 compiler invocation, and defined in the ppc
invocation.

If you are curious as to how it arranges that, read the source.

Regards,
Martin



More information about the Python-list mailing list