Bug 65733 - gcc 4.9.2 suffers bootstrap comparison failures with clang 3.5.1 and later.
Summary: gcc 4.9.2 suffers bootstrap comparison failures with clang 3.5.1 and later.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://llvm.org/bugs/show_bug.cgi?id...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-10 18:39 UTC by Jack Howarth
Modified: 2015-04-11 17:12 UTC (History)
2 users (show)

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


Attachments
binary conftest.o.g from clang 3.6.0 compiler (675 bytes, application/octet-stream)
2015-04-11 00:52 UTC, Jack Howarth
Details
binary conftest.o.g0 from clang 3.6.0 compiler (236 bytes, application/octet-stream)
2015-04-11 00:53 UTC, Jack Howarth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2015-04-10 18:39:36 UTC
The Xcode 6.3 release (with Apple Clang 6.1 compilers based on 3.6.0svn) produces bootstrap comparison failures in the gcc 4.9.2 build on x86_64-apple-darwin14. The same bootstrap comparison failure is also seen on x86_64-apple-darwin13 with Xcode 6.2 but using the llvm.org clang 3.5.1, 3.5.2 or 3.6.0 compilers instead of the Apple Clang 6.0 compilers.

Comparing stages 2 and 3
warning: gcc/cc1-checksum.o differs
warning: gcc/cc1obj-checksum.o differs
warning: gcc/cc1objplus-checksum.o differs
warning: gcc/cc1plus-checksum.o differs
Bootstrap comparison failure!
gcc/asan.o differs
gcc/attribs.o differs
gcc/bitmap.o differs
gcc/c/c-decl.o differs
gcc/cfg.o differs
gcc/coverage.o differs
gcc/cp/class.o differs
gcc/cp/semantics.o differs
gcc/cp/tree.o differs
gcc/dse.o differs
gcc/dwarf2out.o differs
gcc/except.o differs
gcc/fortran/trans-common.o differs
gcc/ggc-common.o differs
gcc/graphite-clast-to-gimple.o differs
gcc/graphite.o differs
gcc/ipa-profile.o differs
gcc/ira-color.o differs
gcc/ira-costs.o differs
gcc/java/jcf-io.o differs
gcc/loop-unroll.o differs
gcc/lto-streamer-in.o differs
gcc/lto-streamer-out.o differs
gcc/objc/objc-act.o differs
gcc/objcp/objcp-act.o differs
gcc/passes.o differs
gcc/plugin.o differs
gcc/postreload-gcse.o differs
gcc/statistics.o differs
gcc/trans-mem.o differs
gcc/tree-cfg.o differs
gcc/tree-eh.o differs
gcc/tree-ssa-ccp.o differs
gcc/tree-ssa-coalesce.o differs
gcc/tree-ssa-dom.o differs
gcc/tree-ssa-live.o differs
gcc/tree-ssa-loop-ivopts.o differs
gcc/tree-ssa-phiopt.o differs
gcc/tree-ssa-pre.o differs
gcc/tree-ssa-reassoc.o differs
gcc/tree-ssa-threadupdate.o differs
gcc/tree-ssa-uncprop.o differs
gcc/tree-vectorizer.o differs
gcc/valtrack.o differs
gcc/vtable-verify.o differs
Makefile:20180: recipe for target 'compare' failed

The observation, that the llvm.org clang 3.5.1 or later compilers along side Xcode 6.2 produces the same bootstrap comparison failure, eliminates the cctools changes in Xcode 6.3 as the culprit and points to miscompilation of the stage1 compiler instead.

Reducing the optimization of the stage1 bootstrap with STAGE1_CFLAGS="-O0 -g" and STAGE1_CXXFLAGS="-O0 -g" doesn't eliminate the bootstrap comparison failure.

Interestingly, current gcc trunk 5.0svn doesn't exhibit the bootstrap comparison failure (with the stock build or using --enable-checking=release).
Comment 1 Jack Howarth 2015-04-10 18:44:05 UTC
Gcc bootstraps were all tested with...

../gcc-4.9.2/configure --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9

The stock Apple clang 6.0 compilers from Xcode 6.2 don't exhibit the bootstrap comparison failure of course on either x86_64-apple-darwin13 or x86_64-apple-darwin14.
Comment 2 Jack Howarth 2015-04-10 20:42:45 UTC
Current gcc-4_9-branch at r221965 suffers the same bootstrap comparison failure on x86_64-apple-darwin14 with Xcode 6.3's Apple Clang 6.1 compilers and on x86_64-apple-darwin13 with Xcode 6.2 and the llvm.org 3.6.0's clang compilers.
Comment 3 Jack Howarth 2015-04-10 23:46:15 UTC
As Iain pointed out to me, the gcc configure output under the more recent clang compilers isn't setting BUILD_CONFIG. Oddly gcc trunk also doesn't set BUILD_CONFIG in the configure output under the more recent clang compilers but the bootstrap comparison failure isn't seen. For gcc 4.9 and gcc-4_9-branch, --with-build-config=bootstrap-debug  has to be explicitly passed to configure to suppress the bootstrap comparison failures under the more recent clang compilers.
Comment 4 Jack Howarth 2015-04-11 00:46:12 UTC
The issue in configure can be seen with...

mkdir conftest
cd conftest
echo "int f (void) { return 0; }" > conftest.c
clang-3.6 -c conftest.c
mv conftest.o conftest.o.g0
clang-3.6 -c -g conftest.c
mv conftest.o conftest.o.g
../gcc-4.9.3-20150410/contrib/compare-debug conftest.o.g0 conftest.o.g

