forked from alibaba/AliOS-Things
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaos_toolchain_xtensa.mk
130 lines (108 loc) · 5.27 KB
/
aos_toolchain_xtensa.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
ifneq ($(filter $(HOST_ARCH), xtensa),)
TOOLCHAIN_PATH ?=
ifneq ($(filter $(HOST_MCU_FAMILY), esp8266), )
TOOLCHAIN_PREFIX := xtensa-lx106-elf-
TOOLCHAIN_DEFAULT_FOLDER := gcc-xtensa-lx106
endif
ifneq ($(filter $(HOST_MCU_FAMILY), esp32), )
TOOLCHAIN_PREFIX := xtensa-esp32-elf-
TOOLCHAIN_DEFAULT_FOLDER := gcc-xtensa-esp32
endif
ifneq (,$(wildcard $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin))
TOOLCHAIN_PATH := $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin/
endif
SYSTEM_TOOLCHAIN_PATH :=
ifeq ($(HOST_OS),Win32)
SYSTEM_GCC_PATH = $(shell where $(TOOLCHAIN_PREFIX)gcc.exe)
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc.exe,$(SYSTEM_GCC_PATH)))
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc.exe,,$(SYSTEM_GCC_PATH))
endif
else #WIN32
ifneq (,$(filter $(HOST_OS),Linux32 Linux64 OSX))
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc,,$(SYSTEM_GCC_PATH))
endif
else #Linux32 Linux64 OSX
$(error unsupport OS $(HOST_OS))
endif #Linux32 Linux64 OSX
endif #WIN32
ifeq (,$(TOOLCHAIN_PATH))
ifneq (,$(SYSTEM_TOOLCHAIN_PATH))
TOOLCHAIN_PATH := $(SYSTEM_TOOLCHAIN_PATH)
else
DOWNLOAD_URL = "https://esp-idf.readthedocs.io/en/latest/get-started/index.html\#setup-toolchain"
$(error can not find compiler toolchain, please setup toolchain as $(DOWNLOAD_URL) instructed)
endif #SYSTEM_TOOLCHAIN_PATH
endif #TOOLCHAIN_PATH
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++
AS := $(CC)
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
CPP := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cpp
OPTIONS_IN_FILE_OPTION := @
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
#debug: no optimize and log enable
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
#release_log: optimize but log enable
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref -nostdlib
#release: optimize and log disable
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref -nostdlib
COMPILER_SPECIFIC_DEPS_FLAG := -MD
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
COMPILER_SPECIFIC_LINK_SCRIPT =
LINKER := $(CC)
LINK_SCRIPT_SUFFIX := .ld
TOOLCHAIN_NAME := GCC
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
ENDIAN_ASMFLAGS_LITTLE :=
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
CLIB_LDFLAGS_NANO := --specs=nano.specs
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
# Chip specific flags for GCC
CPU_CFLAGS :=
CPU_CXXFLAGS :=
CPU_ASMFLAGS :=
CPU_LDFLAGS :=
CLIB_LDFLAGS_NANO +=
CLIB_LDFLAGS_NANO_FLOAT +=
# $(1) is map file, $(2) is CSV output file
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
# $(1) is map file, $(2) is CSV output file
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
STRIP_OUTPUT_PREFIX := -o
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
LINK_OUTPUT_SUFFIX :=.elf
BIN_OUTPUT_SUFFIX :=.bin
HEX_OUTPUT_SUFFIX :=.hex
endif