Skip to content

Commit a11db2e

Browse files
committed
Zephyr 3.7 support. Drop older 3.x
Issues with 3.x prior to 3.7: picolibc: I was not able to get Kconfig to build picolibc from source in a way that was compatible with both 3.7 and prior versions of 3.x due to Zephyr changing PICOLIBC_USE_MODULE from a bool to a choice. Setting options in each prj.conf also doesn't work because it generates warnings for undefined symbols in older versions. If there were some way to have version-conditional behavior in Kconfig, that would make it possible to bring back older 3.x compat. ctors: zephyr-macros uses ctors to run init code. This required setting CONFIG_CPLUSPLUS. That has been deprecated and removed in 3.7, but there is now a separate option, CONFIG_STATIC_INIT_GNU, that runs ctors. TOOLCHAIN_SUPPORTS_STATIC_INIT_GNU happened to be added in the same commit, so we can use this to distinguish between setting CPLUSPLUS on 2.x and STATIC_INIT_GNU on 3.7. Prior to 3.7, STATIC_INIT_GNU does not exist and CPLUSPLUS conflicts with PICOLIBC_USE_MODULE. It might be possible to avoid this mess by not relying on C++ ctors.
1 parent 5c93c46 commit a11db2e

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

.github/workflows/main.yml

+4-16
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,24 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
zephyr_version: [3.6.0, 3.5.0, 3.4.0, 2.7.3, 2.3.0]
15+
zephyr_version: [3.7.0, 2.7.3, 2.3.0]
1616
board: [qemu_x86, qemu_cortex_m3, qemu_cortex_r5, nucleo_l552ze_q, native_posix, qemu_riscv32, qemu_riscv64]
1717
test: [samples/rust-app, samples/no_std, samples/serial]
1818
exclude:
1919
- board: qemu_riscv32
2020
zephyr_version: 2.3.0
2121
- board: qemu_riscv64
2222
zephyr_version: 2.3.0
23-
- board: qemu_riscv32
24-
zephyr_version: 2.4.0
25-
- board: qemu_riscv64
26-
zephyr_version: 2.4.0
27-
- board: qemu_riscv32
28-
zephyr_version: 2.5.0
29-
- board: qemu_riscv64
30-
zephyr_version: 2.5.0
31-
- board: qemu_riscv32
32-
zephyr_version: 2.6.0
33-
- board: qemu_riscv64
34-
zephyr_version: 2.6.0
3523
- board: qemu_riscv32
3624
zephyr_version: 2.7.3
3725
- board: qemu_riscv64
3826
zephyr_version: 2.7.3
27+
# serial/uart does not exist on posix
3928
- board: native_posix
4029
test: samples/serial
30+
# posix has header issues on Zephyr 3.x
4131
- board: native_posix
42-
zephyr_version: 3.5.0
43-
- board: native_posix
44-
zephyr_version: 3.6.0
32+
zephyr_version: 3.7.0
4533
include:
4634
- fails: false
4735
- run: false

Kconfig

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
menuconfig RUST
22
bool "Rust"
33
select THREAD_CUSTOM_DATA
4-
select CPLUSPLUS
5-
select PICOLIBC_USE_MODULE if PICOLIBC
4+
# Static initializers for Zephyr >=3.7
5+
select STATIC_INIT_GNU if TOOLCHAIN_SUPPORTS_STATIC_INIT_GNU
6+
# Static initializers for Zephyr 2.x
7+
select CPLUSPLUS if !TOOLCHAIN_SUPPORTS_STATIC_INIT_GNU
68
help
79
Rust language support.
810

911
if RUST
12+
13+
# Define this choice to use PICOLIBC_USE_MODULE on 3.7 and be compatible with 2.x
14+
# This breaks older 3.x versions because PICOLIBC_SOURCE is not a choice there
15+
# It is not possible to use 'select' with a 'choice'
16+
choice PICOLIBC_SOURCE
17+
prompt "Source of Picolibc"
18+
default PICOLIBC_USE_MODULE
19+
20+
config PICOLIBC_USE_MODULE
21+
bool "Picolibc from module"
22+
endchoice
23+
1024
choice RUST_GLOBAL_ALLOCATOR
1125
prompt "Rust global allocator"
1226
default RUST_ALLOC_POOL if USERSPACE

0 commit comments

Comments
 (0)