Skip to content

Compilation warning/error on stm32l4: "__weak" redefined #8563

@cpriouzeau

Description

@cpriouzeau

After the introduction of patch aee97be : "arch: arm: soc: remove core zephyr header inclusions from soc.h", some error appear at compilation time:

In file included from /home/buildslave/src/github.com/zephyrproject-rtos/zephyr/include/toolchain.h:21:0,
from /home/buildslave/src/github.com/zephyrproject-rtos/zephyr/include/kernel_includes.h:19,
from /home/buildslave/src/github.com/zephyrproject-rtos/zephyr/arch/arm/soc/st_stm32/stm32l4/soc.h:26,
from /home/buildslave/src/github.com/zephyrproject-rtos/zephyr/arch/arm/soc/st_stm32/common/arm_mpu_regions.c:7:
/home/buildslave/src/github.com/zephyrproject-rtos/zephyr/include/toolchain/gcc.h:145:0: error: "__weak" redefined [-Werror]
#define __weak attribute((weak))

To solve it, on stm32l4 and stm32f4 we need to move the call of "include <kernel_includes.h>" before machine specific call "include <stm32l4xx.h>" or "include <stm32f4xx.h>"

Proposal to correct it with stm32l4 and smt32f4:

diff --git a/arch/arm/soc/st_stm32/stm32f4/soc.h b/arch/arm/soc/st_stm32/stm32f4/soc.h
index 044701f..8e462bf 100644
--- a/arch/arm/soc/st_stm32/stm32f4/soc.h
+++ b/arch/arm/soc/st_stm32/stm32f4/soc.h
@@ -24,9 +24,8 @@
 
 #ifndef _ASMLANGUAGE
 
-#include <stm32f4xx.h>
-
 #include <kernel_includes.h>
+#include <stm32f4xx.h>
 
 #ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
 #include <stm32f4xx_ll_utils.h>
diff --git a/arch/arm/soc/st_stm32/stm32l4/soc.h b/arch/arm/soc/st_stm32/stm32l4/soc.h
index fafe672..025c370 100644
--- a/arch/arm/soc/st_stm32/stm32l4/soc.h
+++ b/arch/arm/soc/st_stm32/stm32l4/soc.h
@@ -22,8 +22,8 @@
 #ifndef _ASMLANGUAGE
 
 #include <autoconf.h>
-#include <stm32l4xx.h>
 #include <kernel_includes.h>
+#include <stm32l4xx.h>
 
 #define GPIO_REG_SIZE         0x400
 /* base address for where GPIO registers start */

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions