Bill Allombert on Wed, 18 Dec 2013 13:19:20 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: MacOs X Lion compiler and PARI |
On Mon, Aug 15, 2011 at 12:59:14AM +0200, Bill Allombert wrote: > On Sat, Aug 06, 2011 at 09:15:01AM -0700, William Stein wrote: > > On Fri, Aug 5, 2011 at 5:30 AM, Bill Allombert > > <Bill.Allombert@math.u-bordeaux1.fr> wrote: > > > Hello PARI developers, > > > > > > I received reports that MacOs X Lion default compiler is unable to compile PARI > > > correctly. Precisely this version: > > > > > > GNU compiler version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) > > > > > > So far I got two kind of issues: > > > With --with-gmp, PARI build, but the resulting code is broken (see bug #1222) > > > With --without-gmp, PARI fails to build (see > > > <http://pari.math.u-bordeaux.fr/buildlogs/dac98dec-af1e-4e54-97ba-f001b69bf7a9>) > > > > > > Concerning, the first issue, I do not have access to such a system and in any > > > case I cannot fix Apple compiler, so I would appreciate if one of you Mac OS X > > > users would report the problem to Apple. > > > To encourage porting efforts to Lion, I setup a computer with the > > latest OS and XCode 4.1 on it. > > Thanks a lot, this has allowed to confirm that the problem > is a compiler issue that cause the file 'src/kernel/none/gcdll.c' > (included in mp.c) to be miscompiled with -O1 and up. > The symptom is that > bezout(7,2) return [0, 1, 2] instead of [1, -3, 1]. So I finally get access to a another working OS X system (snow leopard) and I have got to the root of the problem (I hope). "Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)" miscompiles the call to divll in src/kernel/none/divll.c. If one change the definition of divll in src/kernel/x86_64/asm0.h #define divll(a,b) \ __extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \ __asm__ ("divq %4" \ : "=a" /* %eax */ (__value), "=&d" /* %edx */ (hiremainder) \ ^^^^^ : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "mr" (__arg2)); \ __value; \ }) by replacing "=&d" by "=d", then GP works fine (make test-all succeed). However, both variants are correct, so this is a compiler bug. Cheers, Bill.