lto1.exe: internal compiler error

Bug #1570613 reported by Benjamin
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Fix Released
Medium
Thomas Preud'homme
gcc
Fix Released
Medium

Bug Description

Use latest GCC ARM Embedded 5.0/5-2016-q1:
https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe
- host machine: Windows 7 SP1 64bits Asus N56VZ (16GB RAM+SSD Samsung 850 PRO 512GB)

Using repo https://github.com/bvernoux/hydrafw up to commit https://github.com/bvernoux/hydrafw/commit/3679dc0601220ee4ac897d7e3af4cb59b545e984
Just do
make clean
make
See also
https://github.com/bvernoux/hydrafw/wiki/how-to-build-flash-and-use-hydrafw-on-windows
or
https://github.com/bvernoux/hydrafw/wiki/how-to-build-flash-and-use-hydrafw-on-linux

Linking build/hydrafw.elf
lto1.exe: internal compiler error: in add_symbol_to_partition_1, at lto/lto-partition.c:158
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper.exe: fatal error: d:\GNU_ARM_5_3_2016q1\bin\arm-none-eabi-gcc.exe returned 1 exit status
compilation terminated.
d:/gnu_arm_5_3_2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
make: *** [build/hydrafw.elf] Error 1

For information the build/link work perfectly (with no error) with GNU_ARM_4_7_2013q3 and GNU_ARM_4_9_2015q3

Revision history for this message
In , Acrsofter (acrsofter) wrote :

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)

Revision history for this message
In , Rguenth (rguenth) wrote :

Can you try a recent snapshot and provide a testcase please?

Revision history for this message
In , Marxin-m (marxin-m) wrote :

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

Revision history for this message
In , Acrsofter (acrsofter) wrote :

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

Revision history for this message
In , Acrsofter (acrsofter) wrote :

someone here can deal with it?

Benjamin (bvernoux)
tags: added: 5-2016-q1-update bug
Changed in gcc-arm-embedded:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

Hi Benjamin,

We are aware of this but on some machine the failure does not happen very often which complicates debugging. We'll update the bug report as we progress.

Best regards

Revision history for this message
Benjamin (bvernoux) wrote : Re: [Bug 1570613] Re: lto1.exe: internal compiler error

Hi Thomas,

The problem is always reproductible on my side
Tell me if you want more details in order to reproduce it.

Best regards,
Benjamin Vernoux
Le 15 avr. 2016 14:20, "Thomas Preud'homme" <email address hidden> a
écrit :

Hi Benjamin,

We are aware of this but on some machine the failure does not happen
very often which complicates debugging. We'll update the bug report as
we progress.

Best regards

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1570613

Title:
  lto1.exe: internal compiler error

Status in GCC ARM Embedded:
  Confirmed

Bug description:

  Use latest GCC ARM Embedded 5.0/5-2016-q1:

https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe
  - host machine: Windows 7 SP1 64bits Asus N56VZ (16GB RAM+SSD Samsung 850
PRO 512GB)

  Using repo https://github.com/bvernoux/hydrafw up to commit
https://github.com/bvernoux/hydrafw/commit/3679dc0601220ee4ac897d7e3af4cb59b545e984
  Just do
  make clean
  make
  See also

https://github.com/bvernoux/hydrafw/wiki/how-to-build-flash-and-use-hydrafw-on-windows
  or

https://github.com/bvernoux/hydrafw/wiki/how-to-build-flash-and-use-hydrafw-on-linux

  Linking build/hydrafw.elf
  lto1.exe: internal compiler error: in add_symbol_to_partition_1, at
lto/lto-partition.c:158
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <http://gcc.gnu.org/bugs.html> for instructions.
  lto-wrapper.exe: fatal error:
d:\GNU_ARM_5_3_2016q1\bin\arm-none-eabi-gcc.exe returned 1 exit status
  compilation terminated.

d:/gnu_arm_5_3_2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld.exe:
error: lto-wrapper failed
  collect2.exe: error: ld returned 1 exit status
  make: *** [build/hydrafw.elf] Error 1

  For information the build/link work perfectly (with no error) with
  GNU_ARM_4_7_2013q3 and GNU_ARM_4_9_2015q3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1570613/+subscriptions

Revision history for this message
In , Thopre01 (thopre01) wrote :

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

Revision history for this message
In , Thopre01 (thopre01) wrote :

I can also reproduce both bugs with trunk GCC.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

Hi,

There is already an bug open for this in GCC's bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71607

I've just tested with newer versions of the compiler and updated the bug accordingly.

Best regards.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :
Revision history for this message
In , Thopre01 (thopre01) wrote :

Update version accordingly.

Revision history for this message
Benjamin (bvernoux) wrote :

Do you have any update about this bug ?
For me it shall be set as BLOCKER bug as it is very important/mandatory to use -lto option on embedded firmware (to speedup code and lower code size ...)
I see it is not even fixed for new GCC version "Release GCC ARM Embedded 5 update 3"

Revision history for this message
In , Marxin-m (marxin-m) wrote :

Is affected just the arm-none-eabi target, or are any others?

Changed in gcc-arm-embedded:
status: Confirmed → In Progress
Revision history for this message
In , Thopre01 (thopre01) wrote :

Got a patch that works for this testcase and building ChibiOS 3.0.4. Will run more testing.

