Bug 78087 - gcc 6.2.0 fails to link temacs from emacs-25.1 with -O0 -flto
Summary: gcc 6.2.0 fails to link temacs from emacs-25.1 with -O0 -flto
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (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-24 01:17 UTC by Jack Howarth
Modified: 2017-07-23 22:09 UTC (History)
0 users

See Also:
Host: x86_64-apple-darwin15, x86_64-linux-gnu
Target: x86_64-apple-darwin15, x86_64-linux-gnu
Build: x86_64-apple-darwin15, x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2016-10-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2016-10-24 01:17:03 UTC
The gcc 6.2.0 compiler fails to link temacs in a build of emacs 25.1 when the "-O0 -flto" flag is passed on CFLAGS and "-flto" on LDFLAGS. This issue occurs on x86_64-apple-darwin15 where the failure appears as...

  CCLD     temacs
/var/folders/vh/xthx1f251nqfj804049zl1wm0000gn/T//cc5Viitn.s:288358:1: error: assembler local symbol 'L1' not defined
...
/var/folders/vh/xthx1f251nqfj804049zl1wm0000gn/T//cc5Viitn.s:288358:1: error: assembler local symbol 'L174' not defined

and on x86_64 linux using a build gcc 6.2.0 with configure edited to set build_lto_plugin=no on ELF to use the same code LTO code generation path on linux as darwin...

  CCLD     temacs
/tmp/cc7ZBmmQ.ltrans0.ltrans.o:(.rodata+0x135a0): undefined reference to `.L1'
...
/tmp/cc7ZBmmQ.ltrans0.ltrans.o:(.rodata+0x13bc8): more undefined references to `.L174' follow
collect2: fatal error: ld returned 1 exit status

On x86_64 linux, the issue is suppressed when the -O1 optimization level or higher is used.
On x86_64 darwin, the linker failure in PR78077 occurs when the -O1 optimization level or higher is used.
Comment 1 Jack Howarth 2016-10-24 04:48:39 UTC
Interestingly, the stock build of gcc 6.2.0 on x86_64 linux (with LTO plugin linker plugin support) runs into a different set of failures when building emacs 25.1 using '-O0 -flto'...

  CCLD     etags
/tmp/ccS55vep.ltrans4.ltrans.o: In function `skip_spaces.lto_priv.60':
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:6677: undefined reference to `c_isspace'
/tmp/ccS55vep.ltrans4.ltrans.o: In function `skip_non_spaces.lto_priv.71':
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:6686: undefined reference to `c_isspace'
...
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:1209: undefined reference to `rpl_optind'
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:1263: undefined reference to `set_binary_mode'
collect2: error: ld returned 1 exit status

or using '-O2 -flto'...

  CCLD     etags
/tmp/ccaauRE2.ltrans1.ltrans.o: In function `strcaseeq':
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:162: undefined reference to `c_strcasecmp'
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:162: undefined reference to `c_strcasecmp'
/tmp/ccaauRE2.ltrans1.ltrans.o: In function `main':
...
/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:174: undefined reference to `c_strncasecmp'
/tmp/ccaauRE2.ltrans4.ltrans.o:/home/howarth/emacs-25.1/build/lib-src/../../lib-src/etags.c:174: more undefined references to `c_strncasecmp' follow
collect2: error: ld returned 1 exit status
Comment 2 Jack Howarth 2016-10-24 04:50:14 UTC
Note that these tests on linux used binutils-2.27.
Comment 3 Richard Biener 2016-10-24 09:02:11 UTC
LTO exposes certain classes of coding bugs.  Ask firefox / libreoffice people.  So as a start I assume these are all temacs bugs.
Comment 4 Eric Gallager 2017-07-23 22:09:28 UTC
(In reply to Richard Biener from comment #3)
> LTO exposes certain classes of coding bugs.  Ask firefox / libreoffice
> people.  So as a start I assume these are all temacs bugs.

I never got in touch with them; I guess we'll just assume this bug is actually with temacs then...