From owner-freebsd-questions@FreeBSD.ORG Sat Sep 11 14:05:47 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB52E1065673 for ; Sat, 11 Sep 2010 14:05:47 +0000 (UTC) (envelope-from ohartman@mail.zedat.fu-berlin.de) Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) by mx1.freebsd.org (Postfix) with ESMTP id 6D46C8FC25 for ; Sat, 11 Sep 2010 14:05:47 +0000 (UTC) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost1.zedat.fu-berlin.de (Exim 4.69) with esmtp (envelope-from ) id <1OuQiA-0001cz-H6>; Sat, 11 Sep 2010 16:05:46 +0200 Received: from e178019247.adsl.alicedsl.de ([85.178.19.247] helo=thor.walstatt.dyndns.org) by inpost2.zedat.fu-berlin.de (Exim 4.69) with esmtpsa (envelope-from ) id <1OuQiA-0003rB-5Z>; Sat, 11 Sep 2010 16:05:46 +0200 Message-ID: <4C8B8CB9.4010104@mail.zedat.fu-berlin.de> Date: Sat, 11 Sep 2010 16:05:45 +0200 From: "O. Hartmann" User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.9) Gecko/20100908 Thunderbird/3.1.3 MIME-Version: 1.0 To: Mehmet Erol Sanliturk References: <4C8B4BC0.1000900@mail.zedat.fu-berlin.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: 85.178.19.247 X-Mailman-Approved-At: Sat, 11 Sep 2010 15:35:43 +0000 Cc: Andrew Brampton , freebsd-questions@freebsd.org Subject: Re: Compiling software with different compiler than cc or clang results in unusable output X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Sep 2010 14:05:47 -0000 On 09/11/10 14:26, Mehmet Erol Sanliturk wrote: > > > On Sat, Sep 11, 2010 at 5:43 AM, Andrew Brampton > > wrot= e: > > On 11 September 2010 10:28, O. Hartmann > > wrote: > > > > Dear Sirs, > > > > you see me a kind of desperate. I wrote my own a small piece of > =C2 software in > > C, calculating the orbit and position of astronomical objects, > astroids, in > > a heliocentric coordinate system from Keplerian orbital elements= =2E > So far. > > The software calculates the set of points of an ellipse based up= on > > ephemeridal datas taken from the Minor Planet Cataloge. Again, s= o > far, > > everything all right. The set of points of an orbit is all right= and > > correct. But when it comes to positions at a specific time, then= > I loose > > hair! > > > > Compiling this piece of software with FreeBSD's gcc (V4.2) and > clang (clang > > devel) on my private and lab's FreeBSD boxes (both most recent > FreeBSD > > 8.1/amd64), this program does well, the calculated orbital > positions are > > very close to professional applications or observational checks.= > But when > > compiling the sources with gcc44 or gcc45 (same source, same > CFLAG setting, > > mostly no CFLAGS set), then there is a great discrepancy. > Sometimes when > > plotting positions, the results plotted seconds before differs > from the most > > recent. The ellipses are allways correct, but the position of a > single point > > at a specific time isn't correct. > > > > I use the GNU autotools to build the package. > > > > I suspekt miscompilations in memory alloction or in some time- o= r > > mathematical functions like sin, cos. > > > > before I digg deeper I'd like to ask the community for some hint= s > how to > > hunt down such a problem. > > > > regards, > > Oliver > > Sounds a cool project. I suspect you are miss-using a feature of C = or > are using uninitialised memory, and with gcc44/45's more aggressive= > optimisations it is getting it wrong. I have three suggestions > > 1) Use valgrind to check if it finds anything wrong when running yo= ur > program. Check both the good and the bad builds. > > 2) If your program is made up of multiple C files, then try compili= ng > all of the C files with gcc42, but just one at a time with gcc44. T= his > way will help you track down exactly which C file has "the bug". > > 3) Finally do some printf debugging to find the first line of code > that is generating the wrong value. > > I hope these suggestions help. > Andrew > > > > Another check may be to use Sun Studio C and or Fortran=C2 compilers .= > These can be used in Linux ( Linux version of Sun Studio )=C2 and/or > OpenSolaris or Solaris ( Solaris version of SunStudio ( both in x86 , > x86_64 , Sparc )=C2 ( all of them are ( Solaris , OpenSolaris , Sun > Studio , Linux =C2 ) =C2 free ) . All of them are freely downloadable f= rom > www.sun.com and/or www.opensolaris.com > ( these sites or their pages may be > redirected to www.oracle.com owned pages ) . > > Personally I tried GCC compilers , but I found that they are very > unreliable . Now I am using Sun Studio compilers in OpenSolaris and > Linux , and never GCC compilers .=C2 > > Thank you very much . > > Mehmet Erol Sanliturk > > > > =C2 Hello. Well, the only other architectures I have access to are Linux boxes. clang ist a very nice compiler since its syntax checking is formidable.=20 But its code is slow and there seems no OpenMP support at the moment. Oliver