Changed in gcc:
importance: Unknown → Medium
status: Unknown → In Progress
Revision history for this message
In , Thopre01 (thopre01) wrote :
Changed in gcc-arm-embedded:
assignee: nobody → Thomas Preud'homme (thomas-preudhomme)
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :
Revision history for this message
In , Hubicka (hubicka) wrote :

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

Revision history for this message
In , Thopre01 (thopre01) wrote :

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 <email address hidden>

 Backport from mainline
 2017-06-15 Jan Hubicka <email address hidden>
      Thomas Preud'homme <email address hidden>

 gcc/
 PR lto/69866
 * lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
 that resolved externally.
 2017-06-15 Thomas Preud'homme <email address hidden>

 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 <email address hidden>

 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

Changed in gcc-arm-embedded:
status: In Progress → Fix Committed
Revision history for this message
In , Thopre01 (thopre01) wrote :

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 <email address hidden>

 Revert:

 Backport from mainline
 2017-06-15 Thomas Preud'homme <email address hidden>

 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 <email address hidden>

 * 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

Revision history for this message
In , Thopre01 (thopre01) wrote :

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 <email address hidden>

 Backport from mainline
 2017-06-15 Jan Hubicka <email address hidden>
      Thomas Preud'homme <email address hidden>

 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 <email address hidden>

 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

Changed in gcc-arm-embedded:
milestone: none → 8-2018-q4-major
Revision history for this message
In , Thopre01 (thopre01) wrote :

Fixed in r249224 and thus fixed on 8.1

Revision history for this message
In , Thopre01 (thopre01) wrote :

@honza: would you mind backporting to GCC 7? IIRW GCC 6 backport is more tricky.

Thanks!

Changed in gcc:
status: In Progress → Confirmed
Joey Ye (jinyun-ye)
Changed in gcc-arm-embedded:
status: Fix Committed → Fix Released
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :
Download full text (7.4 KiB)

The master branch has been updated by Maciej W. Rozycki <email address hidden>:

https://gcc.gnu.org/g:76a553587f3181605c57801c37b0d3e94ce3aca5

commit r11-5795-g76a553587f3181605c57801c37b0d3e94ce3aca5
Author: Maciej W. Rozycki <email address hidden>
Date: Sat Dec 5 18:26:27 2020 +0000

    VAX: Fix the LTO compiler downgrading code to non-PIC model

    Fix a testsuite failure:

    /tmp/ccL65Mmt.s: Assembler messages:
    /tmp/ccL65Mmt.s:36: Warning: Symbol n used as immediate operand in PIC mode.
    FAIL: gcc.dg/lto/pr55660 c_lto_pr55660_0.o-c_lto_pr55660_1.o link, -O0 -flto -flto-partition=none -fuse-linker-plugin

    where non-PIC code is substituted by the LTO compiler at the link stage
    for what used to be PIC code in the original compilation. This happens
    because in the de-facto VAX ELF psABI we rely on code being PIC for GOT
    support in dynamic executables and arrange that by having `-fPIC' passed
    to the compiler by default by means of a specs recipe.

    That is however canceled where the LTO wrapper is used, by an internal
    arrangement in the LTO compiler that clears the PIC flag whenever the
    `-flinker-output=exec' option has been used. This has been deliberately
    introduced with commit 1ff9ed6fb282 ("re PR lto/67548 (LTO drops weak
    binding with "ld -r")")[1]:

    "In the log of PR67548 HJ actually pointed out that we do have API at
    linker plugin side which says what type of output is done. This is cool
    because we can also use it to drop -fpic when building static binary.
    This is common in Firefox, where some objects are built with -fpic and
    linked to both binaries and libraries."

    with this code:

        case LTO_LINKER_OUTPUT_EXEC: /* Normal executable */
          flag_pic = 0;
          flag_pie = 0;
          flag_shlib = 0;
          break;

    Consequently code like:

    .L6:
            addl3 -8(%fp),$n,%r0
            pushl %r0
            calls $1,foo
            addl2 %r0,-12(%fp)
            incl -8(%fp)
    .L5:

    is produced by the LTO compiler, where a reference to `n' is used that
    is invalid in PIC code, because it uses the immediate addressing mode,
    denoted by the `$' prefix.

    For that not to happen we must never pass `-flinker-output=exec' to the
    LTO compiler unless non-PIC code has been explicitly requested. Using
    `-flinker-output=dyn' except for relocatable output would seem the
    simplest approach, as it does not fiddle with any of the internal code
    model settings beyond what the command-line options have arranged and
    therefore lets them remain the same as with the original compilation,
    but it breaks as well causing PR lto/69866 to retrigger, as that code
    seems sensitive to `flag_shlib':

    lto1: internal compiler error: in add_symbol_to_partition_1, at lto/lto-partition.c:152
    0x105be1cb add_symbol_to_partition_1
            .../gcc/lto/lto-partition.c:152
    0x105be443 add_symbol_to_partition_1
            .../gcc/lto/lto-partition.c:194
    0x105be80f add_symbol_to_partition
            .../gcc/lto/lto-partition.c:270
    0x105bee6f add_sorted_nodes
       ...

Read more...

Revision history for this message
In , Rguenth (rguenth) wrote :

Fixed.

Revision history for this message
In , Rguenth (rguenth) wrote :

*** Bug 88550 has been marked as a duplicate of this bug. ***

Changed in gcc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.