Bug 69866 - lto1: internal compiler error: in add_symbol_to_partition_1, at lto/lto-partition.c:158
Summary: lto1: internal compiler error: in add_symbol_to_partition_1, at lto/lto-parti...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2016-02-18 19:19 UTC by acrsofter
Modified: 2018-10-17 19:55 UTC (History)
0 users

See Also:
Host:
Target: arm-none-eabi
Build:
Known to work: 8.1.0
Known to fail: 5.4.1, 6.1.1, 7.0
Last reconfirmed: 2016-07-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description acrsofter 2016-02-18 19:19:37 UTC
lto1: internal compiler error: in add_symbol_to_partition_1, at lto/lto-partition.c:158
0x58b14d add_symbol_to_partition_1
	../../gcc-5.3.0/gcc/lto/lto-partition.c:157
0x58aeb2 add_symbol_to_partition_1
	../../gcc-5.3.0/gcc/lto/lto-partition.c:202
0x58c10c lto_balanced_map(int)
	../../gcc-5.3.0/gcc/lto/lto-partition.c:550
0x58640d do_whole_program_analysis
	../../gcc-5.3.0/gcc/lto/lto.c:3324
0x58640d lto_main()
	../../gcc-5.3.0/gcc/lto/lto.c:3485
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: arm-none-eabi-gcc returned 1 exit status
compilation terminated.
/files/work/acr/wip_elibos/elibos_toolchains/gcc-arm/gcc-arm-none-eabi-5.3.0-a/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
../../../os/common/ports/ARMCMx/compilers/GCC/rules.mk:238: recipe for target 'build/ch.elf' failed
make: *** [build/ch.elf] Error 1



buildind ChibiOS_16.1.3/demos/STM32/RT-STM32F401RE-NUCLEO

https://sourceforge.net/projects/chibios/files/


./arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=./arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/files/work/acr/wip_elibos/elibos_toolchains/gcc-arm/gcc-arm-none-eabi-5.3.0-a/bin/../libexec/gcc/arm-none-eabi/5.3.0/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-5.3.0/configure --prefix=/opt/arm_cross --target=arm-none-eabi --enable-languages=c,c++ --disable-multilib --with-newlib
Thread model: single
gcc version 5.3.0 (GCC)
Comment 1 Richard Biener 2016-02-19 08:51:55 UTC
Can you try a recent snapshot and provide a testcase please?
Comment 2 Martin Liška 2016-02-19 10:35:18 UTC
Issue with ChibiOS was already discussed a bit in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65380#c17

Where a reproducer script uses a base metal compiler.

Martin
Comment 3 acrsofter 2016-02-20 03:25:13 UTC
reproduce steps:

[foo.c]

int _umh(int i)
{
  return i+1;
}

int weaks(int i) __attribute__((weak, alias("_umh")));

int main()
{
 return weaks(10);
}


[bar.c]

int weaks(int i)
{
  return i+1;
}


now compile:

gcc -c bar.c

gcc -flto -c foo.c

gcc -flto -o elf bar.o foo.o


note:

bar compiled without flt
but rest with flt


now at linking stage booms
at line

 gcc_assert (c != SYMBOL_EXTERNAL
      && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node)));

in lto/lto-partition.c

===============================================================

same code compiled without lto ok

gcc 4.9.3 not affected
but 5.3.0 affected and latest (gcc-6-20160214) affected
Comment 4 acrsofter 2016-02-23 08:24:56 UTC
someone here can deal with it?
Comment 5 Thomas Preud'homme 2016-07-20 13:05:20 UTC
I can indeed reproduce that bug with latest gcc-5-branch either by compiling the below testcase, or by building ChibiOS 3.0.4 as described in https://answers.launchpad.net/gcc-arm-embedded/+question/280242

Best regards.

(In reply to acrsofter from comment #3)
> reproduce steps:
> 
> [foo.c]
> 
> int _umh(int i)
> {
>   return i+1;
> }
> 
> int weaks(int i) __attribute__((weak, alias("_umh")));
> 
> int main()
> {
>  return weaks(10);
> }
> 
> 
> [bar.c]
> 
> int weaks(int i)
> {
>   return i+1;
> }
> 
> 
> now compile:
> 
> gcc -c bar.c
> 
> gcc -flto -c foo.c
> 
> gcc -flto -o elf bar.o foo.o
> 
> 
> note:
> 
> bar compiled without flt
> but rest with flt
> 
> 
> now at linking stage booms
> at line
> 
>  gcc_assert (c != SYMBOL_EXTERNAL
>       && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node)));
> 
> in lto/lto-partition.c
> 
> ===============================================================
> 
> same code compiled without lto ok
> 
> gcc 4.9.3 not affected
> but 5.3.0 affected and latest (gcc-6-20160214) affected
Comment 6 Thomas Preud'homme 2016-07-20 14:16:02 UTC
I can also reproduce both bugs with trunk GCC.
Comment 7 Thomas Preud'homme 2016-07-20 15:44:08 UTC
Update version accordingly.
Comment 8 Martin Liška 2017-02-01 14:17:10 UTC
Is affected just the arm-none-eabi target, or are any others?
Comment 9 Thomas Preud'homme 2017-02-28 11:15:24 UTC
Got a patch that works for this testcase and building ChibiOS 3.0.4. Will run more testing.
Comment 10 Thomas Preud'homme 2017-03-02 14:54:17 UTC
Patch has been submitted for review: https://gcc.gnu.org/ml/gcc-patches/2017-03/msg00110.html
Comment 11 Jan Hubicka 2017-06-15 18:42:42 UTC
Author: hubicka
Date: Thu Jun 15 18:42:10 2017
New Revision: 249224

