aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGyorgy Szing <Gyorgy.Szing@arm.com>2022-09-15 15:13:35 +0200
committerGyörgy Szing <gyorgy.szing@arm.com>2022-10-13 10:54:40 +0200
commitc734111452fa264e0b4a8aefbeced4aebd46b9cb (patch)
tree4d8c532f07df3997af39fa495294948f22fa2b72
parent3d4956770f89eb9ae0a73257901ae6277c078da6 (diff)
downloadtrusted-services-c734111452fa264e0b4a8aefbeced4aebd46b9cb.tar.gz
Fix newlib build issue if using pre-fetched source
Newlib stores object and build configuration files in its source tree. When different deployments rebuild newlib, sometimes a configuration error is reported by newlib build system. To avoid this error "distclean" is run before building newlib. Change-Id: Ifcef73744c121584dbe8db3998ced9636c3cc5d4 Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
-rw-r--r--external/newlib/newlib.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/external/newlib/newlib.cmake b/external/newlib/newlib.cmake
index 3ef610711..b1884be20 100644
--- a/external/newlib/newlib.cmake
+++ b/external/newlib/newlib.cmake
@@ -161,6 +161,21 @@ if (NOT NEWLIB_LIBC_PATH)
# Get extra external CFLAGS for host from environment
set(NEWLIB_CFLAGS $ENV{NEWLIB_CFLAGS} CACHE STRING "")
+ # Newlib is keeping build artifacts in the source directory. If the source is pre-fetched,
+ # intermediate files of previoud build migth be still present.
+ # Run distclean to avoid build errors due to reconfiguration.
+ execute_process(COMMAND
+ ${CMAKE_COMMAND} -E env --unset=CC PATH=${COMPILER_PATH}:$ENV{PATH}
+ make -j${PROCESSOR_COUNT} distclean
+ WORKING_DIRECTORY
+ ${NEWLIB_SOURCE_DIR}
+ RESULT_VARIABLE _newlib_error
+ )
+ #ignore error as distclean-host is failing.
+ #if (_newlib_error)
+ # message(FATAL_ERROR "\"distclean\" step of newlib failed with ${_newlib_error}.")
+ #endif()
+
# Newlib configure step
# CC env var must be unset otherwise configure will assume the cross compiler is the host
# compiler.