From 0277e577f3b20f370dbf7befa8959b826112bf47 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 12 Jan 2024 11:05:45 +0100 Subject: [PATCH 1/2] Replace "hard-coded" optimisation level "-Os" with the build property "compiler.optimization_flags". --- platform.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform.txt b/platform.txt index 9f670bfbe..9d196cac2 100644 --- a/platform.txt +++ b/platform.txt @@ -14,15 +14,17 @@ compiler.warning_flags.default= compiler.warning_flags.more=-Wall compiler.warning_flags.all=-Wall -Wextra +compiler.optimization_flags=-Os + compiler.path={build.compiler_path} compiler.c.cmd={build.crossprefix}gcc -compiler.c.flags=-c {compiler.warning_flags} -Os -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin +compiler.c.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin compiler.c.elf.cmd={build.crossprefix}g++ compiler.c.elf.flags=-Wl,--gc-sections --specs=nosys.specs {compiler.warning_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu} compiler.S.cmd={build.crossprefix}g++ -compiler.S.flags=-c -g -x assembler-with-cpp -Os -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections +compiler.S.flags=-c -g -x assembler-with-cpp {compiler.optimization_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections compiler.cpp.cmd={build.crossprefix}g++ -compiler.cpp.flags=-c {compiler.warning_flags} -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin +compiler.cpp.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin compiler.ar.cmd={build.crossprefix}ar compiler.ar.flags=rcs compiler.ar.extra_flags= From 9f7e1681ce4d186a4e7ed2f0a6fed6344e9fb723 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 12 Jan 2024 11:08:24 +0100 Subject: [PATCH 2/2] Define different optimisation flags for release and debug. -Og provides "a reasonable level of optimization while maintaining fast compilation and a good debugging experience". --- platform.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform.txt b/platform.txt index 9d196cac2..06091223c 100644 --- a/platform.txt +++ b/platform.txt @@ -15,6 +15,8 @@ compiler.warning_flags.more=-Wall compiler.warning_flags.all=-Wall -Wextra compiler.optimization_flags=-Os +compiler.optimization_flags.release=-Os +compiler.optimization_flags.debug=-Og compiler.path={build.compiler_path} compiler.c.cmd={build.crossprefix}gcc