Skip to content

Commit 8b1e34f

Browse files
donghengdongheng
dongheng
authored and
dongheng
committed
feat(kconfig): update global "Kconfig" and its dependent compiling script
1 parent f12b37b commit 8b1e34f

File tree

3 files changed

+215
-180
lines changed

3 files changed

+215
-180
lines changed

Kconfig

+194-162
Original file line numberDiff line numberDiff line change
@@ -4,165 +4,197 @@
44
#
55
mainmenu "Espressif IoT Development Framework Configuration"
66

7-
choice IDF_TARGET
8-
bool "Espressif target platform choose"
9-
default IDF_TARGET_ESP8266
10-
help
11-
Choose the specific target platform which you will use.
12-
13-
config IDF_TARGET_ESP8266
14-
bool "esp8266"
15-
endchoice
16-
17-
config IDF_TARGET
18-
string
19-
default "esp8266" if IDF_TARGET_ESP8266
20-
21-
menu "SDK tool configuration"
22-
config SDK_TOOLPREFIX
23-
string
24-
default "xtensa-lx106-elf-" if IDF_TARGET_ESP8266
25-
help
26-
The prefix/path that is used to call the toolchain. The default setting assumes
27-
a crosstool-ng gcc setup that is in your PATH.
28-
29-
config PYTHON
30-
string "Python 2 interpreter"
31-
default "python"
32-
help
33-
The executable name/path that is used to run python. On some systems Python 2.x
34-
may need to be invoked as python2.
35-
36-
config MAKE_WARN_UNDEFINED_VARIABLES
37-
bool "'make' warns on undefined variables"
38-
default "y"
39-
help
40-
Adds --warn-undefined-variables to MAKEFLAGS. This causes make to
41-
print a warning any time an undefined variable is referenced.
42-
43-
This option helps find places where a variable reference is misspelled
44-
or otherwise missing, but it can be unwanted if you have Makefiles which
45-
depend on undefined variables expanding to an empty string.
46-
47-
endmenu # SDK tool configuration
48-
49-
source "$COMPONENT_KCONFIGS_PROJBUILD"
50-
51-
menu "Compiler options"
52-
53-
choice OPTIMIZATION_COMPILER
54-
prompt "Optimization Level"
55-
default OPTIMIZATION_LEVEL_DEBUG
56-
help
57-
This option sets compiler optimization level (gcc -O argument).
58-
59-
- for "Release" setting, -Os flag is added to CFLAGS.
60-
- for "Debug" setting, -Og flag is added to CFLAGS.
61-
62-
"Release" with -Os produces smaller & faster compiled code but it
63-
may be harder to correlated code addresses to source files when debugging.
64-
65-
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
66-
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
67-
custom optimization levels may be unsupported.
68-
69-
config OPTIMIZATION_LEVEL_DEBUG
70-
bool "Debug (-Og)"
71-
config OPTIMIZATION_LEVEL_RELEASE
72-
bool "Release (-Os)"
73-
endchoice
74-
75-
choice OPTIMIZATION_ASSERTION_LEVEL
76-
prompt "Assertion level"
77-
default OPTIMIZATION_ASSERTIONS_ENABLED
78-
help
79-
Assertions can be:
80-
- Enabled. Failure will print verbose assertion details. This is the default.
81-
82-
- Set to "silent" to save code size (failed assertions will abort() but user
83-
needs to use the aborting address to find the line number with the failed assertion.)
84-
85-
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
86-
to CPPFLAGS in this case.
87-
88-
config OPTIMIZATION_ASSERTIONS_ENABLED
89-
prompt "Enabled"
90-
bool
91-
help
92-
Enable assertions. Assertion content and line number will be printed on failure.
93-
94-
config OPTIMIZATION_ASSERTIONS_SILENT
95-
prompt "Silent (saves code size)"
96-
bool
97-
help
98-
Enable silent assertions. Failed assertions will abort(), user needs to
99-
use the aborting address to find the line number with the failed assertion.
100-
101-
config OPTIMIZATION_ASSERTIONS_DISABLED
102-
prompt "Disabled (sets -DNDEBUG)"
103-
bool
104-
help
105-
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
106-
107-
endchoice # assertions
108-
109-
menuconfig CXX_EXCEPTIONS
110-
bool "Enable C++ exceptions"
111-
default n
112-
help
113-
Enabling this option compiles all IDF C++ files with exception support enabled.
114-
115-
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
116-
an exception will abort instead.
117-
118-
Enabling this option currently adds an additional ~500 bytes of heap overhead
119-
when an exception is thrown in user code for the first time.
120-
121-
config CXX_EXCEPTIONS_EMG_POOL_SIZE
122-
int "Emergency Pool Size"
123-
default 0
124-
depends on CXX_EXCEPTIONS
125-
help
126-
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
127-
memory for thrown exceptions when there is not enough memory on the heap.
128-
129-
choice STACK_CHECK_MODE
130-
prompt "Stack smashing protection mode"
131-
default STACK_CHECK_NONE
132-
help
133-
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
134-
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
135-
The guards are initialized when a function is entered and then checked when the function exits.
136-
If a guard check fails, program is halted. Protection has the following modes:
137-
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca, and functions with buffers larger than
138-
8 bytes are protected.
139-
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes additional functions to be protected -- those that
140-
have local array definitions, or have references to local frame addresses.
141-
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
142-
143-
Modes have the following impact on code performance and coverage:
144-
- performance: NORMAL > STRONG > OVERALL
145-
- coverage: NORMAL < STRONG < OVERALL
146-
147-
148-
config STACK_CHECK_NONE
149-
bool "None"
150-
config STACK_CHECK_NORM
151-
bool "Normal"
152-
config STACK_CHECK_STRONG
153-
bool "Strong"
154-
config STACK_CHECK_ALL
155-
bool "Overall"
156-
endchoice
157-
158-
config STACK_CHECK
159-
bool
160-
default !STACK_CHECK_NONE
161-
help
162-
Stack smashing protection.
163-
164-
endmenu # Compiler Options
165-
166-
menu "Component config"
167-
source "$COMPONENT_KCONFIGS"
168-
endmenu
7+
# Hidden option to support checking for this specific target in C code and Kconfig files
8+
config IDF_TARGET_ESP8266
9+
bool
10+
default "y" if IDF_TARGET="esp8266"
11+
default "n"
12+
13+
config IDF_CMAKE
14+
bool
15+
option env="IDF_CMAKE"
16+
17+
18+
config IDF_TARGET_ENV
19+
# A proxy to get environment variable $IDF_TARGET
20+
string
21+
option env="IDF_TARGET"
22+
23+
config IDF_TARGET
24+
# This option records the IDF target when sdkconfig is generated the first time.
25+
# It is not updated if environment variable $IDF_TARGET changes later, and
26+
# the build system is responsible for detecting the mismatch between
27+
# CONFIG_IDF_TARGET and $IDF_TARGET.
28+
string
29+
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
30+
default IDF_TARGET_ENV
31+
32+
33+
menu "SDK tool configuration"
34+
config SDK_TOOLPREFIX
35+
string "Compiler toolchain path/prefix"
36+
default "xtensa-lx106-elf-"
37+
help
38+
The prefix/path that is used to call the toolchain. The default setting assumes
39+
a crosstool-ng gcc setup that is in your PATH.
40+
41+
config SDK_PYTHON
42+
string "Python 2 interpreter"
43+
depends on !IDF_CMAKE
44+
default "python"
45+
help
46+
The executable name/path that is used to run python. On some systems Python 2.x
47+
may need to be invoked as python2.
48+
49+
(Note: This option is used with the legacy GNU Make build system only.)
50+
51+
config SDK_MAKE_WARN_UNDEFINED_VARIABLES
52+
bool "'make' warns on undefined variables"
53+
depends on !IDF_CMAKE
54+
default "n"
55+
help
56+
Adds --warn-undefined-variables to MAKEFLAGS. This causes make to
57+
print a warning any time an undefined variable is referenced.
58+
59+
This option helps find places where a variable reference is misspelled
60+
or otherwise missing, but it can be unwanted if you have Makefiles which
61+
depend on undefined variables expanding to an empty string.
62+
63+
(Note: this option is used with the legacy GNU Make build system only.)
64+
65+
endmenu # SDK tool configuration
66+
67+
source "$COMPONENT_KCONFIGS_PROJBUILD"
68+
69+
menu "Compiler options"
70+
71+
choice COMPILER_OPTIMIZATION
72+
prompt "Optimization Level"
73+
default COMPILER_OPTIMIZATION_LEVEL_DEBUG
74+
help
75+
This option sets compiler optimization level (gcc -O argument).
76+
77+
- for "Release" setting, -Os flag is added to CFLAGS.
78+
- for "Debug" setting, -Og flag is added to CFLAGS.
79+
80+
"Release" with -Os produces smaller & faster compiled code but it
81+
may be harder to correlated code addresses to source files when debugging.
82+
83+
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
84+
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
85+
custom optimization levels may be unsupported.
86+
87+
config COMPILER_OPTIMIZATION_LEVEL_DEBUG
88+
bool "Debug (-Og)"
89+
config COMPILER_OPTIMIZATION_LEVEL_RELEASE
90+
bool "Release (-Os)"
91+
endchoice
92+
93+
choice COMPILER_OPTIMIZATION_ASSERTION_LEVEL
94+
prompt "Assertion level"
95+
default COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE
96+
help
97+
Assertions can be:
98+
99+
- Enabled. Failure will print verbose assertion details. This is the default.
100+
101+
- Set to "silent" to save code size (failed assertions will abort() but user
102+
needs to use the aborting address to find the line number with the failed assertion.)
103+
104+
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
105+
to CPPFLAGS in this case.
106+
107+
config COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE
108+
prompt "Enabled"
109+
bool
110+
help
111+
Enable assertions. Assertion content and line number will be printed on failure.
112+
113+
config COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
114+
prompt "Silent (saves code size)"
115+
bool
116+
help
117+
Enable silent assertions. Failed assertions will abort(), user needs to
118+
use the aborting address to find the line number with the failed assertion.
119+
120+
config COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
121+
prompt "Disabled (sets -DNDEBUG)"
122+
bool
123+
help
124+
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
125+
126+
endchoice # assertions
127+
128+
menuconfig COMPILER_CXX_EXCEPTIONS
129+
bool "Enable C++ exceptions"
130+
default n
131+
help
132+
Enabling this option compiles all IDF C++ files with exception support enabled.
133+
134+
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code
135+
which throws an exception will abort instead.
136+
137+
Enabling this option currently adds an additional ~500 bytes of heap overhead
138+
when an exception is thrown in user code for the first time.
139+
140+
choice COMPILER_STACK_CHECK_MODE
141+
prompt "Stack smashing protection mode"
142+
default COMPILER_STACK_CHECK_MODE_NONE
143+
help
144+
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
145+
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
146+
The guards are initialized when a function is entered and then checked when the function exits.
147+
If a guard check fails, program is halted. Protection has the following modes:
148+
149+
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca, and functions with
150+
buffers larger than 8 bytes are protected.
151+
152+
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes additional functions
153+
to be protected -- those that have local array definitions, or have references to local frame
154+
addresses.
155+
156+
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
157+
158+
Modes have the following impact on code performance and coverage:
159+
160+
- performance: NORMAL > STRONG > OVERALL
161+
162+
- coverage: NORMAL < STRONG < OVERALL
163+
164+
165+
config COMPILER_STACK_CHECK_MODE_NONE
166+
bool "None"
167+
config COMPILER_STACK_CHECK_MODE_NORM
168+
bool "Normal"
169+
config COMPILER_STACK_CHECK_MODE_STRONG
170+
bool "Strong"
171+
config COMPILER_STACK_CHECK_MODE_ALL
172+
bool "Overall"
173+
endchoice
174+
175+
config COMPILER_STACK_CHECK
176+
bool
177+
default !COMPILER_STACK_CHECK_MODE_NONE
178+
help
179+
Stack smashing protection.
180+
181+
config COMPILER_WARN_WRITE_STRINGS
182+
bool "Enable -Wwrite-strings warning flag"
183+
default "n"
184+
help
185+
Adds -Wwrite-strings flag for the C/C++ compilers.
186+
187+
For C, this gives string constants the type ``const char[]`` so that
188+
copying the address of one into a non-const ``char *`` pointer
189+
produces a warning. This warning helps to find at compile time code
190+
that tries to write into a string constant.
191+
192+
For C++, this warns about the deprecated conversion from string
193+
literals to ``char *``.
194+
195+
196+
endmenu # Compiler Options
197+
198+
menu "Component config"
199+
source "$COMPONENT_KCONFIGS"
200+
endmenu

