Bug 78077 - gcc 6.2.0 fails to link temacs from emacs-25.1 using the Xcode 8 linker
Summary: gcc 6.2.0 fails to link temacs from emacs-25.1 using the Xcode 8 linker
Status: RESOLVED DUPLICATE of bug 57438
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-22 20:18 UTC by Jack Howarth
Modified: 2017-11-02 01:00 UTC (History)
4 users (show)

See Also:
Host: x86_64-apple-darwin15
Target: x86_64-apple-darwin15
Build: x86_64-apple-darwin15
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2016-10-22 20:18:55 UTC
The gcc 6.2.0 release fails to link temacs in the build of emacs-25.1 on x86_64-apple-darwin15 using the Xcode 8 linker. Configuring a build as...

../configure --without-ns CC=/sw/bin/gcc-fsf-6 CXX=/sw/bin/g++-fsf-6 CPPFLAGS="-I/sw/include" LDFLAGS="-L/sw/lib"

results in a build that fails at...

  CCLD     temacs
0  0x1097875cc  __assert_rtn + 144
1  0x10979a9df  mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions const&) + 3195
2  0x109792536  mach_o::relocatable::Parser<x86_64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 342
3  0x1097d3bac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 824
4  0x1097d640b  ld::tool::InputFiles::parseWorkerThread() + 495
5  0x7fff99bde99d  _pthread_body + 131
6  0x7fff99bde91a  _pthread_body + 0
A linker snapshot was created at:
	/tmp/temacs-2016-09-22-161008.ld-snapshot
ld: Assertion failed: (cfiStartsArray[i] != cfiStartsArray[i-1]), function parse, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-274.1/src/ld/parsers/macho_relocatable_file.cpp, line 1893.
collect2: error: ld returned 1 exit status
Comment 1 Jack Howarth 2016-10-22 20:37:41 UTC
This Xcode 8 linker failure is suppressed when emacs 25.1 is built at -O0, but occurs for -O1, -O2, -Os and -O3.
Comment 2 Jack Howarth 2016-10-24 11:52:48 UTC
This issue is also observed on x86_64-apple-darwin14 using gcc 6.2.0 and the linker from Xcode 7.2.1.
Comment 3 Jack Howarth 2016-10-24 12:31:35 UTC
Opened radar://28914335 'linker crash when linking temacs from emacs 25.1 when built with FSF gcc 6.2.0 or gcc trunk' with standalone test case attached as reproducer.
Comment 4 Jack Howarth 2016-10-24 17:45:38 UTC
The Apple developers think this is gcc bug producing malformatted input to the linker. From macho_relocatable_file.cpp, we are triggering the linker check...

        #ifndef NDEBUG
                // scan for FDEs claming the same function
                for(uint32_t i=1; i < cfiStartsArrayCount; ++i) {
                        assert( cfiStartsArray[i] != cfiStartsArray[i-1] );
                }
        #endif
Comment 5 Iain Sandoe 2016-10-24 18:31:47 UTC
(In reply to Jack Howarth from comment #4)
> The Apple developers think this is gcc bug producing malformatted input to
> the linker. From macho_relocatable_file.cpp, we are triggering the linker
> check...
> 
>         #ifndef NDEBUG
>                 // scan for FDEs claming the same function
>                 for(uint32_t i=1; i < cfiStartsArrayCount; ++i) {
>                         assert( cfiStartsArray[i] != cfiStartsArray[i-1] );
>                 }
>         #endif

If it's a 0-length FDE caused by a 0-length function, then this is a repeat of 57438.  If so please mark it accordingly  (I expect to post a fix for 57438 soon, and I can send you a preview if that helps).

If this is something different, then please can we have a reduced test-case.  Thanks
Comment 6 Jack Howarth 2016-10-24 20:48:29 UTC
(In reply to Iain Sandoe from comment #5)
> (In reply to Jack Howarth from comment #4)
> > The Apple developers think this is gcc bug producing malformatted input to
> > the linker. From macho_relocatable_file.cpp, we are triggering the linker
> > check...
> > 
> >         #ifndef NDEBUG
> >                 // scan for FDEs claming the same function
> >                 for(uint32_t i=1; i < cfiStartsArrayCount; ++i) {
> >                         assert( cfiStartsArray[i] != cfiStartsArray[i-1] );
> >                 }
> >         #endif
> 
> If it's a 0-length FDE caused by a 0-length function, then this is a repeat
> of 57438.  If so please mark it accordingly  (I expect to post a fix for
> 57438 soon, and I can send you a preview if that helps).
> 
> If this is something different, then please can we have a reduced test-case.
> Thanks

A reduced test case is unlikely but I can confirm that this appears to be due to PR57438 since passing -D__builtin_unreachable=__builtin_trap by using...

../configure --enable-link-time-optimization --without-ns CC=/sw/bin/gcc-fsf-6 CXX=/sw/bin/g++-fsf-6 CPPFLAGS="-D__builtin_unreachable=__builtin_trap -I/sw/include" LDFLAGS="-L/sw/lib"

produces a successful build at -O2 with LTO under stock gcc 6.2.0 and Xcode 8.1 GM's linker.
Comment 7 Eric Gallager 2017-11-02 01:00:53 UTC
(In reply to Jack Howarth from comment #6)
> (In reply to Iain Sandoe from comment #5)
> > (In reply to Jack Howarth from comment #4)
> > > The Apple developers think this is gcc bug producing malformatted input to
> > > the linker. From macho_relocatable_file.cpp, we are triggering the linker
> > > check...
> > > 
> > >         #ifndef NDEBUG
> > >                 // scan for FDEs claming the same function
> > >                 for(uint32_t i=1; i < cfiStartsArrayCount; ++i) {
> > >                         assert( cfiStartsArray[i] != cfiStartsArray[i-1] );
> > >                 }
> > >         #endif
> > 
> > If it's a 0-length FDE caused by a 0-length function, then this is a repeat
> > of 57438.  If so please mark it accordingly  (I expect to post a fix for
> > 57438 soon, and I can send you a preview if that helps).
> > 
> > If this is something different, then please can we have a reduced test-case.
> > Thanks
> 
> A reduced test case is unlikely but I can confirm that this appears to be
> due to PR57438 since passing -D__builtin_unreachable=__builtin_trap by
> using...
> 
> ../configure --enable-link-time-optimization --without-ns
> CC=/sw/bin/gcc-fsf-6 CXX=/sw/bin/g++-fsf-6
> CPPFLAGS="-D__builtin_unreachable=__builtin_trap -I/sw/include"
> LDFLAGS="-L/sw/lib"
> 
> produces a successful build at -O2 with LTO under stock gcc 6.2.0 and Xcode
> 8.1 GM's linker.

OK, closing it as a duplicate of bug 57438 then.

*** This bug has been marked as a duplicate of bug 57438 ***