URL: https://gcc.gnu.org/viewcvs?rev=249224&root=gcc&view=rev
Log:

	PR lto/69866
	* lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
	that resolved externally.

	* gcc.dg/lto/pr69866_0.c: New test.
	* gcc.dg/lto/pr69866_1.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/lto/pr69866_0.c
    trunk/gcc/testsuite/gcc.dg/lto/pr69866_1.c
Modified:
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto-partition.c
    trunk/gcc/lto/lto-symtab.c
    trunk/gcc/testsuite/ChangeLog
Comment 12 Thomas Preud'homme 2017-06-20 11:20:08 UTC
Author: thopre01
Date: Tue Jun 20 11:19:36 2017
New Revision: 249406

URL: https://gcc.gnu.org/viewcvs?rev=249406&root=gcc&view=rev
Log:
Fix PR69866

2017-06-20  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	Backport from mainline
	2017-06-15  Jan Hubicka  <hubicka@ucw.cz>
		    Thomas Preud'homme  <thomas.preudhomme@arm.com>

	gcc/
	PR lto/69866
	* lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
	that resolved externally.
	2017-06-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	gcc/testsuite/
	PR lto/69866
	* gcc.dg/lto/pr69866_0.c: New test.
	* gcc.dg/lto/pr69866_1.c: Likewise.

	Backport from mainline
	2017-06-18  Jan Hubicka  <hubicka@ucw.cz>

	gcc/testsuite/
	* gcc.dg/lto/pr69866_0.c: This test needs alias.

Added:
    branches/ARM/embedded-6-branch/gcc/lto/ChangeLog.arm
    branches/ARM/embedded-6-branch/gcc/testsuite/gcc.dg/lto/pr69866_0.c
    branches/ARM/embedded-6-branch/gcc/testsuite/gcc.dg/lto/pr69866_1.c
Modified:
    branches/ARM/embedded-6-branch/gcc/lto/lto-symtab.c
    branches/ARM/embedded-6-branch/gcc/testsuite/ChangeLog.arm
Comment 13 Thomas Preud'homme 2017-06-21 08:18:28 UTC
Author: thopre01
Date: Wed Jun 21 08:17:56 2017
New Revision: 249437

URL: https://gcc.gnu.org/viewcvs?rev=249437&root=gcc&view=rev
Log:
2017-06-21  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	Revert:

	Backport from mainline
	2017-06-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	PR lto/69866
	* gcc.dg/lto/pr69866_0.c: New test.
	* gcc.dg/lto/pr69866_1.c: Likewise.

	Backport from mainline
	2017-06-18  Jan Hubicka  <hubicka@ucw.cz>

	* gcc.dg/lto/pr69866_0.c: This test needs alias.


Removed:
    branches/ARM/embedded-6-branch/gcc/lto/ChangeLog.arm
    branches/ARM/embedded-6-branch/gcc/testsuite/gcc.dg/lto/pr69866_0.c
    branches/ARM/embedded-6-branch/gcc/testsuite/gcc.dg/lto/pr69866_1.c
Modified:
    branches/ARM/embedded-6-branch/gcc/lto/lto-symtab.c
    branches/ARM/embedded-6-branch/gcc/testsuite/ChangeLog.arm
Comment 14 Thomas Preud'homme 2017-11-28 15:19:45 UTC
Author: thopre01
Date: Tue Nov 28 15:19:14 2017
New Revision: 255203

URL: https://gcc.gnu.org/viewcvs?rev=255203&root=gcc&view=rev
Log:
Fix ICE in add_symbol_to_partition_1

2017-11-28  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	Backport from mainline
	2017-06-15  Jan Hubicka  <hubicka@ucw.cz>
		    Thomas Preud'homme  <thomas.preudhomme@arm.com>

	gcc/lto/
	PR lto/69866
	* lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
	that resolved externally.

	Backport from mainline
	2017-06-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	gcc/testsuite/
	PR lto/69866
	* gcc.dg/lto/pr69866_0.c: New test.
	* gcc.dg/lto/pr69866_1.c: Likewise.


Added:
    branches/ARM/embedded-7-branch/gcc/lto/ChangeLog.arm
    branches/ARM/embedded-7-branch/gcc/testsuite/gcc.dg/lto/pr69866_0.c
    branches/ARM/embedded-7-branch/gcc/testsuite/gcc.dg/lto/pr69866_1.c
Modified:
    branches/ARM/embedded-7-branch/gcc/lto/lto-partition.c
    branches/ARM/embedded-7-branch/gcc/lto/lto-symtab.c
    branches/ARM/embedded-7-branch/gcc/testsuite/ChangeLog.arm
Comment 15 Thomas Preud'homme 2018-05-05 10:03:51 UTC
Fixed in r249224 and thus fixed on 8.1
Comment 16 Thomas Preud'homme 2018-07-13 12:11:50 UTC
@honza: would you mind backporting to GCC 7? IIRW GCC 6 backport is more tricky.

Thanks!