This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GCC 11.2 arm-none-eabi, internal compiler error: Illegal instruction

Hello.

I am trying to use GCC 11.2 on Ubuntu 21.04 (x86_64 Linux hosted cross toolchains, gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz) to compile a program for STM32 (Cortex-M).

If I use float in the program, the build fails with an error "internal compiler error: Illegal instruction". If I do not use float, the build succeeds. If I change the toolchain path in Makefile to 10.3, the build succeeds with and without float.

Here is an example of the code I am trying to build:

#include "main.h"


int main(void){
	float f;

	while(1){
		f = f + 0.1;
	};

}

And here is my Makefile:

TARGET = firmware
DEBUG = 1
OPT = -O2
BUILD_DIR = build

C_SOURCES =  \
main.c

ASM_SOURCES =  \
startup.s

#Path to GCC10.3
GCC_PATH = ~/soft/gcc-arm-none-eabi/bin
#Path to GCC11.2
#GCC_PATH = ~/soft/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin
PREFIX = arm-none-eabi-
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
 
CPU = -mcpu=cortex-m7
FPU = -mfpu=fpv5-sp-d16
FLOAT-ABI = -mfloat-abi=hard
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
AS_DEFS = 
C_DEFS =  \
-DSTM32F730xx
AS_INCLUDES = 
C_INCLUDES =  \
-ISrc

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif

CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"

LDSCRIPT = linker.ld

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -Wl,--print-memory-usage

# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin

#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
	$(AS) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(HEX) $< $@
	
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(BIN) $< $@	
	
$(BUILD_DIR):
	mkdir $@		

clean:
	-rm -fR $(BUILD_DIR)
  
-include $(wildcard $(BUILD_DIR)/*.d)

If I try to build with GCC 11.2, I get an error:

main.c:8:17: internal compiler error: Illegal instruction
    8 |                 f = f + 0.1;
      |                 ^

If I just change GCC_PATH in Makefile to 10.3, the build succeeds.

Parents
  • Same issue on Cortex-r52 target with

    -march=armv8-r -mtune=cortex-r52 -mfpu=vfpv3-d16 -mfloat-abi=hard
    

    it compiles fine with arm-none-eabi-gcc10 and arm-none-eabi-gcc9 but not with new toochain based on gcc 11.2-2022.02

    float.c:61:9: internal compiler error: Illegal instruction
       61 |         float x = 3.4;

    By the way I tried to compile also with

    AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf)

    And I have the same error with float types

Reply
  • Same issue on Cortex-r52 target with

    -march=armv8-r -mtune=cortex-r52 -mfpu=vfpv3-d16 -mfloat-abi=hard
    

    it compiles fine with arm-none-eabi-gcc10 and arm-none-eabi-gcc9 but not with new toochain based on gcc 11.2-2022.02

    float.c:61:9: internal compiler error: Illegal instruction
       61 |         float x = 3.4;

    By the way I tried to compile also with

    AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf)

    And I have the same error with float types

Children
No data