mirror of https://github.com/wolfSSL/wolfBoot.git
Added USE_CLANG option to Makefile
parent
19d562dbde
commit
4eca085b54
5
Makefile
5
Makefile
|
|
@ -25,7 +25,12 @@ LIBS=
|
|||
SIGN_ALG=
|
||||
OBJCOPY_FLAGS=
|
||||
BIG_ENDIAN?=0
|
||||
USE_CLANG?=0
|
||||
ifeq ($(USE_CLANG),1)
|
||||
USE_GCC?=0
|
||||
else
|
||||
USE_GCC?=1
|
||||
endif
|
||||
USE_GCC_HEADLESS?=1
|
||||
FLASH_OTP_KEYSTORE?=0
|
||||
BOOTLOADER_PARTITION_SIZE?=$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET)))
|
||||
|
|
|
|||
25
arch.mk
25
arch.mk
|
|
@ -137,8 +137,10 @@ ifeq ($(ARCH),ARM)
|
|||
CFLAGS+=-mthumb -mlittle-endian
|
||||
LDFLAGS+=-mthumb -mlittle-endian
|
||||
ifeq ($(USE_GCC),1)
|
||||
ifeq ($(findstring clang,$(notdir $(CC))),)
|
||||
CFLAGS+=-mthumb-interwork
|
||||
LDFLAGS+=-mthumb-interwork
|
||||
endif
|
||||
endif
|
||||
|
||||
## Target specific configuration
|
||||
|
|
@ -1220,6 +1222,29 @@ ifeq ($(TARGET),psoc6)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(USE_CLANG),1)
|
||||
ifneq ($(ARCH),ARM)
|
||||
$(error USE_CLANG=1 is currently supported only for ARCH=ARM)
|
||||
endif
|
||||
CLANG?=clang
|
||||
CLANG_GCC_NAME?=$(CROSS_COMPILE)gcc
|
||||
CLANG_TARGET?=arm-none-eabi
|
||||
CLANG_DRIVER:=$(CLANG) --target=$(CLANG_TARGET) -ccc-gcc-name $(CLANG_GCC_NAME)
|
||||
CLANG_LIBC_A?=$(shell $(CLANG_GCC_NAME) -print-file-name=libc.a)
|
||||
CLANG_NEWLIB_INCLUDE?=$(abspath $(dir $(CLANG_LIBC_A))/../include)
|
||||
|
||||
CC=$(CLANG_DRIVER)
|
||||
LD=$(CLANG_DRIVER)
|
||||
AS=$(CLANG_DRIVER)
|
||||
AR=$(CROSS_COMPILE)ar
|
||||
OBJCOPY?=$(CROSS_COMPILE)objcopy
|
||||
SIZE=$(CROSS_COMPILE)size
|
||||
|
||||
CFLAGS+=-isystem $(CLANG_NEWLIB_INCLUDE)
|
||||
CFLAGS+=-DWOLFSSL_NO_ATOMIC -DWOLFSSL_NO_ATOMICS
|
||||
LDFLAGS+=-nostdlib
|
||||
endif
|
||||
|
||||
ifeq ($(USE_GCC),1)
|
||||
## Toolchain setup
|
||||
CC=$(CROSS_COMPILE)gcc
|
||||
|
|
|
|||
|
|
@ -46,10 +46,16 @@ extern "C" {
|
|||
#ifndef RAMFUNCTION
|
||||
# if defined(__WOLFBOOT) && defined(RAM_CODE)
|
||||
# if defined(ARCH_ARM)
|
||||
# if defined(__clang__)
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode")))
|
||||
# else
|
||||
# if defined(__has_attribute)
|
||||
# if __has_attribute(long_call)
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
|
||||
# else
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode")))
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
|
||||
# else
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode")))
|
||||
# endif
|
||||
# elif defined(ARCH_PPC)
|
||||
# define RAMFUNCTION __attribute__((used,section(".ramcode"),longcall))
|
||||
|
|
|
|||
23
options.mk
23
options.mk
|
|
@ -1,8 +1,19 @@
|
|||
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/asn.o
|
||||
USE_GCC?=1
|
||||
USE_CLANG?=0
|
||||
ifeq ($(USE_CLANG),1)
|
||||
USE_GCC?=0
|
||||
else
|
||||
USE_GCC?=1
|
||||
endif
|
||||
WOLFBOOT_TEST_FILLER?=0
|
||||
WOLFBOOT_TIME_TEST?=0
|
||||
|
||||
ifeq ($(USE_CLANG),1)
|
||||
ifeq ($(USE_GCC),1)
|
||||
$(error USE_CLANG=1 is incompatible with USE_GCC=1; set USE_GCC=0)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Support for Built-in ROT into OTP flash memory
|
||||
ifeq ($(FLASH_OTP_KEYSTORE),1)
|
||||
CFLAGS+=-D"FLASH_OTP_KEYSTORE"
|
||||
|
|
@ -722,7 +733,9 @@ ifeq ($(DEBUG_SYMBOLS),1)
|
|||
ifeq ($(USE_GCC),1)
|
||||
CFLAGS+=-ggdb3
|
||||
else ifneq ($(ARCH),AURIX_TC3)
|
||||
ifneq ($(USE_CLANG),1)
|
||||
CFLAGS+=-gstabs
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
@ -1031,9 +1044,11 @@ OBJS+=$(OBJS_EXTRA)
|
|||
|
||||
ifeq ($(USE_GCC_HEADLESS),1)
|
||||
ifeq ($(USE_GCC),1)
|
||||
ifneq ($(ARCH),RENESAS_RX)
|
||||
ifneq ($(ARCH),AURIX_TC3)
|
||||
CFLAGS+="-Wstack-usage=$(STACK_USAGE)"
|
||||
ifneq ($(USE_CLANG),1)
|
||||
ifneq ($(ARCH),RENESAS_RX)
|
||||
ifneq ($(ARCH),AURIX_TC3)
|
||||
CFLAGS+="-Wstack-usage=$(STACK_USAGE)"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -757,6 +757,8 @@ out:
|
|||
# if defined(__GNUC__) && !defined(__clang__)
|
||||
# pragma GCC push_options
|
||||
# pragma GCC optimize("O0")
|
||||
# elif defined(__clang__)
|
||||
# pragma clang optimize off
|
||||
# elif defined(__IAR_SYSTEMS_ICC__)
|
||||
# pragma optimize=none
|
||||
# endif
|
||||
|
|
@ -1476,6 +1478,8 @@ void RAMFUNCTION wolfBoot_start(void)
|
|||
#ifdef WOLFBOOT_ARMORED
|
||||
# if defined(__GNUC__) && !defined(__clang__)
|
||||
# pragma GCC pop_options
|
||||
# elif defined(__clang__)
|
||||
# pragma clang optimize on
|
||||
# elif defined(__IAR_SYSTEMS_ICC__)
|
||||
# pragma optimize=default
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -22,7 +22,12 @@ endif
|
|||
CFLAGS+=-I. -I..
|
||||
DEBUG?=1
|
||||
DELTA_DATA_SIZE?=2000
|
||||
USE_GCC?=1
|
||||
USE_CLANG?=0
|
||||
ifeq ($(USE_CLANG),1)
|
||||
USE_GCC?=0
|
||||
else
|
||||
USE_GCC?=1
|
||||
endif
|
||||
USE_GCC_HEADLESS?=1
|
||||
BOOTLOADER_PARTITION_SIZE?=$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET)))
|
||||
|
||||
|
|
@ -57,14 +62,18 @@ else
|
|||
CFLAGS+=-Wall -ffreestanding -Wno-unused
|
||||
# Stack usage computation not supported on TriCore
|
||||
ifneq ($(ARCH),AURIX_TC3)
|
||||
CFLAGS+=-Wstack-usage=1024 -nostartfiles
|
||||
ifneq ($(USE_CLANG),1)
|
||||
CFLAGS+=-Wstack-usage=1024
|
||||
endif
|
||||
endif
|
||||
CFLAGS+=-DTARGET_$(TARGET) -I../include
|
||||
CFLAGS+=-g
|
||||
ifeq ($(USE_GCC),1)
|
||||
CFLAGS+=-ggdb3
|
||||
else ifneq ($(ARCH),AURIX_TC3)
|
||||
CFLAGS+=-gstabs
|
||||
ifneq ($(USE_CLANG),1)
|
||||
CFLAGS+=-gstabs
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),RENESAS_RX)
|
||||
|
|
@ -78,6 +87,10 @@ endif
|
|||
|
||||
include ../arch.mk
|
||||
|
||||
ifeq ($(USE_CLANG),1)
|
||||
APP_OBJS+=../src/string.o
|
||||
endif
|
||||
|
||||
# Optional alias for clearer TZ PSA selection in app builds.
|
||||
ifeq ($(WOLFCRYPT_TZ_PSA),1)
|
||||
WOLFCRYPT_TZ=1
|
||||
|
|
@ -85,7 +98,7 @@ ifeq ($(WOLFCRYPT_TZ_PSA),1)
|
|||
endif
|
||||
|
||||
# Setup default linker flags
|
||||
LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map
|
||||
LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -nostartfiles
|
||||
|
||||
# Setup default objcopy flags
|
||||
OBJCOPY_FLAGS+=--gap-fill $(FILL_BYTE)
|
||||
|
|
|
|||
Loading…
Reference in New Issue