From 7a9ffa9270b5c9b886ab59fe674c722a8a5c3e00 Mon Sep 17 00:00:00 2001 From: Sergey Pluzhnikov Date: Tue, 8 Nov 2022 20:00:46 +0100 Subject: [PATCH 1/5] Ref. #926. Fixes for LTO build. --- src/modm/platform/clock/stm32/rcc.cpp.in | 4 ++-- src/modm/platform/heap/cortex/heap_newlib.cpp | 3 +-- src/modm/platform/heap/cortex/no_heap.c.in | 2 +- .../cmake/resources/ci_CMakeLists.txt.in | 5 +++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modm/platform/clock/stm32/rcc.cpp.in b/src/modm/platform/clock/stm32/rcc.cpp.in index 3e1c73ae44..7cd40d1661 100644 --- a/src/modm/platform/clock/stm32/rcc.cpp.in +++ b/src/modm/platform/clock/stm32/rcc.cpp.in @@ -23,8 +23,8 @@ modm_weak void SystemCoreClockUpdate() { /* Nothing to update */ } namespace modm::platform { -constinit uint16_t modm_fastdata delay_fcpu_MHz(computeDelayMhz(Rcc::BootFrequency)); -constinit uint16_t modm_fastdata delay_ns_per_loop(computeDelayNsPerLoop(Rcc::BootFrequency)); +constinit uint16_t modm_fastdata modm_used delay_fcpu_MHz(computeDelayMhz(Rcc::BootFrequency)); +constinit uint16_t modm_fastdata modm_used delay_ns_per_loop(computeDelayNsPerLoop(Rcc::BootFrequency)); // ---------------------------------------------------------------------------- %% if target.family == "f0" diff --git a/src/modm/platform/heap/cortex/heap_newlib.cpp b/src/modm/platform/heap/cortex/heap_newlib.cpp index 0987802536..1c906d59bf 100644 --- a/src/modm/platform/heap/cortex/heap_newlib.cpp +++ b/src/modm/platform/heap/cortex/heap_newlib.cpp @@ -40,8 +40,7 @@ void __modm_initialize_memory(void) * Note: This implementation is not thread safe (despite taking a * _reent structure as a parameter). */ -void * -_sbrk_r(struct _reent *, ptrdiff_t size) +modm_used void * _sbrk_r(struct _reent *, ptrdiff_t size) { const uint8_t *const heap = heap_top; heap_top += size; diff --git a/src/modm/platform/heap/cortex/no_heap.c.in b/src/modm/platform/heap/cortex/no_heap.c.in index 4c963b885e..273d18f4e0 100644 --- a/src/modm/platform/heap/cortex/no_heap.c.in +++ b/src/modm/platform/heap/cortex/no_heap.c.in @@ -19,7 +19,7 @@ void __modm_initialize_memory(void) } // ---------------------------------------------------------------------------- -modm_weak modm_section("{{ no_heap_section }}") +modm_weak modm_used modm_section("{{ no_heap_section }}") void* _sbrk_r(struct _reent *r, ptrdiff_t size) { (void) r; diff --git a/tools/build_script_generator/cmake/resources/ci_CMakeLists.txt.in b/tools/build_script_generator/cmake/resources/ci_CMakeLists.txt.in index cf68aeea18..4d44b499cd 100644 --- a/tools/build_script_generator/cmake/resources/ci_CMakeLists.txt.in +++ b/tools/build_script_generator/cmake/resources/ci_CMakeLists.txt.in @@ -41,6 +41,11 @@ set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}-objdump) set(CMAKE_AR ${TOOLCHAIN_PREFIX}-gcc-ar) set(CMAKE_NM ${TOOLCHAIN_PREFIX}-gcc-nm) +SET(CMAKE_C_ARCHIVE_CREATE " qcs ") +SET(CMAKE_C_ARCHIVE_FINISH ":") +SET(CMAKE_CXX_ARCHIVE_CREATE " qcs ") +SET(CMAKE_CXX_ARCHIVE_FINISH ":") + project({{ project_name }} CXX C) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) From 1c931168e4314d46b82231629c3efec7dbdd3fda Mon Sep 17 00:00:00 2001 From: ser-plu <115997562+ser-plu@users.noreply.github.com> Date: Tue, 8 Nov 2022 20:32:38 +0100 Subject: [PATCH 2/5] function signature fix for heap_newlib.cpp Co-authored-by: Raphael Lehmann --- src/modm/platform/heap/cortex/heap_newlib.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modm/platform/heap/cortex/heap_newlib.cpp b/src/modm/platform/heap/cortex/heap_newlib.cpp index 1c906d59bf..83d1a506a9 100644 --- a/src/modm/platform/heap/cortex/heap_newlib.cpp +++ b/src/modm/platform/heap/cortex/heap_newlib.cpp @@ -40,7 +40,8 @@ void __modm_initialize_memory(void) * Note: This implementation is not thread safe (despite taking a * _reent structure as a parameter). */ -modm_used void * _sbrk_r(struct _reent *, ptrdiff_t size) +modm_used void * +_sbrk_r(struct _reent *, ptrdiff_t size) { const uint8_t *const heap = heap_top; heap_top += size; From a096405a689ced9daf408d4af4290c391cbf7a48 Mon Sep 17 00:00:00 2001 From: Sergey Pluzhnikov Date: Thu, 10 Nov 2022 13:50:34 +0100 Subject: [PATCH 3/5] 'used' attribute for vectorsRom --- src/modm/platform/core/cortex/vectors.c.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modm/platform/core/cortex/vectors.c.in b/src/modm/platform/core/cortex/vectors.c.in index 907b064e19..ec88024b1a 100644 --- a/src/modm/platform/core/cortex/vectors.c.in +++ b/src/modm/platform/core/cortex/vectors.c.in @@ -33,7 +33,7 @@ typedef void (* const FunctionPointer)(void); extern uint32_t __main_stack_top[]; // Define the vector table -modm_section(".vector_rom") +modm_section(".vector_rom") modm_used FunctionPointer vectorsRom[] = { (FunctionPointer)__main_stack_top, // -16: stack pointer From c5ea8eecb68c148afc676fce3c5f5f6674a7e6f6 Mon Sep 17 00:00:00 2001 From: Sergey Pluzhnikov Date: Thu, 10 Nov 2022 15:21:29 +0100 Subject: [PATCH 4/5] 'used' attribute for vectorsRam and Undefined_Handler --- src/modm/platform/core/cortex/vectors.c.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modm/platform/core/cortex/vectors.c.in b/src/modm/platform/core/cortex/vectors.c.in index ec88024b1a..81f6a75872 100644 --- a/src/modm/platform/core/cortex/vectors.c.in +++ b/src/modm/platform/core/cortex/vectors.c.in @@ -50,7 +50,7 @@ FunctionPointer vectorsRom[] = }; %% if vector_table_location == "ram" // reserve space for the remapped vector table in RAM -modm_section(".vector_ram") +modm_section(".vector_ram") modm_used FunctionPointer vectorsRam[sizeof(vectorsRom) / sizeof(FunctionPointer)]; %% endif @@ -65,7 +65,8 @@ FunctionPointer vectorsRam[sizeof(vectorsRom) / sizeof(FunctionPointer)]; #include %% endif -void Undefined_Handler(void) +modm_used void +Undefined_Handler(void) { %% if with_assert const int32_t irqn = ((int32_t)__get_IPSR()) - 16; From 0be5e0311d51a5b1ce7292edbe9caf0aae5ef954 Mon Sep 17 00:00:00 2001 From: Sergey Pluzhnikov Date: Thu, 10 Nov 2022 15:54:23 +0100 Subject: [PATCH 5/5] spaces fix --- src/modm/platform/core/cortex/vectors.c.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modm/platform/core/cortex/vectors.c.in b/src/modm/platform/core/cortex/vectors.c.in index 81f6a75872..c7002ec874 100644 --- a/src/modm/platform/core/cortex/vectors.c.in +++ b/src/modm/platform/core/cortex/vectors.c.in @@ -65,7 +65,7 @@ FunctionPointer vectorsRam[sizeof(vectorsRom) / sizeof(FunctionPointer)]; #include %% endif -modm_used void +modm_used void Undefined_Handler(void) { %% if with_assert