From 165130ef99822ab7c8a8765e7f593522b9faa925 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 4 Nov 2024 12:47:28 -0700 Subject: wip picolibc --- 3rd-party/picolibc.patch | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 3rd-party/picolibc.patch (limited to '3rd-party/picolibc.patch') diff --git a/3rd-party/picolibc.patch b/3rd-party/picolibc.patch new file mode 100644 index 0000000..fdaf59f --- /dev/null +++ b/3rd-party/picolibc.patch @@ -0,0 +1,90 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 391d2360c..a466455a8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -59,7 +59,7 @@ endif() + set(CMAKE_SYSTEM_SUB_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) + + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686" OR +- ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") ++ ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") + set(CMAKE_SYSTEM_PROCESSOR "x86") + endif() + +@@ -512,6 +512,24 @@ CHECK_INCLUDE_FILE(xtensa/config/core-isa.h _XTENSA_HAVE_CONFIG_CORE_ISA_H) + + configure_file(picolibc.h.in "${PICOLIBC_INCLUDE}/picolibc.h") + ++set(DEFAULT_FLASH_ADDR 0x00000000) ++set(DEFAULT_FLASH_SIZE 0x00400000) ++set(DEFAULT_RAM_ADDR 0x20000000) ++set(DEFAULT_RAM_SIZE 0x00200000) ++set(DEFAULT_STACK_SIZE 0x00001000) ++set(DEFAULT_ALIGNMENT 8) ++ ++set(BFD_START "") ++set(BFD_END "") ++set(LLD_START "/* For ld.lld: ") ++set(LLD_END "*/") ++set(TLS_PHDRS "tls_init PT_TLS; ++tls PT_TLS;") ++set(TLS_INIT_SEG "tls_init") ++ ++configure_file(picolibc.ld.in "${PROJECT_BINARY_DIR}/picolibc.ld" @ONLY) ++set(PICOLIBC_LD "${PROJECT_BINARY_DIR}/picolibc.ld") ++ + set(INCLUDEDIR include) + set(LIBDIR .) + if(PICOLIBC_TLS) +@@ -524,7 +542,8 @@ set(ADDITIONAL_LIBS "") + set(SPECS_EXTRA "") + set(SPECS_ISYSTEM "-isystem ${PROJECT_BINARY_DIR}/${include}") + set(SPECS_LIBPATH "-L${PROJECT_BINARY_DIR}") +-set(SPECS_STARTFILE "${PROJECT_BINARY_DIR}/crt0.o") ++set(SPECS_STARTFILE "@SPECS_STARTFILE@") ++ + string(APPEND SPECS_PRINTF "%{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfprintf=__f_vfprintf}" + " %{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfscanf=__f_vfscanf}" + " %{DPICOLIBC_DOUBLE_PRINTF_SCANF:--defsym=vfprintf=__d_vfprintf}" +@@ -536,7 +555,13 @@ string(APPEND SPECS_PRINTF "%{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfprintf=__f + ) + set(PREFIX "${PROJECT_BINARY_DIR}") + +-configure_file(picolibc.specs.in "${PROJECT_BINARY_DIR}/picolibc.specs" @ONLY) ++configure_file(picolibc.specs.in "${PROJECT_BINARY_DIR}/picolibc.specs.in2" @ONLY) ++ ++add_custom_command( ++ OUTPUT "${PROJECT_BINARY_DIR}/picolibc.specs" ++ DEPENDS "${PROJECT_BINARY_DIR}/picolibc.specs.in2" picocrt ++ COMMAND sed "s,@SPECS_STARTFILE@,$,g" <"${PROJECT_BINARY_DIR}/picolibc.specs.in2" >"${PROJECT_BINARY_DIR}/picolibc.specs" ++) + + set(PICOLIBC_COMPILE_OPTIONS + "-nostdlib" +@@ -571,7 +596,8 @@ picolibc_supported_compile_options( + "-fsignaling-nans" + ) + +-add_library(c STATIC) ++add_library(c STATIC ++ "${PROJECT_BINARY_DIR}/picolibc.specs") + + target_compile_options(c PRIVATE ${PICOLIBC_COMPILE_OPTIONS}) + +@@ -586,6 +612,8 @@ define_property(GLOBAL PROPERTY PICOLIBC_HEADERS + + add_subdirectory(newlib) + ++add_subdirectory(picocrt) ++ + install(TARGETS c + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include) +@@ -597,7 +625,6 @@ if(TESTS) + # semihosting-based tests + + add_subdirectory(semihost) +- add_subdirectory(picocrt) + + set(PICOCRT_OBJ $) + set(PICOCRT_SEMIHOST_OBJ $) -- cgit v1.2.3-2-g168b