make/project.mk

+3-18
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ $(error IDF_PATH variable is not set to a valid directory.)
9595
endif
9696

9797
ifdef IDF_TARGET
98-
ifneq ($(IDF_TARGET),esp32)
99-
$(error GNU Make based build system only supports esp32 target, but IDF_TARGET is set to $(IDF_TARGET))
98+
ifneq ($(IDF_TARGET),esp8266)
99+
$(error GNU Make based build system only supports esp8266 target, but IDF_TARGET is set to $(IDF_TARGET))
100100
endif
101101
else
102-
export IDF_TARGET := esp32
102+
export IDF_TARGET := esp8266
103103
endif
104104

105105

@@ -377,21 +377,6 @@ COMMON_WARNING_FLAGS = -Wall -Werror=all \
377377
-Wextra \
378378
-Wno-unused-parameter -Wno-sign-compare
379379

380-
ifdef CONFIG_COMPILER_DISABLE_GCC8_WARNINGS
381-
COMMON_WARNING_FLAGS += -Wno-parentheses \
382-
-Wno-sizeof-pointer-memaccess \
383-
-Wno-clobbered \
384-
-Wno-format-overflow \
385-
-Wno-stringop-truncation \
386-
-Wno-misleading-indentation \
387-
-Wno-cast-function-type \
388-
-Wno-implicit-fallthrough \
389-
-Wno-unused-const-variable \
390-
-Wno-switch-unreachable \
391-
-Wno-format-truncation \
392-
-Wno-memset-elt-size \
393-
-Wno-int-in-bool-context
394-
endif
395380

396381
ifdef CONFIG_COMPILER_WARN_WRITE_STRINGS
397382
COMMON_WARNING_FLAGS += -Wwrite-strings

0 commit comments

Comments
 (0)