blob: a9d291b4e11c1e3f34c93eaa0426e4a4dda41b33 [file] [log] [blame]
From df66efc0db9899c41632091db11bfe2c05eec1fa Mon Sep 17 00:00:00 2001
From: Anton Antonov <Anton.Antonov@arm.com>
Date: Wed, 31 Aug 2022 17:55:21 +0100
Subject: [PATCH] Allow to define additional partameters for newlib configure.
Do not skip newlib and libgloss when crosscompiling
Upstream-Status: Pending
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
...-aarch64-linux-gcc-to-compile-bare-metal-lib.patch | 11 ++++++++++-
external/newlib/newlib.cmake | 6 ++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/external/newlib/0001-Allow-aarch64-linux-gcc-to-compile-bare-metal-lib.patch b/external/newlib/0001-Allow-aarch64-linux-gcc-to-compile-bare-metal-lib.patch
index f87ed5a..7533ed0 100644
--- a/external/newlib/0001-Allow-aarch64-linux-gcc-to-compile-bare-metal-lib.patch
+++ b/external/newlib/0001-Allow-aarch64-linux-gcc-to-compile-bare-metal-lib.patch
@@ -16,9 +16,18 @@ Signed-off-by: Gyorgy Szing <gyorgy.szing@arm.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
-index 5db52701..1eb71a80 100755
+index 5db527014..dce91609e 100755
--- a/configure
+++ b/configure
+@@ -2886,7 +2886,7 @@ esac
+
+ # Some are only suitable for cross toolchains.
+ # Remove these if host=target.
+-cross_only="target-libgloss target-newlib target-opcodes"
++cross_only="target-opcodes"
+
+ case $is_cross_compiler in
+ no) skipdirs="${skipdirs} ${cross_only}" ;;
@@ -3659,7 +3659,7 @@ case "${target}" in
*-*-freebsd*)
noconfigdirs="$noconfigdirs target-newlib target-libgloss"
diff --git a/external/newlib/newlib.cmake b/external/newlib/newlib.cmake
index 13eb78c..5ee99a5 100644
--- a/external/newlib/newlib.cmake
+++ b/external/newlib/newlib.cmake
@@ -168,6 +168,10 @@ if (NOT NEWLIB_LIBC_PATH)
string(REPLACE ";" " -isystem " CFLAGS_FOR_TARGET "${_gcc_include_dirs}")
set(CFLAGS_FOR_TARGET "-isystem ${CFLAGS_FOR_TARGET} -fpic")
+ # Split a newlib extra build parameter into a list of parameters
+ set(NEWLIB_EXTRAS ${NEWLIB_EXTRA})
+ separate_arguments(NEWLIB_EXTRAS)
+
# Newlib configure step
# CC env var must be unset otherwise configure will assume the cross compiler is the host
# compiler.
@@ -175,6 +179,7 @@ if (NOT NEWLIB_LIBC_PATH)
execute_process(COMMAND
${CMAKE_COMMAND} -E env --unset=CC PATH=${COMPILER_PATH}:$ENV{PATH} ./configure
--target=${COMPILER_PREFIX}
+ --host=${COMPILER_PREFIX}
--prefix=${NEWLIB_INSTALL_DIR}
--enable-newlib-nano-formatted-io
--enable-newlib-nano-malloc
@@ -182,6 +187,7 @@ if (NOT NEWLIB_LIBC_PATH)
--enable-newlib-reent-small
--enable-newlib-global-atexit
--disable-multilib
+ ${NEWLIB_EXTRAS}
CFLAGS_FOR_TARGET=${CFLAGS_FOR_TARGET}
LDFLAGS_FOR_TARGET=-fpie
WORKING_DIRECTORY
--
2.25.1