Skip to content

Commit

Permalink
libc: rework libc selection and reduce Kconfigs
Browse files Browse the repository at this point in the history
Moved all libc Kconfigs to where the code is and remove the default
Kconfig for selecting the minimal libc. Minimal libc is now the default
if nothing else is configured in.

Removed the options for extended libc, this obviously was restricting
features in the minimal libc without a good reason, most of the
functions are available directly when using newlib, so there is no
reason why we need to restrict those in minimal libc.

Jira: ZEP-1440
Change-Id: If0a3adf4314e2ebdf0e139dee3eb4f47ce07aa89
Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif authored and Anas Nashif committed Dec 15, 2016
1 parent b12a8e0 commit fe958df
Show file tree
Hide file tree
Showing 36 changed files with 57 additions and 93 deletions.
2 changes: 2 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ source "lib/crypto/tinycrypt/Kconfig"
endmenu

source "lib/iot/Kconfig"

source "lib/libc/Kconfig"
6 changes: 2 additions & 4 deletions lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ifdef CONFIG_MINIMAL_LIBC
ZEPHYRINCLUDE += -I$(srctree)/lib/libc/minimal/include
endif

ifdef CONFIG_NEWLIB_LIBC
ZEPHYRINCLUDE += $(TOOLCHAIN_CFLAGS)
ALL_LIBS += m c
Expand All @@ -14,6 +10,8 @@ ifdef CONFIG_NEWLIB_LIBC_FLOAT_SCANF
LDFLAGS += -u _scanf_float
endif

else
ZEPHYRINCLUDE += -I$(srctree)/lib/libc/minimal/include
endif

include $(srctree)/lib/iot/Makefile
3 changes: 1 addition & 2 deletions lib/iot/http/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ config HTTP_PARSER
help
This option enables the http_parser library from nodejs.
This parser requires some string-related routines commonly
provided by a libc implementation. So, MINIMAL_LIBC_EXTENDED
can be used here to resolve all the required dependencies.
provided by a libc implementation.

config HTTP_PARSER_STRICT
bool
Expand Down
44 changes: 44 additions & 0 deletions lib/libc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Kconfig - C library

#
# Copyright (c) 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

menu "C Library"

config NEWLIB_LIBC
bool
prompt "Build with newlib c library"
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.

config NEWLIB_LIBC_FLOAT_PRINTF
bool "Build with newlib float printf"
default n
depends on NEWLIB_LIBC
help
Build with floating point printf enabled. This will increase the size of
the image.

config NEWLIB_LIBC_FLOAT_SCANF
bool "Build with newlib float scanf"
default n
depends on NEWLIB_LIBC
help
Build with floating point scanf enabled. This will increase the size of
the image.

endmenu
7 changes: 5 additions & 2 deletions lib/libc/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
obj-$(CONFIG_MINIMAL_LIBC) += minimal/
obj-$(CONFIG_NEWLIB_LIBC) += newlib/
ifeq ($(CONFIG_NEWLIB_LIBC),y)
obj-y += newlib/
else
obj-y += minimal/
endif
2 changes: 1 addition & 1 deletion lib/libc/minimal/source/stdlib/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
obj-$(CONFIG_MINIMAL_LIBC_EXTENDED) += strtol.o strtoul.o atoi.o
obj-y += strtol.o strtoul.o atoi.o
4 changes: 2 additions & 2 deletions lib/libc/minimal/source/string/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
obj-y := string.o
obj-$(CONFIG_MINIMAL_LIBC_EXTENDED) += strncasecmp.o strstr.o
obj-y += string.o
obj-y += strncasecmp.o strstr.o
52 changes: 0 additions & 52 deletions misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -122,58 +122,6 @@ config CPLUSPLUS
help
This option enables the use of applications built with C++.

choice
prompt "C Library"
default MINIMAL_LIBC

config MINIMAL_LIBC
bool
prompt "Build minimal c library"
help
Build integrated minimal c library. This integrated library is available
to support kernel functionality and test cases. It is not designed to be
used with applications. For applications, please use an external C
library such as newlib.

config NEWLIB_LIBC
bool
prompt "Build with newlib c library"
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.

endchoice

config NEWLIB_LIBC_FLOAT_PRINTF
bool "Build with newlib float printf"
default n
depends on NEWLIB_LIBC
help
Build with floating point printf enabled. This will increase the size of
the image.

config NEWLIB_LIBC_FLOAT_SCANF
bool "Build with newlib float scanf"
default n
depends on NEWLIB_LIBC
help
Build with floating point scanf enabled. This will increase the size of
the image.

config MINIMAL_LIBC_EXTENDED
bool "Build additional libc functions [EXPERIMENTAL]"
default n
depends on MINIMAL_LIBC
help
This option enables building some optional libc functions that
are not used directly by the kernel but can be used in applications.
The option adds the following functions: strtoul, strtol, atoi,
strncasecmp.
Warning: Use the above functions only for testing, if you need to
use any of the functions in an application you probably should be
linking against a full lib c implementation instead.


endmenu

menu "Debugging Options"
Expand Down
1 change: 0 additions & 1 deletion samples/bluetooth/handsfree/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_BREDR=y
CONFIG_BLUETOOTH_RFCOMM=y
Expand Down
1 change: 0 additions & 1 deletion samples/bluetooth/peripheral_csc/prj_nble.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_RANDOM_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
Expand Down
1 change: 0 additions & 1 deletion samples/grove/light/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ CONFIG_GROVE_LIGHT_SENSOR=y
CONFIG_GROVE=y
CONFIG_SENSOR=y
CONFIG_NEWLIB_LIBC=y
CONFIG_MINIMAL_LIBC=n
CONFIG_STDOUT_CONSOLE=y
1 change: 0 additions & 1 deletion samples/grove/temperature/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CONFIG_I2C=y
CONFIG_GROVE=y
CONFIG_ADC=y
CONFIG_NEWLIB_LIBC=y
CONFIG_MINIMAL_LIBC=n
CONFIG_GROVE_TEMPERATURE_SENSOR_ADC_CHANNEL=10
CONFIG_GROVE_TEMPERATURE_SENSOR=y
CONFIG_GROVE_TEMPERATURE_SENSOR_V1_1=y
Expand Down
2 changes: 0 additions & 2 deletions samples/legacy/task_profiler/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,8 @@ For that purpose, following flags must be enabled in project configuration file
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
-->

