Skip to content

Commit

Permalink
treewide: model newlib as a FEATURE
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Jan 27, 2021
1 parent de9f29c commit 63a2a6c
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 29 deletions.
4 changes: 4 additions & 0 deletions Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ include $(RIOTCPU)/$(CPU)/Makefile.features

# Provide CPU as a feature to allow listing all boards with a CPU
FEATURES_PROVIDED += cpu_$(CPU)

# Features that are conflicting for all architectures
FEATURES_CONFLICT += picolibc:newlib
FEATURES_CONFLICT_MSG += "Only one standard C library can be used"
1 change: 0 additions & 1 deletion boards/nucleo-l011k4/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Use Picolibc to reduce ROM usage
USEMODULE += picolibc
FEATURES_REQUIRED += picolibc

include $(RIOTBOARD)/common/nucleo/Makefile.dep
1 change: 0 additions & 1 deletion boards/samd10-xmini/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ endif

# Use Picolibc to reduce ROM usage
FEATURES_REQUIRED += picolibc
USEMODULE += picolibc
1 change: 0 additions & 1 deletion boards/stm32f030f4-demo/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Use Picolibc to reduce ROM usage
FEATURES_REQUIRED += picolibc
USEMODULE += picolibc
1 change: 1 addition & 0 deletions cpu/arm7_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ config CPU_CORE_ARM7TDMI_S
## Declaration of specific features
config HAS_ARCH_ARM7
bool
select HAS_NEWLIB
select HAS_PICOLIBC
help
Indicates that the core is part of the ARM7 group of cores.
Expand Down
8 changes: 2 additions & 6 deletions cpu/arm7_common/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# use common ARM7 periph code
USEMODULE += arm7_common_periph

ifneq (,$(filter picolibc,$(FEATURES_USED)))
# Use Picolibc when explicitly selected
USEMODULE += picolibc
else
# all cortex MCU's use newlib as libc
USEMODULE += newlib
FEATURES_REQUIRED_ANY += newlib|picolibc
ifneq (,$(filter newlib,$(USEMODULE)))
# use the nano-specs of Newlib when available
USEMODULE += newlib_nano
endif
Expand Down
1 change: 1 addition & 0 deletions cpu/arm7_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += arch_arm
FEATURES_PROVIDED += arch_arm7
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += picolibc
FEATURES_PROVIDED += puf_sram
Expand Down
1 change: 1 addition & 0 deletions cpu/cortexm_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ config CPU_CORE_CORTEX_M
select HAS_CPU_CHECK_ADDRESS
select HAS_SSP
select HAS_CORTEXM_SVC
select HAS_NEWLIB

## Common CPU symbols
config CPU_CORE
Expand Down
13 changes: 2 additions & 11 deletions cpu/cortexm_common/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@ USEMODULE += cortexm_common
# include common periph code
USEMODULE += cortexm_common_periph

# Ensure newlib is not added if picolibc is already in FEATURES_USED or USEMODULE.
# nucleo-l011k4 doesn't use features to forces picolibc but directly set it in
# USEMODULE. This is because during the first pass of the dependency resolution,
# with the feature mechanism, the picolib feature is not present in FEATURES_USED
# at this staged and as a result newlib modules are wrongly added.
ifneq (,$(filter picolibc,$(FEATURES_USED) $(USEMODULE)))
# Use Picolibc when explicitly selected
USEMODULE += picolibc
else
# all cortex MCU's use newlib as libc
USEMODULE += newlib
FEATURES_REQUIRED_ANY += newlib|picolibc
ifneq (,$(filter newlib,$(USEMODULE)))
# use the nano-specs of Newlib when available
USEMODULE += newlib_nano
endif
Expand Down
1 change: 1 addition & 0 deletions cpu/cortexm_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += cpu_check_address
FEATURES_PROVIDED += cpu_core_cortexm
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += puf_sram
FEATURES_PROVIDED += picolibc
Expand Down
5 changes: 4 additions & 1 deletion cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ include $(RIOTCPU)/esp_common/Makefile.dep
USEMODULE += esp_idf_driver
USEMODULE += esp_idf_esp32
USEMODULE += esp_idf_soc
USEMODULE += newlib_nano
USEMODULE += pm_layered

ifneq (,$(filter newlib,$(USEMODULE)))
USEMODULE += newlib_nano
endif

ifneq (,$(filter esp_eth,$(USEMODULE)))
USEMODULE += esp_freertos
USEMODULE += esp_idf_eth
Expand Down
1 change: 0 additions & 1 deletion cpu/esp8266/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ USEMODULE += esp_idf_util
USEMODULE += esp_idf_wpa_supplicant_crypto
USEMODULE += esp_sdk
USEMODULE += mtd
USEMODULE += newlib
USEMODULE += periph_common
USEMODULE += ps

