summaryrefslogtreecommitdiff
path: root/3rd-party/picolibc.patch
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-04 12:47:28 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-04 12:47:28 -0700
commit165130ef99822ab7c8a8765e7f593522b9faa925 (patch)
tree2bb00d89d9a80cb0f8369965cc60a1a0d8b38bb2 /3rd-party/picolibc.patch
parent29f9994856f1f56c40e9c54ec5e8f29ba8d3387e (diff)
wip picolibclukeshu/picolibc
Diffstat (limited to '3rd-party/picolibc.patch')
-rw-r--r--3rd-party/picolibc.patch90
1 files changed, 90 insertions, 0 deletions
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@,$<TARGET_OBJECTS:picocrt>,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 $<TARGET_OBJECTS:picocrt>)
+ set(PICOCRT_SEMIHOST_OBJ $<TARGET_OBJECTS:picocrt-semihost>)