Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 1069974

Browse files
author
Leandro Dorileo
committed
build: compiler options
This patch re-organizes the compiler option into their own menu entry, adds a release/debug build type and also includes the CONFIG_CFLAGS and CONFIG_LDFLAGS configuration alternatives. Signed-off-by: Leandro Dorileo <[email protected]>
1 parent 54c5a88 commit 1069974

File tree

2 files changed

+52
-20
lines changed

2 files changed

+52
-20
lines changed

Kconfig

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,6 @@ config ENABLE_DYNAMIC_MODULES
3030
depends on SHARED_LIBRARY
3131
default n
3232

33-
config CC_SANITIZE
34-
bool "Compiler sanitize"
35-
depends on FEATURE_CC_SANITIZE && (HAVE_SANITIZE_UNDEFINED || HAVE_SANITIZE_ADDRESS)
36-
default y
37-
38-
choice CC_SANITIZE_TYPE
39-
prompt "Compiler sanitize type"
40-
depends on CC_SANITIZE
41-
default CC_SANITIZE_UNDEFINED if HAVE_SANITIZE_UNDEFINED
42-
default CC_SANITIZE_ADDRESS if HAVE_SANITIZE_ADDRESS
43-
44-
config CC_SANITIZE_UNDEFINED
45-
bool "undefined"
46-
depends on HAVE_SANITIZE_UNDEFINED
47-
48-
config CC_SANITIZE_ADDRESS
49-
bool "address"
50-
depends on HAVE_SANITIZE_ADDRESS
51-
endchoice
52-
5333
config MODULES
5434
bool "Enable loadable module support"
5535
option modules
@@ -85,6 +65,51 @@ config PREFIX
8565
further resources, such as loadable module support (see
8666
MODULES configuration help).
8767

68+
menu "Compiler options"
69+
choice BUILD_TYPE
70+
prompt "Build type"
71+
default BUILD_TYPE_RELEASE
72+
73+
config BUILD_TYPE_DEBUG
74+
bool "debug"
75+
76+
config BUILD_TYPE_RELEASE
77+
bool "release"
78+
endchoice
79+
80+
config CONFIG_CFLAGS
81+
string "Arbitrary CFLAGS"
82+
help
83+
Sets arbitrary CFLAGS to be used across make invocations
84+
without the need to be provided on every make call.
85+
86+
config CONFIG_LDFLAGS
87+
string "Arbitrary LDFLAGS"
88+
help
89+
Sets arbitrary LDFLAGS to be used across make invocations
90+
without the need to be provided on every make call.
91+
92+
config CC_SANITIZE
93+
bool "Compiler sanitize"
94+
depends on FEATURE_CC_SANITIZE && (HAVE_SANITIZE_UNDEFINED || HAVE_SANITIZE_ADDRESS)
95+
default y
96+
97+
choice CC_SANITIZE_TYPE
98+
prompt "Compiler sanitize type"
99+
depends on CC_SANITIZE
100+
default CC_SANITIZE_UNDEFINED if HAVE_SANITIZE_UNDEFINED
101+
default CC_SANITIZE_ADDRESS if HAVE_SANITIZE_ADDRESS
102+
103+
config CC_SANITIZE_UNDEFINED
104+
bool "undefined"
105+
depends on HAVE_SANITIZE_UNDEFINED
106+
107+
config CC_SANITIZE_ADDRESS
108+
bool "address"
109+
depends on HAVE_SANITIZE_ADDRESS
110+
endchoice
111+
endmenu
112+
88113
endmenu
89114

90115
menu "Core library"

tools/build/Makefile.vars

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ COMMON_LDFLAGS += $(SANITIZE_ADDRESS_LDFLAGS)
160160
endif
161161
endif
162162

163+
COMMON_CFLAGS += $(patsubst "%",%,$(CONFIG_CFLAGS))
164+
COMMON_LDFLAGS += $(patsubst "%",%,$(CONFIG_LDFLAGS))
165+
163166
ifneq (,$(shell echo $(COMMON_CFLAGS) | grep -e "-O[s12345\ ]"))
164167
COMMON_CFLAGS += $(FLTO_CFLAGS)
165168
endif
@@ -209,6 +212,10 @@ ifeq (y,$(SHARED_LIBRARY))
209212
COMMON_CFLAGS += -fPIC
210213
endif
211214

215+
ifeq (y,$(BUILD_TYPE_DEBUG))
216+
COMMON_CFLAGS += -g
217+
endif
218+
212219
COMMON_CFLAGS += -std=gnu99
213220
COMMON_CFLAGS += -include $(abspath $(KCONFIG_AUTOHEADER))
214221
COMMON_CFLAGS += -include $(abspath $(DEFINITIONS_H))

0 commit comments

Comments
 (0)