Expand Down
1 change: 1 addition & 0 deletions cpu/esp_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ config CPU_COMMON_ESP
select HAS_ESP_SPIFFS
select HAS_ESP_WIFI
select HAS_ESP_WIFI_AP
select HAS_NEWLIB
select HAS_LIBSTDCPP
select HAS_PERIPH_CPUID
select HAS_PERIPH_HWRNG
Expand Down
2 changes: 1 addition & 1 deletion cpu/esp_common/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ USEMODULE += esp_common_periph
USEMODULE += esp_freertos
USEMODULE += esp_idf
USEMODULE += log
USEMODULE += newlib
USEMODULE += periph
USEMODULE += periph_hwrng
USEMODULE += periph_flash
Expand All @@ -22,6 +21,7 @@ USEMODULE += xtensa

# Features used by ESP*

FEATURES_REQUIRED += newlib
FEATURES_REQUIRED += cpp # Vendor code uses C++

ifneq (,$(filter esp_wifi_ap,$(USEMODULE)))
Expand Down
1 change: 1 addition & 0 deletions cpu/esp_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ FEATURES_PROVIDED += esp_spiffs
FEATURES_PROVIDED += esp_wifi_ap
FEATURES_PROVIDED += esp_wifi
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_hwrng
FEATURES_PROVIDED += periph_pm
Expand Down
1 change: 1 addition & 0 deletions cpu/fe310/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
config CPU_ARCH_RISCV
bool
select HAS_ARCH_RISCV
select HAS_NEWLIB
select HAS_PICOLIBC if '$(RIOT_CI_BUILD)' != '1'
select MODULE_MALLOC_THREAD_SAFE if TEST_KCONFIG

Expand Down
6 changes: 3 additions & 3 deletions cpu/fe310/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ifneq (,$(filter picolibc,$(FEATURES_USED)))
USEMODULE += picolibc
else

FEATURES_REQUIRED_ANY += picolibc|newlib
ifneq (,$(filter newlib,$(USEMODULE)))
USEMODULE += newlib_nano
USEMODULE += newlib_syscalls_fe310
endif
Expand Down
1 change: 1 addition & 0 deletions cpu/fe310/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FEATURES_PROVIDED += arch_32bit
FEATURES_PROVIDED += arch_riscv
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_plic
Expand Down
1 change: 1 addition & 0 deletions cpu/mips32r2_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config CPU_ARCH_MIPS32R2
bool
select HAS_ARCH_32BIT
select HAS_ARCH_MIPS32R2
select HAS_NEWLIB
select HAS_CPP
select HAS_LIBSTDCPP
select HAS_PERIPH_PM
Expand Down
2 changes: 1 addition & 1 deletion cpu/mips32r2_common/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
USEMODULE += mips32r2_common
USEMODULE += mips32r2_common_periph
USEMODULE += newlib

FEATURES_REQUIRED += newlib
# mips32 needs periph_timer for its gettimeofday() implementation
FEATURES_REQUIRED += periph_timer

Expand Down
1 change: 1 addition & 0 deletions cpu/mips32r2_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CPU_ARCH = mips32r2

FEATURES_PROVIDED += arch_32bit
FEATURES_PROVIDED += arch_mips32r2
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += periph_pm
1 change: 1 addition & 0 deletions cpu/msp430_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ config CPU_ARCH_MSP430
select HAS_ARCH_MSP430
select HAS_PERIPH_FLASHPAGE
select HAS_PERIPH_FLASHPAGE_PAGEWISE
select HAS_NEWLIB
select HAS_PERIPH_PM
select MODULE_MALLOC_THREAD_SAFE if TEST_KCONFIG

Expand Down
1 change: 1 addition & 0 deletions cpu/msp430_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CPU_CORE = msp430

FEATURES_PROVIDED += arch_16bit
FEATURES_PROVIDED += arch_msp430
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_flashpage
FEATURES_PROVIDED += periph_flashpage_pagewise
FEATURES_PROVIDED += periph_pm
5 changes: 5 additions & 0 deletions kconfigs/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ config HAS_PICOLIBC
help
Indicates that the picolibc C library is available for the platform.

config HAS_NEWLIB
bool
help
Indicates that the newlib C library is available for the platform.

config HAS_PUF_SRAM
bool
help
Expand Down
10 changes: 10 additions & 0 deletions makefiles/features_modules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,15 @@ ifneq (,$(filter cortexm_mpu,$(FEATURES_USED)))
USEMODULE += mpu_stack_guard
endif

# use picolibc if the feature is used
ifneq (,$(filter picolibc,$(FEATURES_USED)))
USEMODULE += picolibc
endif

# use newlib if the feature is used
ifneq (,$(filter newlib,$(FEATURES_USED)))
USEMODULE += newlib
endif

# use efm32_coretemp if the feature is used
USEMODULE += $(filter efm32_coretemp, $(FEATURES_USED))
4 changes: 2 additions & 2 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,11 @@ ifneq (,$(filter od_string,$(USEMODULE)))
endif

ifneq (,$(filter newlib_gnu_source,$(USEMODULE)))
USEMODULE += newlib
FEATURES_REQUIRED += newlib
endif

ifneq (,$(filter newlib_nano,$(USEMODULE)))
USEMODULE += newlib
FEATURES_REQUIRED += newlib
endif

ifneq (,$(filter newlib,$(USEMODULE)))
Expand Down

0 comments on commit 63a2a6c

Please sign in to comment.