Skip to content

Commit eab42d9

Browse files
committed
update clang make build for stm32: f0 f1 f2 f3 f4 f7 h7 g0 g4 l0 l4 samd21 samd51 nrf
1 parent a7bf0e3 commit eab42d9

File tree

20 files changed

+95
-52
lines changed

20 files changed

+95
-52
lines changed

examples/build_system/make/toolchain/gcc_rules.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CFLAGS := $(filter-out $(CFLAGS_SKIP),$(CFLAGS))
2222
endif
2323

2424
ifeq ($(TOOLCHAIN),clang)
25+
CFLAGS += $(CFLAGS_CLANG)
2526
LDFLAGS += $(CFLAGS) $(LDFLAGS_CLANG)
2627
else
2728
LDFLAGS += $(CFLAGS) $(LDFLAGS_GCC)

hw/bsp/nrf/family.mk

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,40 @@ include $(TOP)/$(BOARD_PATH)/board.mk
88
CPU_CORE ?= cortex-m4
99

1010
CFLAGS += \
11-
-flto \
1211
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
13-
-DCONFIG_GPIO_AS_PINRESET
12+
-DCONFIG_GPIO_AS_PINRESET \
13+
-D__STARTUP_CLEAR_BSS
1414

1515
#CFLAGS += -nostdlib
1616
#CFLAGS += -D__START=main
1717

1818
# suppress warning caused by vendor mcu driver
19-
CFLAGS += \
19+
CFLAGS_GCC += \
20+
-flto \
2021
-Wno-error=undef \
2122
-Wno-error=unused-parameter \
23+
-Wno-error=unused-variable \
2224
-Wno-error=cast-align \
2325
-Wno-error=cast-qual \
24-
-Wno-error=redundant-decls
26+
-Wno-error=redundant-decls \
2527

26-
LDFLAGS += \
27-
-specs=nosys.specs -specs=nano.specs \
28+
LDFLAGS_GCC += \
29+
-nostartfiles \
30+
--specs=nosys.specs --specs=nano.specs \
2831
-L$(TOP)/${NRFX_DIR}/mdk
2932

