Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -180,7 +185,7 @@ CFLAGS+=$(WOLFPSA_CFLAGS)

# Setup default optimizations (for GCC)
ifeq ($(USE_GCC_HEADLESS),1)
CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding -nostartfiles
CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding
CFLAGS+=-ffunction-sections -fdata-sections -fomit-frame-pointer
# Allow unused parameters and functions
CFLAGS+=-Wno-unused-parameter -Wno-unused-function
Expand Down
33 changes: 31 additions & 2 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ endif
ifeq ($(ARCH),ARM)
CROSS_COMPILE?=arm-none-eabi-
CFLAGS+=-DARCH_ARM
CFLAGS+=-mthumb -mlittle-endian -mthumb-interwork
LDFLAGS+=-mthumb -mlittle-endian -mthumb-interwork
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
ifeq ($(TARGET),samr21)
Expand Down Expand Up @@ -1216,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
Expand Down
12 changes: 11 additions & 1 deletion include/wolfboot/wolfboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ extern "C" {
#ifndef RAMFUNCTION
# if defined(__WOLFBOOT) && defined(RAM_CODE)
# if defined(ARCH_ARM)
# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
# 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))
# else
Expand Down
25 changes: 21 additions & 4 deletions options.mk
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1030,9 +1043,13 @@ CFLAGS+=$(CFLAGS_EXTRA)
OBJS+=$(OBJS_EXTRA)

ifeq ($(USE_GCC_HEADLESS),1)
ifneq ($(ARCH),RENESAS_RX)
ifneq ($(ARCH),AURIX_TC3)
CFLAGS+="-Wstack-usage=$(STACK_USAGE)"
ifeq ($(USE_GCC),1)
ifneq ($(USE_CLANG),1)
ifneq ($(ARCH),RENESAS_RX)
ifneq ($(ARCH),AURIX_TC3)
CFLAGS+="-Wstack-usage=$(STACK_USAGE)"
endif
endif
endif
endif
endif
Expand Down
8 changes: 6 additions & 2 deletions src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,11 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,


#ifdef WOLFBOOT_ARMORED
# ifdef __GNUC__
# 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
Expand Down Expand Up @@ -1474,8 +1476,10 @@ void RAMFUNCTION wolfBoot_start(void)
}

#ifdef WOLFBOOT_ARMORED
# ifdef __GNUC__
# 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
Expand Down
21 changes: 17 additions & 4 deletions test-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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)
Expand All @@ -78,14 +87,18 @@ 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
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)
Expand Down
Loading