..which unexpectedly produces...

conftest.o.g0.stripped conftest.o.g.stripped differ: char 433, line 1
stripping off .eh_frame and LTO sections, then retrying
failed to strip off .eh_frame
conftest.o.g0.stripped conftest.o.g.stripped differ: char 433, line 1
Comment 5 Jack Howarth 2015-04-11 00:52:27 UTC
Created attachment 35295 [details]
binary conftest.o.g from clang 3.6.0 compiler

The binary conftest.o.g was created on x86_64-apple-darwin13 using the cctools from Xcode 6.2 and the llvm.org 3.6.0 clang compilers with the command...

echo "int f (void) { return 0; }" > conftest.c
clang-3.6 -c -g conftest.c
mv conftest.o conftest.o.g
Comment 6 Jack Howarth 2015-04-11 00:53:55 UTC
Created attachment 35296 [details]
binary conftest.o.g0 from clang 3.6.0 compiler

The binary conftest.o.g was created on x86_64-apple-darwin13 using the cctools from Xcode 6.2 and the llvm.org 3.6.0 clang compilers with the command...

echo "int f (void) { return 0; }" > conftest.c
clang-3.6 -c conftest.c
mv conftest.o conftest.o.g0
Comment 7 Jack Howarth 2015-04-11 01:49:00 UTC
Using...

ld -S -r -no_uuid conftest.o.g -o conftest.o.g.stripped
ld -S -r -no_uuid conftest.o.g0 -o conftest.o.g0.stripped
dwarfdump --eh-frame conftest.o.g.stripped > conftest.o.g.stripped.dwarfdump
dwarfdump --eh-frame conftest.o.g0.stripped > conftest.o.g0.stripped.dwarfdump

for conftest.c compiled with Xcode 6.2 Apple Clang 6.0 on x86_64-apple-darwin13, we get...

% diff -u conftest.o.g.stripped.dwarfdump conftest.o.g0.stripped.dwarfdump
--- conftest.o.g.stripped.dwarfdump	2015-04-10 21:43:15.000000000 -0400
+++ conftest.o.g0.stripped.dwarfdump	2015-04-10 21:43:04.000000000 -0400
@@ -1,5 +1,5 @@
 ----------------------------------------------------------------------
- File: conftest.o.g.stripped (x86_64)
+ File: conftest.o.g0.stripped (x86_64)
 ----------------------------------------------------------------------
 Exception handling frame information for section __eh_frame
 

but for contest.c compiled with llvm.org 3.6.0's clang on x86_64-apple-darwin13, we get...

% diff -u conftest.o.g.stripped.dwarfdump conftest.o.g0.stripped.dwarfdump
--- conftest.o.g.stripped.dwarfdump	2015-04-10 21:42:02.000000000 -0400
+++ conftest.o.g0.stripped.dwarfdump	2015-04-10 21:41:52.000000000 -0400
@@ -1,12 +1,12 @@
 ----------------------------------------------------------------------
- File: conftest.o.g.stripped (x86_64)
+ File: conftest.o.g0.stripped (x86_64)
 ----------------------------------------------------------------------
 Exception handling frame information for section __eh_frame
 
 0x00000000: CIE
         length: 0x00000014
         CIE_id: 0xffffffff
-       version: 0x01
+       version: 0x03
   augmentation: "zR"
     code_align: 1
     data_align: -8
Comment 8 Iain Sandoe 2015-04-11 09:03:38 UTC
(In reply to Jack Howarth from comment #7)

> % diff -u conftest.o.g.stripped.dwarfdump conftest.o.g0.stripped.dwarfdump
> --- conftest.o.g.stripped.dwarfdump	2015-04-10 21:42:02.000000000 -0400
> +++ conftest.o.g0.stripped.dwarfdump	2015-04-10 21:41:52.000000000 -0400
> @@ -1,12 +1,12 @@
>  ----------------------------------------------------------------------
> - File: conftest.o.g.stripped (x86_64)
> + File: conftest.o.g0.stripped (x86_64)
>  ----------------------------------------------------------------------
>  Exception handling frame information for section __eh_frame
>  
>  0x00000000: CIE
>          length: 0x00000014
>          CIE_id: 0xffffffff
> -       version: 0x01
> +       version: 0x03

Confirmed with TOT clang as of this morning.  Please file an llvm BZ and/or a radar against Xcode 6.3.
Comment 9 Dominique d'Humieres 2015-04-11 09:39:12 UTC
Same problem with 4.8.5.
Comment 10 Jack Howarth 2015-04-11 12:34:52 UTC
> 
> Confirmed with TOT clang as of this morning.  Please file an llvm BZ and/or
> a radar against Xcode 6.3.

Reported as radar bug /20509942, "Apple Clang 6.1 emits inconsistent eh_frame dwarf versions"
Comment 11 Jack Howarth 2015-04-11 14:17:19 UTC
This issue appears to have been introduced by...

http://llvm.org/viewvc/llvm-project?view=revision&revision=211272

and seems to have been previously discussed...

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141208/247970.html
Comment 12 Jack Howarth 2015-04-11 17:12:37 UTC
It appears that clang 3.5 and later defaults to setting the CIE version to dwarf2 in the absence of -g. This behavior can't be overridden by passing -gdwarf-3 in the absence of -g. However the gcc configure test failure can be suppressed under clang by appending -gdwarf-2 instead (to downgrade the CIE version to dwarf3 in the presence of -g).