zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.05k stars 6.18k forks source link

OOT board fails to build after going from v3.5.0 to v3.7.0 #75286

Closed ycsin closed 2 days ago

ycsin commented 6 days ago

Describe the bug I encountered the following compilation error while testing build on v3.7.0 for OOT boards.

are/zephyr/__sources-3.7.0__/out/zephyr/subsys/debug/symtab/symtab_stub.c
riscv64-unknown-elf-gcc: fatal error: cannot read spec file 'picolibc.specs': No such file or directory
compilation terminated.
ninja: build stopped: subcommand failed.

This didn't happen in v3.5.0.

There's a similar report in the #cpp channel in our discord server, but I'm not sure what board they used.

https://discord.com/channels/720317445772017664/883444430676324382/1255783684322230282

Screenshot 2024-07-02 at 12 17 29 AM

Report from the user:

NCS - HEAD detached at v2.7.0-rc3
Zephyr - HEAD detached at 3e80418dd59

WSL2

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy

CMake

-DBOARD=native_sim
- CMake version: 3.28.1
-- Cache files will be written to: /home/dev/.cache/zephyr
-- Zephyr version: 3.6.99 (/home/dev/ncs/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: native_sim, qualifiers: native
-- Found host-tools: zephyr 0.16.8 (/home/dev/zephyr-sdk-0.16.8)
-- Found toolchain: host (gcc/ld)
CONFIG_CPP=y
CONFIG_GLIBCXX_LIBCPP=y
CONFIG_POSIX_API=y
CONFIG_PICOLIBC=y

Please also mention any information which could help others to understand the problem you're facing:

To Reproduce Probably not easy to reproduce with upstream SDK.

Expected behavior I'm expecting my application to build on v3.7.0

Impact OOT board/soc/application doesn't build on v3.7.0

Environment (please complete the following information):

Root cause The cause of the issue that I've encountered is due to PICOLIBC getting selected

https://github.com/zephyrproject-rtos/zephyr/blob/cac70373aa81b9989905ac530b9773e4b748e409/lib/libc/Kconfig#L60-L65

instead of yielding to the next default even though the build env doesn't have the source for it (OOT application may not be using Zephyr SDK + the PICOLIBC module).

This issue can be worked-around for users going from 2.7 LTS to 3.7 LTS by explicitly selecting the minimal libc (CONFIG_MINIMAL_LIBC=y)

Log

stdout:
[1/215] Preparing syscall dependency handling

[2/215] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.0-rc1 (/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr), build: 3.7.0-fb
[3/215] Generating misc/generated/syscalls_subdirs.trigger
[4/215] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
[5/215] Generating include/generated/zephyr/syscall_dispatch.c, include/generated/zephyr/syscall_list.h
[6/215] Generating include/generated/zephyr/driver-validation.h
[7/215] Generating include/generated/zephyr/kobj-types-enum.h, include/generated/zephyr/otype-to-str.h, include/generated/zephyr/otype-to-size.h
[8/215] Building C object zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj
FAILED: zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj 
/mnt/infra-asic-riscv64-toolchain-20230823/bin/riscv64-unknown-elf-gcc -DKERNEL -DK_HEAP_MEM_POOL_SIZE=10240 -DPICOLIBC_DOUBLE_PRINTF_SCANF -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/kernel/include -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/arch/riscv/include -Izephyr/include/generated/zephyr -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include -Izephyr/include/generated -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include/zephyr/posix -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/lib/posix/options/getopt -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/soc/common/riscv-privileged/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia/riscv_board/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia/riscv_board/../meta-common -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/tracing/include -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/tracing/user/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/include -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/lib/benchmark/sub_cmds/.. -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/testsuite/include -I/data/users/ycsin/firmware/zephyr/modules/hal/mtia_gen/__mtia_gen__/out/mtia_gen/include -isystem /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/lib/libc/common/include -fno-strict-aliasing -Os -imacros /data/users/ycsin/firmware/zephyr/__riscv_board-latest-cmake__/out/facebook/configs/riscv_board/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcmodel=medany -mabi=lp64d -march=rv64imafdc_zicsr_zifencei --sysroot=/mnt/infra-asic-riscv64-toolchain-20230823/riscv64-unknown-elf -imacros /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/facebook/configs/riscv_board=CMAKE_SOURCE_DIR -fmacro-prefix-map=/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr=ZEPHYR_BASE -ffunction-sections -fdata-sections --specs=picolibc.specs -D_POSIX_THREADS -mexplicit-relocs -std=c99 -fno-lto -MD -MT zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj -MF zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj.d -o zephyr/CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj -c /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/arch/riscv/core/offsets/offsets.c
riscv64-unknown-elf-gcc: fatal error: cannot read spec file 'picolibc.specs': No such file or directory
compilation terminated.
[9/215] Building C object zephyr/subsys/debug/symtab/CMakeFiles/symtab.dir/symtab_stub.c.obj
FAILED: zephyr/subsys/debug/symtab/CMakeFiles/symtab.dir/symtab_stub.c.obj 
/mnt/infra-asic-riscv64-toolchain-20230823/bin/riscv64-unknown-elf-gcc -DKERNEL -DK_HEAP_MEM_POOL_SIZE=10240 -DPICOLIBC_DOUBLE_PRINTF_SCANF -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -Izephyr/include/generated/zephyr -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include -Izephyr/include/generated -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include/zephyr/posix -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/lib/posix/options/getopt -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/soc/common/riscv-privileged/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia/riscv_board/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/soc/meta/mtia/riscv_board/../meta-common -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/arch/riscv/include -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/kernel/include -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/tracing/include -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/tracing/user/. -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/include -I/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/lib/benchmark/sub_cmds/.. -I/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/testsuite/include -I/data/users/ycsin/firmware/zephyr/modules/hal/mtia_gen/__mtia_gen__/out/mtia_gen/include -isystem /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/lib/libc/common/include -Wshadow -fno-strict-aliasing -Os -imacros /data/users/ycsin/firmware/zephyr/__riscv_board-latest-cmake__/out/facebook/configs/riscv_board/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcmodel=medany -mabi=lp64d -march=rv64imafdc_zicsr_zifencei --sysroot=/mnt/infra-asic-riscv64-toolchain-20230823/riscv64-unknown-elf -imacros /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/data/users/ycsin/firmware/zephyr/modules/meta_asic_latest/__meta_asic_latest__/meta_asic_latest/facebook/configs/riscv_board=CMAKE_SOURCE_DIR -fmacro-prefix-map=/data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr=ZEPHYR_BASE -ffunction-sections -fdata-sections --specs=picolibc.specs -D_POSIX_THREADS -mexplicit-relocs -std=c99 -MD -MT zephyr/subsys/debug/symtab/CMakeFiles/symtab.dir/symtab_stub.c.obj -MF zephyr/subsys/debug/symtab/CMakeFiles/symtab.dir/symtab_stub.c.obj.d -o zephyr/subsys/debug/symtab/CMakeFiles/symtab.dir/symtab_stub.c.obj -c /data/users/ycsin/firmware/zephyr/__sources-3.7.0__/out/zephyr/subsys/debug/symtab/symtab_stub.c
riscv64-unknown-elf-gcc: fatal error: cannot read spec file 'picolibc.specs': No such file or directory
compilation terminated.
ninja: build stopped: subcommand failed.
ycsin commented 6 days ago

cc @keith-packard @stephanosio, LMK if you need more info, but it's a OOT board + SOC with a custom compiler so I can only try my best 🥲

keith-packard commented 6 days ago

It looks like this is using the host compiler (see the reference to /usr/bin/gcc) with cross-compilation flags (including -ffreestanding -fno-builtin --specs=picolibc.specs) to preprocess something (-E). I can't see what it's trying to do beyond that from the included image.

ycsin commented 6 days ago

I can't see what it's trying to do beyond that from the included image.

Updated OP with my compilation logs, could you please take another look?

This is basically what I get after I updated my OOT board to use the HWMv2 on the 3.7.0-rc1

keith-packard commented 5 days ago

You're not using the Zephyr SDK? If not, you'll need to make sure to CONFIG_PICOLIBC_USE_MODULE=y, which is not the default. If that doesn't work, then there's something messed up with the construction of the compiler flags for that particular compilation step.