finetuning: now it is working also with picolibc

This commit is contained in:
Hardy Griech 2025-10-15 18:48:30 +02:00
parent 571d2eda94
commit 4a775eedfd
4 changed files with 53 additions and 5 deletions

View file

@ -99,10 +99,15 @@ if (NOT PICO_COMPILER_SYSROOT)
message(FATAL_ERROR "Could not find an llvm runtime for '${PICO_CLANG_RUNTIME}'")
endif()
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} --sysroot ${PICO_COMPILER_SYSROOT}")
# llvmlibc / newlib
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -isystem ${PICO_COMPILER_SYSROOT}/../include/c++/v1")
# llvmlibc / newlib
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -isystem ${PICO_COMPILER_SYSROOT}/../include")
# add some system includes due to structure of ATfE-21.1.1 header structure
# required for llvmlibc / newlib, NOT for picolibc
if(EXISTS "${PICO_COMPILER_SYSROOT}/../include/c++/v1")
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -isystem ${PICO_COMPILER_SYSROOT}/../include/c++/v1")
endif()
if(EXISTS "${PICO_COMPILER_SYSROOT}/../include")
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -isystem ${PICO_COMPILER_SYSROOT}/../include")
endif()
# moving this here as a reminder from pico_standard_link; it was commented out theee, but if ever needed,
# it belongs here as part of LINKER_FLAGS_INIT

View file

@ -101,7 +101,14 @@ cc_library(
# For now, picolibc doesn't need to provide any headers.
alias(
name = "picolibc_interface",
actual = "//bazel:empty_cc_lib",
hdrs = [
"include/picolibc/sys/cdefs.h",
],
includes = ["include/picolibc"],
# It's hard to properly constrain compatibility since `auto` may select this,
# so just tag as manual.
tags = ["manual"],
target_compatible_with = compatible_with_rp2(),
)
cc_library(

View file

@ -21,6 +21,10 @@ if (NOT TARGET pico_clib_interface)
# PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS=0
#)
target_include_directories(pico_picolibc_interface SYSTEM INTERFACE
${CMAKE_CURRENT_LIST_DIR}/include/picolibc
)
# ---- llvm_libc ----
pico_add_library(pico_llvm_libc_interface)

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __PICO_PICOLIBC_SYS_CDEFS_H
#define __PICO_PICOLIBC_SYS_CDEFS_H
#if defined(__STDC__) || defined(__cplusplus)
#define __CONCAT1(x,y) x ## y
#define __CONCAT(x,y) __CONCAT1(x,y)
#define __STRING(x) #x
#define __XSTRING(x) __STRING(x)
#endif
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
#define __packed __attribute__((__packed__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __always_inline __inline__ __attribute__((__always_inline__))
#define __noinline __attribute__((__noinline__))
#define __printflike(fmtarg, firstvararg) \
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#include_next <sys/cdefs.h>
#endif