-flto causes unresolved reference to __clear_cache

Bug #1630668 reported by JC Wren
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Won't Fix
Medium
Unassigned

Bug Description

When GCC 5.4 2016q3 adds a __clear_cache call and -flto is enabled, ld reports __clear_cache as an unresolved reference.

Target is Cortex-M3 (STM32L151ZD). Attached is a file that will reproduce this issue.

As this uses arm-eabi-none-ar, which requires the --plugin argument when using LTO, I had to copy liblto_plugin-0.dll to the working directory when running under Cygwin. This is also noted in the README.txt file.

This bug report is part of thread https://answers.launchpad.net/gcc-arm-embedded/+question/402728

Revision history for this message
JC Wren (jcwren) wrote :
Changed in gcc-arm-embedded:
status: New → Confirmed
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

Hi JC,

We haven't a patch at this point yet but the problem is well understood thanks to your testcase. It only happens when linking static archive so you can work around the issue by either:

- not putting the object file in an archive
- or extracting the elements from the archive for linking

I will let you know once this is fixed.

Best regards,

Thomas

Changed in gcc-arm-embedded:
importance: Undecided → Medium
assignee: nobody → Thomas Preud'homme (thomas-preudhomme)
Changed in gcc-arm-embedded:
status: Confirmed → In Progress
Revision history for this message
JC Wren (jcwren) wrote :

Thomas,

From what I can tell, this bug is still in progress, correct?. I gave '6 2017-q2-update' a try, and the error still occurs.

Cheers,
--jc

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

Hi JC,

The bug is not fixed indeed. As I said the problem is well understood but other issues took priority considering as this can be worked around by avoiding the mix of LTO and static libraries. That said I should report the problem to the GNU ld community so that there's a chance the community could fix it before me.

Best regards.

Revision history for this message
JC Wren (jcwren) wrote :

Yah, no problem, just verifying more than anything.

I did convert my project from using a library to linking all the .o files directly. The bootloader links and runs correctly with -flto, but the main application does not run, although it does link. I have not yet had a chance to put it on the debugger and see why it's not starting.

Thanks!

Changed in gcc-arm-embedded:
status: In Progress → Confirmed
Changed in gcc-arm-embedded:
assignee: Thomas Preud'homme (thomas-preudhomme) → nobody
Revision history for this message
Joey Ye (jinyun-ye) wrote :

Close it with won't fix as there is a workaround available.

Changed in gcc-arm-embedded:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Bug attachments

Remote bug watches

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