So it is this. Been using keil for small projects under 32k but finally decided to do something bigger and quickly ran out of space even with -Os.
So here my goal is to use keil IDE simply as IDE / project management / debugger, and build with arm gnu toolchain as available here:
https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain
I went to project/items and checked Use GCC compiler for arm projects, confirmed the warnings, and re-entered all the define and include paths.
under CC options, I have unchecked all the stuff under code generation, added relative paths to include folders inside my project, and added some things to misc controls like --specs=nano.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
However looking at the "compiler control line", I see the following ugly mess:
-c -mcpu=cortex-m4 -mthumb -gdwarf-2 -MD -Wall -O0 -I ./lib/CMSIS -I ./lib/CMSIS/Include -I ./lib/STM32F4xx_StdPeriph_Driver/inc -I ./lib/fatfs -I ./lib/RTT -I ./lib/wiznet --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -IC:/KEIL/ARM/CMSIS/Include -IC:/KEIL/ARM/INC/ST/STM32F4xx -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include/c++/13.2.1 -IF:/programs/arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/arm-none-eabi -D__UVISION_VERSION="538" -D__GCC -D__GCC_VERSION="1321" -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -DHSE_VALUE="8000000" -o *.o
In armcc version, there's a "no default includes" checkbox and I always check it because I don't want any files outside the project folder to affect anything I build to keep it portable.
However here, it seems to assume that I for some reason want stuff from C:\Keil and other places included with no way to force it out.
It also seems to ignore --specs because I keep getting libc link errors even tho nano/nosys shouldn't include full-sized libc...
Anyway, how do I fix this to just build? I have a normal Makefile to match this project
CFLAGS = -Wall $(OPTFLAGS) -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ggdb -ffunction-sections -fdata-sections $(INCLUDES) $(DEFINES)LDFLAGS = -Tflash.ld -Wl,--gc-sections
with these settings and everything builds fine outside of the IDE.
Just read my comment... You may have the answer there.If you don't make money from your project, why don't you switch to the Keil-MDK Community edition that doesn't have any code size limitation? My understanding was that you moved to GCC to eliminate the 32KB code size restriction. Is there a conflict with the use policy (non-commercial) of the Keil-MDK Community edition? Is it important for you to stick to GCC for other reasons?
I did read your comment. Latest GCC / clang produces potentially better code, and I may be using newest C++ features that are not in armcc etc, the reason for using gcc isn't relevant (let's ignore 32k limit for the moment) the point is the option is available, but does not work - that's what I want to fix.
The Keil MDK switched to clang since 5.37. I'm using it. I had an old project compiled with ARM_CC5 and I had to download it separately and install it as a secondary toolchain.Now I can switch from ARM_CC5 to ARCLANG. Give it a try and see if I'm wrong.
I"m aware of this as well. I still want to use gcc. If I wanted to ask about limitations of armclang from Keil, I would have titled the thread as such.
I apologize for the misunderstanding. I thought that you were looking to remove the 32 KB code size limitation. In this case, I hope you will find a solution. Good luck!