diff --git a/Makefile b/Makefile index b213fcd..ea88021 100644 --- a/Makefile +++ b/Makefile @@ -95,9 +95,9 @@ CFLAGS += -std=c99 CFLAGS += -Wpedantic -Wall -Werror -Wundef -Wextra -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5 # add options for better code optimization CFLAGS += -fno-common -ffunction-sections -fdata-sections -# use variable size enum (opencm3 and libc do) +# use variable size enum (opencm3, gcc, and compiler-rt do) CFLAGS += -fshort-enums -# use no variable size enum +# use no variable size enum (musl does not) #CFLAGS += -fno-short-enums # don't use system main definition (the starting point) CFLAGS += -ffreestanding @@ -121,22 +121,28 @@ CFLAGS += $(DEFS) LDFLAGS += -static # don's include the system start files LDFLAGS += -nostartfiles -# don't use system libraries -#LDFLAGS += -nostdlib -nostdinc # only keep used sections LDFLAGS += --gc-sections +# don't use system libraries +#LDFLAGS += -nostdlib -nostdinc +# add musl libraries (for libc, libm) +#LDFLAGS += --library-path /media/data/tmp/arm-linux-musleabi/arm-linux-musleabi/lib +# add system libraries (for libc, libm, libnosys) +LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/ +# add gcc library (for ARM ABI to be used by gcc) +LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/ +# add compiler-rt library (for ARM ABI to be used by clang) +#LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/ # opencm3 libraries LDFLAGS += --library-path $(OPENCM3_LIB) -# add c,m,nosys system libraries -LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/ -# add gcc system library -LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/ + # linker script with definitions for micro-controller LDFLAGS += --script $(LDSCRIPT) -# used libraries (must be provided after objects) +# used libraries when using gcc (must be provided after objects) LDLIBS += --library $(STM32F1_LIB) --library c --library gcc --library nosys --library m - +# used libraries when using clang (must be provided after objects) +#LDLIBS += --library $(STM32F1_LIB) --library c --library m --library clang_rt.builtins # target micro-controller information (ARM Cortex-M3 supports thumb and thumnb2, but does not include a floating point unit) ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float