Heads up: Apple llvm gcc 4.2 miscompiles PEP 393
The gcc that Apple ships with the Lion SDK (not sure what Xcode version that is) miscompiles Python now. I've reported this to Apple as bug 10143715; not sure whether there is a public link to this bug report. In essence, the code typedef struct { long length; long hash; int state; int *wstr; } PyASCIIObject; typedef struct { PyASCIIObject _base; long utf8_length; char *utf8; long wstr_length; } PyCompactUnicodeObject; void *_PyUnicode_compact_data(void *unicode) { return ((((PyASCIIObject*)unicode)->state & 0x20) ? ((void*)((PyASCIIObject*)(unicode) + 1)) : ((void*)((PyCompactUnicodeObject*)(unicode) + 1))); } miscompiles (with -O2 -fomit-frame-pointer) to __PyUnicode_compact_data: Leh_func_begin1: leaq 32(%rdi), %rax ret The compiler version is gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) This unconditionally assumes that sizeof(PyASCIIObject) needs to be added to unicode, independent of whether the state bit is set or not. I'm not aware of a work-around in the code. My work-around is to use gcc-4.0, which is still available on my system from an earlier Xcode installation (in /Developer-3.2.6) Regards, Martin
On 2011-09-28, at 13:24 , martin@v.loewis.de wrote:
The gcc that Apple ships with the Lion SDK (not sure what Xcode version that is) Xcode 4.1
I'm not aware of a work-around in the code. My work-around is to use gcc-4.0, which is still available on my system from an earlier Xcode installation (in /Developer-3.2.6) Does Clang also fail to compile this? Clang was updated from 1.6 to 2.0 with Xcode 4, worth a try.
Also, from your version listing it seems to be llvm-gcc (gcc frontend with llvm backend I think), is there no more straight gcc (with gcc frontend and backend)? FWIW, on 10.6 the default gcc is a straight 4.2 > gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) There is an llvm-gcc 4.2 but it uses a slightly different revision of llvm > llvm-gcc --version i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2333.4)
Does Clang also fail to compile this? Clang was updated from 1.6 to 2.0 with Xcode 4, worth a try.
clang indeed works fine.
Also, from your version listing it seems to be llvm-gcc (gcc frontend with llvm backend I think), is there no more straight gcc (with gcc frontend and backend)?
/usr/bin/cc and /usr/bin/gcc both link to llvm-gcc-4.2. However, there still is /usr/bin/gcc-4.2. Using that, Python also compiles correctly - so I have changed the gcc link on my system. Thanks for the advise - I didn't expect that Apple ships thhree compilers... Regards, Martin
In article <74F6ADFA-874D-4BAC-B304-CE8B12D80126@masklinn.net>,
Xavier Morel
On 2011-09-28, at 19:49 , Martin v. Löwis wrote:
Thanks for the advise - I didn't expect that Apple ships thhree compilers
Yeah I can understand that, they're in the middle of the transition but Clang is not quite there yet so...
BTW, at the moment, we are still using gcc-4.2 (not gcc-llvm nor clang) from Xcode 3 on OS X 10.6 for the 64-bit/32-bit installer builds and gcc-4.0 on 10.5 for the 32-bit-only installer builds. We will probably revisit that as we get closer to 3.3 alphas and betas. -- Ned Deily, nad@acm.org
Is anyone on this thread interested in other weird Mac bugs? I had a user complaining that on their Mac, with Python 2.5.6 from macports, 2**63 was a negative number! That sounds like a compiler bug to me... http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=65 (details about the versions involved are in comment 6) -- --Guido van Rossum (python.org/~guido)
In article
Is anyone on this thread interested in other weird Mac bugs? I had a user complaining that on their Mac, with Python 2.5.6 from macports, 2**63 was a negative number! That sounds like a compiler bug to me...
http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=65 (details about the versions involved are in comment 6)
Thanks for the pointer. That looks like a duplicate of Issue11149 (and Issue12701). Another manifestation of this was reported in Issue13061 which also originated from MacPorts. I'll remind them that the configure change is likely needed for all Pythons. It's still safest to stick with good old gcc-4.2 on OS X at the moment. -- Ned Deily, nad@acm.org
Thanks! More proof that debugging crosses *all* abstractions...
On Wed, Oct 5, 2011 at 4:05 PM, Ned Deily
In article
, Guido van Rossum wrote: Is anyone on this thread interested in other weird Mac bugs? I had a user complaining that on their Mac, with Python 2.5.6 from macports, 2**63 was a negative number! That sounds like a compiler bug to me...
http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=65 (details about the versions involved are in comment 6)
Thanks for the pointer. That looks like a duplicate of Issue11149 (and Issue12701). Another manifestation of this was reported in Issue13061 which also originated from MacPorts. I'll remind them that the configure change is likely needed for all Pythons. It's still safest to stick with good old gcc-4.2 on OS X at the moment.
-- Ned Deily, nad@acm.org
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido)
participants (5)
-
"Martin v. Löwis"
-
Guido van Rossum
-
martin@v.loewis.de
-
Ned Deily
-
Xavier Morel