https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91163
Bug ID: 91163 Summary: ARM lto optimalization fail in big-endian case (error: could not unlink output file) Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: jdobry at centrum dot cz CC: marxin at gcc dot gnu.org Target Milestone: --- Hello, in short problem is simple. Let's have file test.c with this content: int main() {} Compile it by this command: arm-none-eabi-gcc -o test.elf -mcpu=cortex-r5 -mbig-endian -mthumb -T empty.ld -Wl,--gc-sections -flto test.c Compilation fails with this error message: ....../arm-none-eabi/bin/ld.exe: error: could not unlink output file This problem is strange, because it have strange conditions to reproduction. * I can reproduce it on any version 8.x and 9.x which I try * I can't reproduce it on linux, is it only windows problem? Why? * It depend to endianity. Without -mbig-endian is is compiled successfully * It depend to -flto. I can follow this problem into LTO plugin/wrapper (it fails on lto-plugin.c function cleanup_handler() which try to unlink existing temporary file test.elf.??????.ltrans0.ltrans.o) In long description we need to compile ARM big-endian code for TI TMS570xxxx MCUs. I was create patch for this functionality till year 2011. It was not need any changes in compiler, only compile BE variant of libraries. We try to push this minor patch to ARM GCC distribution several times. Without success. Reason was problems with auto test for every release of this package. Problem happen with GCC 8 because it integrate multilib support fully. Now is proper place to try push this patch to GCC directly. But I can't send it include this problem. Here is patch for bigendian multilib support, needed by TMS570 MCU family. https://pastebin.com/hMfSd7h3 Jiri NOTE: empty.ld is deliberately empty file