Build: Add -fmacro-prefix-map
Add the -fmacro-prefix-map argument to the GCC and Clang toolchains.
This argument allows for replacing a fixed string in the filepath which
is placed in the __FILE__ macro. Here, we map the path of the top of the
source tree to nothing, stripping it from all definitions of the macro.
This reduces the size of each file path significantly (although is
directory layout dependant exactly how much is saved) and it also makes
logical sense to avoid placing the home directory layout in the binary
unless necessary.
Note that because this is done with string matching, it will not have an
effect on source files that live outside of the tree (tf-m-tests,
tf-m-extras, etc.). It also does not effect debug information in the elf
file, which will continue to use absolute paths.
Change-Id: If4d3d1b2dd6863198ebd67537b0ec7f9b7c920b7
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
index 3ecb795..7fdfb84 100644
--- a/toolchain_GNUARM.cmake
+++ b/toolchain_GNUARM.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2024, Arm Limited. All rights reserved.
+# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -119,6 +119,7 @@
-fno-builtin
-fshort-enums
-funsigned-char
+ -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=
-mthumb
$<$<COMPILE_LANGUAGE:C>:-std=c99>
$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>