CONFIG_MINIMAL_LIBC_EXTENDED is required for atoi() function used in profiler shell
command implementation.

If done, the profiler will automatically enable a shell over UART allowing to
Expand Down
1 change: 0 additions & 1 deletion samples/legacy/task_profiler/microkernel/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_STDOUT_CONSOLE=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_TASK_MONITOR=y
CONFIG_TASK_MONITOR_MASK=6
CONFIG_RING_BUFFER=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_STDOUT_CONSOLE=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_TASK_MONITOR=y
CONFIG_TASK_MONITOR_MASK=6
CONFIG_RING_BUFFER=y
Expand Down
1 change: 0 additions & 1 deletion samples/legacy/task_profiler/nanokernel/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_STDOUT_CONSOLE=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_RING_BUFFER=y
CONFIG_KERNEL_EVENT_LOGGER=y
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_STDOUT_CONSOLE=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_RING_BUFFER=y
CONFIG_KERNEL_EVENT_LOGGER=y
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
Expand Down
1 change: 0 additions & 1 deletion samples/net/mbedtls_dtlsclient/prj_arduino_101.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_MINIMAL_LIBC_EXTENDED=y

CONFIG_SYS_LOG=y
CONFIG_NET_LOG=y
Expand Down
1 change: 0 additions & 1 deletion samples/net/mbedtls_dtlsclient/prj_qemu_x86.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_MINIMAL_LIBC_EXTENDED=y

CONFIG_NETWORKING=y
CONFIG_NET_IPV6=n
Expand Down
1 change: 0 additions & 1 deletion samples/net/mbedtls_sslclient/prj_galileo.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_TEST_RANDOM_GENERATOR=y

CONFIG_NETWORKING=y
Expand Down
1 change: 0 additions & 1 deletion samples/net/zperf/prj_frdm_k64f.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_PRINTK=y
CONFIG_MINIMAL_LIBC_EXTENDED=y

CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
Expand Down
1 change: 0 additions & 1 deletion samples/net/zperf/prj_frdm_k64f_prof.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=10000
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
1 change: 0 additions & 1 deletion samples/net/zperf/prj_galileo_ethernet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_PRINTK=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
#
# networking
#
Expand Down
2 changes: 0 additions & 2 deletions samples/net/zperf/prj_galileo_ethernet_prof.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_PRINTK=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
#
# networking
#
Expand Down Expand Up @@ -43,4 +42,3 @@ CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
CONFIG_UART_NS16550_PORT_1_BAUD_RATE=921600
CONFIG_UART_NS16550_PORT_0=n
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
1 change: 0 additions & 1 deletion samples/net/zperf/prj_qemu_x86.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_PRINTK=y
CONFIG_MINIMAL_LIBC_EXTENDED=y

CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
Expand Down
1 change: 0 additions & 1 deletion samples/net/zperf/prj_quark_se_c1000_devboard.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ENABLE_SHELL=y
CONFIG_PRINTK=y
CONFIG_MINIMAL_LIBC_EXTENDED=y

CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
Expand Down
1 change: 0 additions & 1 deletion subsys/net/ip/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ config NET_SHELL
select ENABLE_SHELL
select CONSOLE_HANDLER
select CONSOLE_HANDLER_SHELL
select MINIMAL_LIBC_EXTENDED
help
Activate shell module that provides network commands like
ping to the console.
Expand Down
1 change: 0 additions & 1 deletion subsys/net/ip/Kconfig.samples
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
menuconfig NET_SAMPLES_IP_ADDRESSES
bool "Set IP addresses for sample applications"
default n
select MINIMAL_LIBC_EXTENDED
help
Allow IP addresses to be set in config file for
networking client/server sample applications.
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/arduino_101.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_BLUETOOTH=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_BLUETOOTH_DEBUG_LOG=y
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_BLUETOOTH=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_BLUETOOTH_DEBUG_LOG=y
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/prj_br.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_BREDR=y
CONFIG_BLUETOOTH_RFCOMM=y
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/prj_nble.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_CUSTOM=y
Expand Down
1 change: 0 additions & 1 deletion tests/bluetooth/shell/prj_nimble.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_BLUETOOTH=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_BLUETOOTH_DEBUG_LOG=y
Expand Down
1 change: 0 additions & 1 deletion tests/crypto/test_mbedtls/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_ARC_INIT=n
CONFIG_STDOUT_CONSOLE=y
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_BUILTIN=y
CONFIG_MBEDTLS_TEST=y
1 change: 0 additions & 1 deletion tests/iot/test_http_header/prj.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Comment the following line if you want to try another libc
CONFIG_MINIMAL_LIBC_EXTENDED=y
CONFIG_HTTP_PARSER=y
# Enable strict parser by uncommenting the following line
# CONFIG_HTTP_PARSER_STRICT=y
1 change: 0 additions & 1 deletion tests/kernel/test_build/newlib.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_DEBUG=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_NEWLIB_LIBC=y
CONFIG_MINIMAL_LIBC=n

0 comments on commit fe958df

Please sign in to comment.