From ad696a2f59368e7878466fe75d90d92fbf09309a Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 17 Dec 2024 07:24:03 +0000 Subject: [PATCH] Define __FILE__ as an empty string in release mode This removes all absolute and relative file paths generated by `__FILE__` macro from release build, making the release build reproducible and the results of code size tests consistent. Without `-Wno-builtin-macro-redefined`, the build errors out: ```console In file included from :365: :3:9: error: redefining builtin macro [-Werror,-Wbuiltin-macro-redefined] 3 | #define __FILE__ "" | ^ 1 error generated. ``` The more detailed description on why this is necessary is in #23195. --- tools/system_libs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/system_libs.py b/tools/system_libs.py index e6bbf1c3435b1..7d8de1298bde1 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -765,6 +765,9 @@ def get_cflags(self): cflags = super().get_cflags() if not self.is_debug: cflags += ['-DNDEBUG'] + # To make reproducible builds and the results of code size tests + # consistent, don't embed the actual __FILE__ paths in release builds. + cflags += ['-D__FILE__=""', '-Wno-builtin-macro-redefined'] return cflags def get_base_name(self):