GCC 7.2.1 with LTO produces invalid assembler code

Asked by aoandr

I've got the following error at linking time when compiling FreeRTOS with -flto:

GNU assembler version 2.29.51 (arm-none-eabi) using BFD version (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 2.29.51.20171128
/tmp/ccXrBd4D.s: Assembler messages:
/tmp/ccXrBd4D.s:27: Error: offset out of range
lto-wrapper: fatal error: arm-none-eabi-gcc returned 1 exit status
compilation terminated.

The line 27 of the assembler code is:
                ldr.w r0, =0xE000ED88

The same source code is successfully compiled and linked by the previous ARM GCC release (6-2017-q2-update). It also compiles and runs when compiled without LTO mode.

Shall I file a bug report ?
(The bug-reporting page insists that I shall first post my problem here, so here you are.)

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi aoandr,

Could you provide us with the command-line used to compile and link as well as the source file involved? If you cannot release those please reduce it the problem to something you can release. We cannot investigate the problem if we cannot reproduce it.

Best regards.

Revision history for this message
aoandr (t-launchpad-nbs-eng-ru) said :
#2

I can not find a way to attach a file to the question here.

So, here is a link to a file on Dropbox.

https://www.dropbox.com/s/gnogyw0qrljv5pk/sample.tar.xz?dl=0

The file contains everything required to reproduce the problem.
Just untar the archive, cd to the test/ directory and run build.sh.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#3

Confirmed. It does work with GCC 8 though which means it might have been fixed there. Feel free to open a bug report if you want, otherwise I'll let you know of the progress here.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#4

Sadly it seems it just does less inlining in GCC 8 for that case so we just avoid the bug. It might still be present.

Revision history for this message
aoandr (t-launchpad-nbs-eng-ru) said :
#5

From my experience, the bug is quite elusive. A minor change to the source code can mask it.

Also, though this particular example does not trigger the bug on GCC 6 (6-2017-q2-update), I _think_ I've seen the same error message from GCC 6 on partially reduced code once. Unfortunately, I've lost that test case. My point is: the bug may be present in older GCC versions too.

I am going to file a formal bug report.
Thanks for your efforts.

Revision history for this message
aoandr (t-launchpad-nbs-eng-ru) said :
#6

I've linked this question to the bug report.
See the Bug #1763050: GCC 7.2.1 with LTO reports "Error: offset out of range" for more info and the test case.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#7

Marking this question as answers since a solution has been provided in the linked bug: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1763050

Can you help with this problem?

Provide an answer of your own, or ask aoandr for more information if necessary.

To post a message you must log in.