diff options
author | Keith Short <keithshort@chromium.org> | 2022-07-27 16:14:55 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-01 16:21:46 +0000 |
commit | 094eddd5e0b92d63c79d6e357f2d1e61c5009553 (patch) | |
tree | 404594b96dfbd255428bd551493f8b96f30362e4 | |
parent | aac009a814a63a6002d95d47b313b0acfe77b2ed (diff) | |
download | chrome-ec-094eddd5e0b92d63c79d6e357f2d1e61c5009553.tar.gz |
zephyr: Replace full paths in assert output
Use the compiler option "-fmacro-prefix-map" to replace the full
filenames generated by the __file__ preprocessor macro with a hard-coded
string. This generates a more deterministic build when asserts are
enabled.
BUG=none
BRANCH=none
TEST=zmake build npcx7. This target enables CONFIG_ASSERT. Confirm that
the filepaths in the output binary use the "EC_BASE" prefix.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I00347df316f888043e535778370647d7638deee9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791658
Reviewed-by: Al Semjonovs <asemjonovs@google.com>
-rw-r--r-- | zephyr/CMakeLists.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 7412e14117..da8df63e14 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -29,6 +29,19 @@ if(DEFINED ZMAKE_INCLUDE_DIR) zephyr_include_directories("${ZMAKE_INCLUDE_DIR}") endif() +# When CONFIG_ASSERT is enabled, the __FILE__ macro may add full paths into the +# read-only strings. This wastes space and can cause non-reproducible builds. +# When the compiler supports it, replace common path prefixes with static +# strings. + +# PLATFORM_EC points to the build directory, which symlinks to the actual +# source. ZEPHYR_CURRENT_CMAKE_DIR points to the actual source directory +# containing this file. Set the PLATFORM_EC_SRC to the parent. +# Replace the paths of the both the build and source directories with "EC_BASE". +cmake_path(GET ZEPHYR_CURRENT_CMAKE_DIR PARENT_PATH PLATFORM_EC_SRC) +zephyr_cc_option(-fmacro-prefix-map=${PLATFORM_EC}=EC_BASE) +zephyr_cc_option(-fmacro-prefix-map=${PLATFORM_EC_SRC}=EC_BASE) + if(DEFINED CONFIG_PLATFORM_EC) # Add CHROMIUM_EC definition, which is used by ec_commands.h to # determine that the header is being compiled for the EC instead of |