File tree Expand file tree Collapse file tree 6 files changed +92
-14
lines changed
Expand file tree Collapse file tree 6 files changed +92
-14
lines changed Original file line number Diff line number Diff line change 2525SIGN_ALG =
2626OBJCOPY_FLAGS =
2727BIG_ENDIAN? =0
28+ USE_CLANG? =0
29+ ifeq ($(USE_CLANG ) ,1)
30+ USE_GCC? =0
31+ else
2832USE_GCC? =1
33+ endif
2934USE_GCC_HEADLESS? =1
3035FLASH_OTP_KEYSTORE? =0
3136BOOTLOADER_PARTITION_SIZE? =$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS ) - $(ARCH_FLASH_OFFSET ) ) )
@@ -180,7 +185,7 @@ CFLAGS+=$(WOLFPSA_CFLAGS)
180185
181186# Setup default optimizations (for GCC)
182187ifeq ($(USE_GCC_HEADLESS ) ,1)
183- CFLAGS+ =-Wall -Wextra -Wno-main -ffreestanding -nostartfiles
188+ CFLAGS+ =-Wall -Wextra -Wno-main -ffreestanding
184189 CFLAGS+ =-ffunction-sections -fdata-sections -fomit-frame-pointer
185190 # Allow unused parameters and functions
186191 CFLAGS+ =-Wno-unused-parameter -Wno-unused-function
Original file line number Diff line number Diff line change @@ -134,8 +134,14 @@ endif
134134ifeq ($(ARCH ) ,ARM)
135135 CROSS_COMPILE? =arm-none-eabi-
136136 CFLAGS+ =-DARCH_ARM
137- CFLAGS+ =-mthumb -mlittle-endian -mthumb-interwork
138- LDFLAGS+ =-mthumb -mlittle-endian -mthumb-interwork
137+ CFLAGS+ =-mthumb -mlittle-endian
138+ LDFLAGS+ =-mthumb -mlittle-endian
139+ ifeq ($(USE_GCC),1)
140+ ifeq ($(findstring clang,$(notdir $(CC))),)
141+ CFLAGS+ =-mthumb-interwork
142+ LDFLAGS+ =-mthumb-interwork
143+ endif
144+ endif
139145
140146 # # Target specific configuration
141147 ifeq ($(TARGET),samr21)
@@ -1216,6 +1222,29 @@ ifeq ($(TARGET),psoc6)
12161222 endif
12171223endif
12181224
1225+ ifeq ($(USE_CLANG ) ,1)
1226+ ifneq ($(ARCH),ARM)
1227+ $(error USE_CLANG=1 is currently supported only for ARCH=ARM)
1228+ endif
1229+ CLANG? =clang
1230+ CLANG_GCC_NAME? =$(CROSS_COMPILE ) gcc
1231+ CLANG_TARGET? =arm-none-eabi
1232+ CLANG_DRIVER: =$(CLANG ) --target=$(CLANG_TARGET ) -ccc-gcc-name $(CLANG_GCC_NAME )
1233+ CLANG_LIBC_A? =$(shell $(CLANG_GCC_NAME ) -print-file-name=libc.a)
1234+ CLANG_NEWLIB_INCLUDE? =$(abspath $(dir $(CLANG_LIBC_A ) ) /../include)
1235+
1236+ CC =$(CLANG_DRIVER )
1237+ LD =$(CLANG_DRIVER )
1238+ AS =$(CLANG_DRIVER )
1239+ AR =$(CROSS_COMPILE ) ar
1240+ OBJCOPY? =$(CROSS_COMPILE ) objcopy
1241+ SIZE =$(CROSS_COMPILE ) size
1242+
1243+ CFLAGS+ =-isystem $(CLANG_NEWLIB_INCLUDE )
1244+ CFLAGS+ =-DWOLFSSL_NO_ATOMIC -DWOLFSSL_NO_ATOMICS
1245+ LDFLAGS+ =-nostdlib
1246+ endif
1247+
12191248ifeq ($(USE_GCC ) ,1)
12201249 # # Toolchain setup
12211250 CC =$(CROSS_COMPILE ) gcc
Original file line number Diff line number Diff line change @@ -46,7 +46,17 @@ extern "C" {
4646#ifndef RAMFUNCTION
4747# if defined(__WOLFBOOT ) && defined(RAM_CODE )
4848# if defined(ARCH_ARM )
49- # define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
49+ # if defined(__has_attribute )
50+ # if __has_attribute (long_call )
51+ # define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
52+ # else
53+ # define RAMFUNCTION __attribute__((used,section(".ramcode")))
54+ # endif
55+ # elif defined(__GNUC__ )
56+ # define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
57+ # else
58+ # define RAMFUNCTION __attribute__((used,section(".ramcode")))
59+ # endif
5060# elif defined(ARCH_PPC )
5161# define RAMFUNCTION __attribute__((used,section(".ramcode"),longcall))
5262# else
Original file line number Diff line number Diff line change 11WOLFCRYPT_OBJS+ =$(WOLFBOOT_LIB_WOLFSSL ) /wolfcrypt/src/asn.o
2- USE_GCC? =1
2+ USE_CLANG? =0
3+ ifeq ($(USE_CLANG ) ,1)
4+ USE_GCC? =0
5+ else
6+ USE_GCC? =1
7+ endif
38WOLFBOOT_TEST_FILLER? =0
49WOLFBOOT_TIME_TEST? =0
510
11+ ifeq ($(USE_CLANG ) ,1)
12+ ifeq ($(USE_GCC),1)
13+ $(error USE_CLANG=1 is incompatible with USE_GCC=1; set USE_GCC=0)
14+ endif
15+ endif
16+
617# Support for Built-in ROT into OTP flash memory
718ifeq ($(FLASH_OTP_KEYSTORE ) ,1)
819 CFLAGS+ =-D"FLASH_OTP_KEYSTORE"
@@ -722,7 +733,9 @@ ifeq ($(DEBUG_SYMBOLS),1)
722733 ifeq ($(USE_GCC),1)
723734 CFLAGS+ =-ggdb3
724735 else ifneq ($(ARCH),AURIX_TC3)
736+ ifneq ($(USE_CLANG),1)
725737 CFLAGS+ =-gstabs
738+ endif
726739 endif
727740endif
728741
@@ -1030,9 +1043,13 @@ CFLAGS+=$(CFLAGS_EXTRA)
10301043OBJS+ =$(OBJS_EXTRA )
10311044
10321045ifeq ($(USE_GCC_HEADLESS ) ,1)
1033- ifneq ($(ARCH),RENESAS_RX)
1034- ifneq ($(ARCH),AURIX_TC3)
1035- CFLAGS+="-Wstack-usage =$(STACK_USAGE ) "
1046+ ifeq ($(USE_GCC),1)
1047+ ifneq ($(USE_CLANG),1)
1048+ ifneq ($(ARCH),RENESAS_RX)
1049+ ifneq ($(ARCH),AURIX_TC3)
1050+ CFLAGS+="-Wstack-usage =$(STACK_USAGE ) "
1051+ endif
1052+ endif
10361053 endif
10371054 endif
10381055endif
Original file line number Diff line number Diff line change @@ -754,9 +754,11 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
754754
755755
756756#ifdef WOLFBOOT_ARMORED
757- # ifdef __GNUC__
757+ # if defined( __GNUC__ ) && !defined( __clang__ )
758758# pragma GCC push_options
759759# pragma GCC optimize("O0")
760+ # elif defined(__clang__ )
761+ # pragma clang optimize off
760762# elif defined(__IAR_SYSTEMS_ICC__ )
761763# pragma optimize=none
762764# endif
@@ -1474,8 +1476,10 @@ void RAMFUNCTION wolfBoot_start(void)
14741476}
14751477
14761478#ifdef WOLFBOOT_ARMORED
1477- # ifdef __GNUC__
1479+ # if defined( __GNUC__ ) && !defined( __clang__ )
14781480# pragma GCC pop_options
1481+ # elif defined(__clang__ )
1482+ # pragma clang optimize on
14791483# elif defined(__IAR_SYSTEMS_ICC__ )
14801484# pragma optimize=default
14811485# endif
Original file line number Diff line number Diff line change 2222CFLAGS+ =-I. -I..
2323DEBUG? =1
2424DELTA_DATA_SIZE? =2000
25- USE_GCC? =1
25+ USE_CLANG? =0
26+ ifeq ($(USE_CLANG ) ,1)
27+ USE_GCC? =0
28+ else
29+ USE_GCC? =1
30+ endif
2631USE_GCC_HEADLESS? =1
2732BOOTLOADER_PARTITION_SIZE? =$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS ) - $(ARCH_FLASH_OFFSET ) ) )
2833
5762 CFLAGS+ =-Wall -ffreestanding -Wno-unused
5863 # Stack usage computation not supported on TriCore
5964 ifneq ($(ARCH),AURIX_TC3)
60- CFLAGS+=-Wstack-usage =1024 -nostartfiles
65+ ifneq ($(USE_CLANG),1)
66+ CFLAGS+=-Wstack-usage =1024
67+ endif
6168 endif
6269 CFLAGS+ =-DTARGET_$(TARGET ) -I../include
6370 CFLAGS+ =-g
6471 ifeq ($(USE_GCC),1)
6572 CFLAGS+ =-ggdb3
6673 else ifneq ($(ARCH),AURIX_TC3)
67- CFLAGS+ =-gstabs
74+ ifneq ($(USE_CLANG),1)
75+ CFLAGS+ =-gstabs
76+ endif
6877 endif
6978
7079 ifeq ($(ARCH),RENESAS_RX)
@@ -78,14 +87,18 @@ endif
7887
7988include ../arch.mk
8089
90+ ifeq ($(USE_CLANG ) ,1)
91+ APP_OBJS+ =../src/string.o
92+ endif
93+
8194# Optional alias for clearer TZ PSA selection in app builds.
8295ifeq ($(WOLFCRYPT_TZ_PSA ) ,1)
8396 WOLFCRYPT_TZ =1
8497 WOLFCRYPT_TZ_PSA =1
8598endif
8699
87100# Setup default linker flags
88- LDFLAGS+ =-T $(LSCRIPT ) -Wl,-gc-sections -Wl,-Map=image.map
101+ LDFLAGS+ =-T $(LSCRIPT ) -Wl,-gc-sections -Wl,-Map=image.map -nostartfiles
89102
90103# Setup default objcopy flags
91104OBJCOPY_FLAGS+ =--gap-fill $(FILL_BYTE )
You can’t perform that action at this time.
0 commit comments