Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Sep 2010 08:26:11 -0400
From:      Mehmet Erol Sanliturk <m.e.sanliturk@gmail.com>
To:        Andrew Brampton <brampton+freebsd@gmail.com>
Cc:        "O. Hartmann" <ohartman@mail.zedat.fu-berlin.de>, freebsd-questions@freebsd.org
Subject:   Re: Compiling software with different compiler than cc or clang results in unusable output
Message-ID:  <AANLkTinmMDSP=Ci5GkogcD744zcy8uyP6gY7uuqLR8-_@mail.gmail.com>
In-Reply-To: <AANLkTinymkQeeLhdbWYP=eEHEtViWVRscJ0-dVPJBX6u@mail.gmail.com>
References:  <4C8B4BC0.1000900@mail.zedat.fu-berlin.de> <AANLkTinymkQeeLhdbWYP=eEHEtViWVRscJ0-dVPJBX6u@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 11, 2010 at 5:43 AM, Andrew Brampton
<brampton+freebsd@gmail.com<brampton%2Bfreebsd@gmail.com>
> wrote:

> On 11 September 2010 10:28, O. Hartmann
> <ohartman@mail.zedat.fu-berlin.de> wrote:
> >
> > Dear Sirs,
> >
> > you see me a kind of desperate. I wrote my own a small piece of  software
> in
> > C, calculating the orbit and position of astronomical objects, astroids,
> in
> > a heliocentric coordinate system from Keplerian orbital elements. So far.
> > The software calculates the set of points of an ellipse based upon
> > ephemeridal datas taken from the Minor Planet Cataloge. Again, so 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- or
> > mathematical functions like sin, cos.
> >
> > before I digg deeper I'd like to ask the community for some hints 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 your
> program. Check both the good and the bad builds.
>
> 2) If your program is made up of multiple C files, then try compiling
> all of the C files with gcc42, but just one at a time with gcc44. This
> 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  compilers . These
can be used in Linux ( Linux version of Sun Studio )  and/or OpenSolaris or
Solaris ( Solaris version of SunStudio ( both in x86 , x86_64 , Sparc )  (
all of them are ( Solaris , OpenSolaris , Sun Studio , Linux  )  free ) .
All of them are freely downloadable from 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 .

Thank you very much .

Mehmet Erol Sanliturk



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinmMDSP=Ci5GkogcD744zcy8uyP6gY7uuqLR8-_>