nternal Compiler error with Cortex M0+ and -mtpcs-leaf-frame

Asked by Uwe Bonnes

Hello,

is following behaviour a bug? Should I file as bug with the tad file appended?
I see no way to attach files here.

Running in the directory from appended tar file give

> arm-none-eabi-gcc -c -MD -MP -mcpu=cortex-m0plus -mthumb -D__CORTEX__ -ffunction-sections -fdata-sections -fomit-frame-pointer -g3 -Og -Wall -Wstrict-prototypes -Werror -O0 -mtpcs-frame -mtpcs-leaf-frame -fno-omit-frame-pointer test.c
test.c: In function 'main':
test.c:5:1: error: insn does not satisfy its constraints:
 }
 ^
(insn 23 22 24 (set (reg:SI 2 r2)
        (reg:SI 15 pc)) test.c:3 187 {*thumb1_movsi_insn}
     (nil))
test.c:5:1: internal compiler error: in note_invalid_constants, at config/arm/arm.c:15756
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

gives an internal compiler error.
Removing -mtpcs-frame from the command line lets the file compile:

> arm-none-eabi-gcc -c -MD -MP -mcpu=cortex-m0plus -mthumb -D__CORTEX__ -ffunction-sections -fdata-sections -fomit-frame-pointer -g3 -Og -Wall -Wstrict-prototypes -Werror -O0 -mtpcs-frame -fno-omit-frame-pointer test.c

-mtpcs-frame is not flagged to be invalid with M0+. The same error happens when compiling for M0.

> arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/cross/gcc-arm-none-eabi/bin/arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/opt/cross/gcc-arm-none-eabi-4_8-2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/lto-wrapper
Target: arm-none-eabi
Configured with: /home/build/work/GCC-4-8-build/src/gcc/configure --target=arm-none-eabi --prefix=/home/build/work/GCC-4-8-build/install-native --libexecdir=/home/build/work/GCC-4-8-build/install-native/lib --infodir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build/work/GCC-4-8-build/install-native/arm-none-eabi --build=i686-linux-gnu --host=i686-linux-gnu --with-gmp=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-mpfr=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-mpc=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-isl=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-cloog=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-libelf=/home/build/work/GCC-4-8-build/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r
Thread model: single
gcc version 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147] (GNU Tools for ARM Embedded Processors)

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Terry Guo (terry.guo) said :
#1

Thanks for reporting. This indeed looks like a bug of compiler. If test.c is very small, you can just copy/paste its content here, so that we can give it a try. Otherwise, please report a new bug and link this one with new bug entry.

Revision history for this message
Uwe Bonnes (bon) said :
#2

The test file is a no-brainer.

> cat test.c
#include "core_cm0plus.h"
int main(void)
{
    return 0;
}

However it needs core_cm0plus.h, core_cmFunc.h and core_cmInstr.h from CMSIS. Let me know if you need these files. Otherwise they com from ARM direct or with the CMSIS file from a manufacturer.

Revision history for this message
Terry Guo (terry.guo) said :
#3

Sorry that I can't reproduce the issue. This test case needs a header file of a real board. By default, the CMSIS provides such file for real board ARM MPS. So here is my case and command:

terguo01@terry-pc01:q256933$ cat test.c
#include "ARMCM0plus.h"
#include "core_cm0plus.h"

int
main (void)
{
  return 0;
}
terguo01@terry-pc01:q256933$ /work/terguo01/tools/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi-gcc -c -MD -MP -mcpu=cortex-m0plus -mthumb -D__CORTEX__ -ffunction-sections -fdata-sections -fomit-frame-pointer -g3 -Og -Wall -Wstrict-prototypes -Werror -O0 -mtpcs-frame -fno-omit-frame-pointer test.c -I /work/terguo01/cmsis/r4p1/CMSIS/Include/ -I /work/terguo01/cmsis/r4p1/Device/ARM/ARMCM0plus/Include/
terguo01@terry-pc01:q256933$ echo $?
0

I can't reproduce with both CMSIS 4.1 and the latest CMSIS 4.2. I guess you are using a header file from your board vendor. In this case, would you please provide a preprocessed file? Feel free to open a bug if you need.

By the way I am testing with Linux version tool chain.

Revision history for this message
Uwe Bonnes (bon) said :
#4

The file is for the STM32L0, as distributed in Stm32cubeL1, V1.1.0, or in MBED Git Head https://github.com/mbedmicro/mbed.git, ./libraries/mbed/targets/cmsis/core_cm0plus.h. This version is older:
/**************************************************************************//**
 * @file core_cmFunc.h
 * @brief CMSIS Cortex-M Core Function Access Header File
 * @version V3.20
 * @date 25. February 2013
 *
 * @note
 *
 ******************************************************************************/
/* Copyright (c) 2009 - 2013 ARM LIMITED

Where to get CMSIS 4.1 and the latest CMSIS 4.2?

Revision history for this message
Terry Guo (terry.guo) said :
#5

The one from MBED still works for me. Am I missing something?

terguo01@terry-pc01:q256933$ cat test.c
#include "stm32l0xx.h"
#include "core_cm0plus.h"

int
main (void)
{
  return 0;
}
terguo01@terry-pc01:q256933$ /work/terguo01/tools/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi-gcc -c -MD -MP -mcpu=cortex-m0plus -mthumb -D__CORTEX__ -ffunction-sections -fdata-sections -fomit-frame-pointer -g3 -Og -Wall -Wstrict-prototypes -Werror -O0 -mtpcs-frame -fno-omit-frame-pointer test.c -I /work/terguo01/sources/mbed/libraries/mbed/targets/cmsis/ -I /work/terguo01/sources/mbed/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L053R8/ -I /work/terguo01/sources/mbed/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/

The latest CMSIS can be downloaded from cmsis.arm.com. You need to registration first.

Revision history for this message
Terry Guo (terry.guo) said :
#7

This question is confirmed as a compiler bug and thus subsequent discussions will be done in that bug entry.