Bug 43834 - problems when linking in XCode 3.2.2 (gcc build 5659) - static constants are messed?
Summary: problems when linking in XCode 3.2.2 (gcc build 5659) - static constants are ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.2.1
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-21 14:15 UTC by Alexander Kobotov
Modified: 2010-04-21 14:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Object files and good output and bad output. (29.64 KB, application/octet-stream)
2010-04-21 14:18 UTC, Alexander Kobotov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kobotov 2010-04-21 14:15:48 UTC
Hi,

I'm experiencing problems when statically linking using particular GCC supplied with XCode 3.2.2: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5659) on Mac OS X 10.6.2. Computations become incorrect.

My application consists of main in C and computational code in Fortran (NETLIB BLAS and slightly modified LAPACK). I'm compiling Fortran code using Intel Fortran Compiler.

If I'm linking using the particular build, then results of my computations become completely incorrect. When I'm linking using any other build (5646 from XCode 3.2, or even i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490)) everything computes correctly for the exactly same object files.

I'm guessing that linker somehow messes constants in my code and this results incorrect computations. I've succeed to see in my big application that constant ONE becomes -ONE with only this linker, however cleaning up for a smaller reproducer I've missed such a constant, but computations results in the reproducer are still incorrect for the build.

I've tried different versions of Intel Fortran Compiler (10.1, 11.1, etc), also tried to compile C code with GCC and with Intel C Compiler - all this doesn't affect results. Only GCC build matters, so I assume this is a problem of linker. However map files produced by all mentioned builds of GCC are binary same, so the problem somewhere deeper.

I'm attaching object files of reproducer. To link say just: gcc *.o. 
Resulting a.out will show correct output like:
x[0] = {1.000000, 0.000000}
x[1] = {1.000000, 0.000000}
x[2] = {1.000000, 0.000000}
TEST PASSED

or report a error like:
info = 0
x[0] = {0.856000, -0.608000} - FAIL
x[1] = {1.520000, 0.840000} - FAIL
x[2] = {0.968000, 1.176000} - FAIL
TEST FAILED!!!


Please feel free to ask for more details. I would like to help to localize the issue, but just don't know where to look at.

Thanks,
Alexander
Comment 1 Alexander Kobotov 2010-04-21 14:18:30 UTC
Created attachment 20452 [details]
Object files and good output and bad output.

File linked correctly is in a.out.good
File with erroneous output in a.out.bad
Also object files used to link are attached.
Comment 2 Richard Biener 2010-04-21 14:37:27 UTC
Report it to Apple.  The version Apple ships does not resemble anything like
an FSF release that would still be supported.