mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Merge pull request #123 from bricky149/clang-build
Add support for clang builds
This commit is contained in:
commit
0cf4e1fe36
49
Makefile
49
Makefile
@ -3,6 +3,7 @@
|
|||||||
# 0 = disable
|
# 0 = disable
|
||||||
# 1 = enable
|
# 1 = enable
|
||||||
#
|
#
|
||||||
|
ENABLE_CLANG := 0
|
||||||
ENABLE_SWD := 0
|
ENABLE_SWD := 0
|
||||||
ENABLE_OVERLAY := 0
|
ENABLE_OVERLAY := 0
|
||||||
ENABLE_LTO := 1
|
ENABLE_LTO := 1
|
||||||
@ -39,7 +40,12 @@ ENABLE_COPY_CHAN_TO_VFO := 1
|
|||||||
|
|
||||||
TARGET = firmware
|
TARGET = firmware
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO), 1)
|
ifeq ($(ENABLE_CLANG),1)
|
||||||
|
# GCC's linker, ld, doesn't understand LLVM's generated bytecode
|
||||||
|
ENABLE_LTO := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_LTO),1)
|
||||||
# can't have LTO and OVERLAY enabled at same time
|
# can't have LTO and OVERLAY enabled at same time
|
||||||
ENABLE_OVERLAY := 0
|
ENABLE_OVERLAY := 0
|
||||||
endif
|
endif
|
||||||
@ -144,8 +150,20 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
AS = arm-none-eabi-gcc
|
AS = arm-none-eabi-gcc
|
||||||
CC = arm-none-eabi-gcc
|
|
||||||
|
CC =
|
||||||
LD = arm-none-eabi-gcc
|
LD = arm-none-eabi-gcc
|
||||||
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
|
CC += arm-none-eabi-gcc
|
||||||
|
# Use GCC's linker to avoid undefined symbol errors
|
||||||
|
# LD += arm-none-eabi-gcc
|
||||||
|
else
|
||||||
|
# May need to adjust this to match your system
|
||||||
|
CC += clang --sysroot=/usr/arm-none-eabi --target=arm-none-eabi
|
||||||
|
# Bloats binaries to 512MB
|
||||||
|
# LD = ld.lld
|
||||||
|
endif
|
||||||
|
|
||||||
OBJCOPY = arm-none-eabi-objcopy
|
OBJCOPY = arm-none-eabi-objcopy
|
||||||
SIZE = arm-none-eabi-size
|
SIZE = arm-none-eabi-size
|
||||||
|
|
||||||
@ -161,13 +179,18 @@ ifeq ($(ENABLE_OVERLAY),1)
|
|||||||
ASFLAGS += -DENABLE_OVERLAY
|
ASFLAGS += -DENABLE_OVERLAY
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
CFLAGS =
|
||||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
|
||||||
|
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
|
||||||
|
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
|
||||||
|
else
|
||||||
|
# Oz needed to make it fit on flash
|
||||||
|
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO), 1)
|
ifeq ($(ENABLE_LTO),1)
|
||||||
# CFLAGS += -flto
|
|
||||||
CFLAGS += -flto=2
|
CFLAGS += -flto=2
|
||||||
else
|
else
|
||||||
# We get most of the space savings if LTO creates problems
|
# We get most of the space savings if LTO creates problems
|
||||||
@ -276,12 +299,18 @@ ifeq ($(ENABLE_BAND_SCOPE),1)
|
|||||||
CFLAGS += -DENABLE_BAND_SCOPE
|
CFLAGS += -DENABLE_BAND_SCOPE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
LDFLAGS =
|
||||||
|
ifeq ($(ENABLE_CLANG),0)
|
||||||
|
LDFLAGS += -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
||||||
|
else
|
||||||
|
# Fix warning about implied executable stack
|
||||||
|
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
||||||
|
endif
|
||||||
|
|
||||||
# Use newlib-nano instead of newlib
|
# Use newlib-nano instead of newlib
|
||||||
LDFLAGS += --specs=nano.specs
|
LDFLAGS += --specs=nano.specs
|
||||||
|
|
||||||
ifeq ($(ENABLE_LTO), 0)
|
ifeq ($(ENABLE_LTO),0)
|
||||||
# Throw away unneeded func/data sections like LTO does
|
# Throw away unneeded func/data sections like LTO does
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
endif
|
endif
|
||||||
|
@ -26,6 +26,7 @@ You can customize the firmware by enabling/disabling various compile options.
|
|||||||
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
|
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
|
||||||
|
|
||||||
```
|
```
|
||||||
|
ENABLE_CLANG := 0 experimental, builds with clang instead of gcc (LTO will be disabled if you enable this)
|
||||||
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
|
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
|
||||||
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
|
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
|
||||||
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (overlay will be disabled if you enable this)
|
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (overlay will be disabled if you enable this)
|
||||||
@ -88,6 +89,9 @@ arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on
|
|||||||
Other versions may generate a flash file that is too big.
|
Other versions may generate a flash file that is too big.
|
||||||
You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm
|
You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm
|
||||||
|
|
||||||
|
clang may be used but isn't fully supported. Resulting binaries may also be bigger.
|
||||||
|
You can get it from: https://releases.llvm.org/download.html
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
To build the firmware, you need to fetch the submodules and then run make:
|
To build the firmware, you need to fetch the submodules and then run make:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user