33+
LDFLAGS_CLANG += \
34+
-L$(TOP)/${NRFX_DIR}/mdk \
35+
3036
SRC_C += \
3137
src/portable/nordic/nrf5x/dcd_nrf5x.c \
3238
${NRFX_DIR}/helpers/nrfx_flag32_allocator.c \
3339
${NRFX_DIR}/drivers/src/nrfx_gpiote.c \
3440
${NRFX_DIR}/drivers/src/nrfx_power.c \
3541
${NRFX_DIR}/drivers/src/nrfx_spim.c \
3642
${NRFX_DIR}/drivers/src/nrfx_uarte.c \
37-
${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c
43+
${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c \
44+
${NRFX_DIR}/soc/nrfx_atomic.c
3845

3946
INC += \
4047
$(TOP)/$(BOARD_PATH) \

hw/bsp/samd21/family.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CFLAGS_SKIP += -Wcast-qual
1717

1818
LDFLAGS_GCC += \
1919
-nostdlib -nostartfiles \
20-
-specs=nosys.specs -specs=nano.specs \
20+
--specs=nosys.specs --specs=nano.specs \
2121

2222
LDFLAGS_CLANG +=
2323

hw/bsp/samd51/family.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ CPU_CORE ?= cortex-m4
66

77
CFLAGS += \
88
-flto \
9-
-nostdlib -nostartfiles \
109
-DCFG_TUSB_MCU=OPT_MCU_SAMD51
1110

1211
# SAM driver is flooded with -Wcast-qual which slow down complication significantly
1312
CFLAGS_SKIP += -Wcast-qual
1413

15-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
14+
LDFLAGS_GCC += \
15+
-nostdlib -nostartfiles \
16+
--specs=nosys.specs --specs=nano.specs
1617

1718
SRC_C += \
1819
src/portable/microchip/samd/dcd_samd.c \
@@ -33,7 +34,7 @@ INC += \
3334
$(TOP)/hw/mcu/microchip/samd51/hal/utils/include \
3435
$(TOP)/hw/mcu/microchip/samd51/hpl/port \
3536
$(TOP)/hw/mcu/microchip/samd51/hri \
36-
$(TOP)/hw/mcu/microchip/samd51/CMSIS/Include
37+
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
3738

3839
# flash using bossac at least version 1.8
3940
# can be found in arduino15/packages/arduino/tools/bossac/

hw/bsp/stm32f0/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ CFLAGS += \
1818
# GCC Flags
1919
CFLAGS_GCC += \
2020
-flto \
21-
-nostdlib -nostartfiles \
2221

2322
# suppress warning caused by vendor mcu driver
2423
CFLAGS_GCC += -Wno-error=unused-parameter -Wno-error=cast-align
2524

26-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
25+
LDFLAGS_GCC += \
26+
-nostdlib -nostartfiles \
27+
--specs=nosys.specs --specs=nano.specs
2728

2829
# ------------------------
2930
# All source paths should be relative to the top level.

hw/bsp/stm32f1/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ CFLAGS += \
1616
# GCC Flags
1717
CFLAGS_GCC += \
1818
-flto \
19-
-nostdlib -nostartfiles \
2019

2120
# mcu driver cause following warnings
2221
CFLAGS_GCC += -Wno-error=cast-align
2322

24-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
23+
LDFLAGS_GCC += \
24+
-nostdlib -nostartfiles \
25+
-specs=nosys.specs -specs=nano.specs
2526

2627
# ------------------------
2728
# All source paths should be relative to the top level.

hw/bsp/stm32f2/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ CFLAGS += \
1616

1717
CFLAGS_GCC += \
1818
-flto \
19-
-nostdlib -nostartfiles \
2019

2120
# mcu driver cause following warnings
2221
CFLAGS_GCC += -Wno-error=sign-compare
2322

24-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
23+
LDFLAGS_GCC += \
24+
-nostdlib -nostartfiles \
25+
--specs=nosys.specs --specs=nano.specs
2526

2627
SRC_C += \
2728
src/portable/synopsys/dwc2/dcd_dwc2.c \

hw/bsp/stm32f3/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ CPU_CORE ?= cortex-m4
1313

1414
CFLAGS += \
1515
-flto \
16-
-nostdlib -nostartfiles \
1716
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
1817

1918
# mcu driver cause following warnings
2019
CFLAGS += -Wno-error=unused-parameter
2120

22-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
21+
LDFLAGS_GCC += \
22+
-nostdlib -nostartfiles \
23+
--specs=nosys.specs --specs=nano.specs
2324

2425
SRC_C += \
2526
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \

hw/bsp/stm32f4/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ CFLAGS += \
2020
# GCC Flags
2121
CFLAGS_GCC += \
2222
-flto \
23-
-nostdlib -nostartfiles
2423

2524
# suppress warning caused by vendor mcu driver
2625
CFLAGS_GCC += -Wno-error=cast-align
2726

28-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
27+
LDFLAGS_GCC += \
28+
-nostdlib -nostartfiles \
29+
--specs=nosys.specs --specs=nano.specs
2930

3031
# -----------------
3132
# Sources & Include

hw/bsp/stm32f7/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ endif
3030
# GCC Flags
3131
CFLAGS_GCC += \
3232
-flto \
33-
-nostdlib -nostartfiles
3433

3534
# mcu driver cause following warnings
3635
CFLAGS_GCC += -Wno-error=cast-align
3736

38-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
37+
LDFLAGS_GCC += \
38+
-nostdlib -nostartfiles \
39+
--specs=nosys.specs --specs=nano.specs
3940

4041
# -----------------
4142
# Sources & Include

hw/bsp/stm32g0/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ CFLAGS += \
1616
# GCC Flags
1717
CFLAGS_GCC += \
1818
-flto \
19-
-nostdlib -nostartfiles
2019

2120
# suppress warning caused by vendor mcu driver
2221
CFLAGS_GCC += -Wno-error=cast-align
2322

24-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
23+
LDFLAGS_GCC += \
24+
-nostdlib -nostartfiles \
25+
--specs=nosys.specs --specs=nano.specs
2526

2627
# -----------------
2728
# Sources & Include

hw/bsp/stm32g4/family.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ CFLAGS += \
1515
# GCC Flags
1616
CFLAGS_GCC += \
1717
-flto \
18-
-nostdlib -nostartfiles \
1918

2019
# suppress warning caused by vendor mcu driver
2120
CFLAGS_GCC += -Wno-error=cast-align
2221

23-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
22+
LDFLAGS_GCC += \
23+
-nostdlib -nostartfiles \
24+
--specs=nosys.specs --specs=nano.specs
2425

2526
# -----------------
2627
# Sources & Include

hw/bsp/stm32h5/family.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ CFLAGS += \
1616
# GCC Flags
1717
CFLAGS_GCC += \
1818
-flto \
19-
-nostdlib -nostartfiles \
2019

2120
# suppress warning caused by vendor mcu driver
2221
CFLAGS_GCC += \
2322
-Wno-error=cast-align \
2423
-Wno-error=undef \
2524
-Wno-error=unused-parameter \
2625

27-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
26+
CFLAGS_CLANG += \
27+
-Wno-error=parentheses-equality
28+
29+
LDFLAGS_GCC += \
30+
-nostdlib -nostartfiles \
31+
--specs=nosys.specs --specs=nano.specs
2832

2933
# -----------------
3034
# Sources & Include
@@ -56,7 +60,7 @@ SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_$(MCU_VARIANT).s
5660

5761
# Linker
5862
LD_FILE_IAR = $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
59-
LD_FILE_GCC = $(ST_CMSIS)/Source/Templates/gcc/linker/$(MCU_VARIANT_UPPER)_FLASH.ld
63+
LD_FILE_GCC = $(FAMILY_PATH)/linker/$(MCU_VARIANT_UPPER)_FLASH.ld
6064

6165
# flash target using on-board stlink
6266
flash: flash-stlink

hw/bsp/stm32h7/family.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ endif
3030
# GCC Flags
3131
CFLAGS_GCC += \
3232
-flto \
33-
-nostdlib -nostartfiles
3433

3534
# suppress warning caused by vendor mcu driver
36-
CFLAGS_GCC += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=unused-parameter
35+
CFLAGS_GCC += \
36+
-Wno-error=cast-align \
37+
-Wno-error=unused-parameter \
3738

38-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
39+
LDFLAGS_GCC += \
40+
-nostdlib -nostartfiles \
41+
--specs=nosys.specs --specs=nano.specs
3942

4043
# -----------------
4144
# Sources & Include

hw/bsp/stm32l0/family.mk

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,26 @@ CPU_CORE ?= cortex-m0plus
1212

1313
CFLAGS += \
1414
-flto \
15-
-nostdlib -nostartfiles \
1615
-DCFG_EXAMPLE_MSC_READONLY \
1716
-DCFG_EXAMPLE_VIDEO_READONLY \
1817
-DCFG_TUSB_MCU=OPT_MCU_STM32L0
1918

2019
# mcu driver cause following warnings
21-
CFLAGS += \
20+
CFLAGS_GCC += \
2221
-Wno-error=unused-parameter \
2322
-Wno-error=redundant-decls \
2423
-Wno-error=cast-align \
25-
-Wno-error=maybe-uninitialized
2624

27-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
25+
ifeq ($(TOOLCHAIN),gcc)
26+
CFLAGS_GCC += -Wno-error=maybe-uninitialized
27+
endif
28+
29+
CFLAGS_CLANG += \
30+
-Wno-error=parentheses-equality
31+
32+
LDFLAGS_GCC += \
33+
-nostdlib -nostartfiles \
34+
--specs=nosys.specs --specs=nano.specs
2835

2936
SRC_C += \
3037
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \

hw/bsp/stm32l4/family.mk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ CFLAGS += \
1616
# GCC Flags
1717
CFLAGS_GCC += \
1818
-flto \
19-
-nostdlib -nostartfiles
19+
-Wno-error=cast-align \
2020

21-
# suppress warning caused by vendor mcu driver
22-
CFLAGS_GCC += -Wno-error=maybe-uninitialized -Wno-error=cast-align
21+
ifeq ($(TOOLCHAIN),gcc)
22+
CFLAGS_GCC += -Wno-error=maybe-uninitialized
23+
endif
2324

24-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
25+
LDFLAGS_GCC += \
26+
-nostdlib -nostartfiles \
27+
--specs=nosys.specs --specs=nano.specs
2528

2629
# -----------------
2730
# Sources & Include

hw/bsp/stm32u5/boards/stm32u575eval/board.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CFLAGS += \
22
-DSTM32U575xx \
33

44
# All source paths should be relative to the top level.
5-
LD_FILE = ${ST_CMSIS}/Source/Templates/gcc/linker/STM32U575xx_FLASH.ld
5+
LD_FILE = ${FAMILY_PATH}/linker/STM32U575xx_FLASH.ld
66

77
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32u575xx.s
88

hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CFLAGS += \
22
-DSTM32U575xx \
33

44
# All source paths should be relative to the top level.
5-
LD_FILE = ${ST_CMSIS}/Source/Templates/gcc/linker/STM32U575xx_FLASH.ld
5+
LD_FILE = ${FAMILY_PATH}/linker/STM32U575xx_FLASH.ld
66

77
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32u575xx.s
88

hw/bsp/stm32u5/family.mk

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ include $(TOP)/$(BOARD_PATH)/board.mk
88
CPU_CORE ?= cortex-m33
99

1010
CFLAGS += \
11-
-flto \
12-
-nostdlib -nostartfiles \
1311
-DCFG_TUSB_MCU=OPT_MCU_STM32U5
1412

1513
# suppress warning caused by vendor mcu driver
16-
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=undef -Wno-error=unused-parameter
14+
CFLAGS_GCC += \
15+
-flto \
16+
-Wno-error=cast-align \
17+
-Wno-error=undef \
18+
-Wno-error=unused-parameter \
19+
-Wno-error=type-limits \
1720

18-
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
21+
ifeq ($(TOOLCHAIN),gcc)
22+
CFLAGS_GCC += -Wno-error=maybe-uninitialized
23+
endif
24+
25+
LDFLAGS_GCC += \
26+
-nostdlib -nostartfiles \
27+
--specs=nosys.specs --specs=nano.specs
1928

2029
SRC_C += \
2130
src/portable/synopsys/dwc2/dcd_dwc2.c \

tools/build_make.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
build_separator = '-' * 106
1313

14-
make_iar_option = 'TOOLCHAIN=iar'
1514

1615
def filter_with_input(mylist):
1716
if len(sys.argv) > 1:
@@ -36,9 +35,10 @@ def build_family(example, family, make_option):
3635

3736

3837
if __name__ == '__main__':
39-
# IAR CC
40-
if make_iar_option not in sys.argv:
41-
make_iar_option = ''
38+
make_option = ''
39+
for a in sys.argv:
40+
if 'TOOLCHAIN=' in sys.argv:
41+
make_option += ' ' + a
4242

4343
# If examples are not specified in arguments, build all
4444
all_examples = []
@@ -67,7 +67,7 @@ def build_family(example, family, make_option):
6767
for example in all_examples:
6868
print(build_separator)
6969
for family in all_families:
70-
fret = build_family(example, family, make_iar_option)
70+
fret = build_family(example, family, make_option)
7171
if len(fret) == len(total_result):
7272
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
7373

0 commit comments

Comments
 (0)