Skip to content

Commit ad696a2

Browse files
committed
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 <built-in>:365: <command line>: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.
1 parent f615920 commit ad696a2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/system_libs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,9 @@ def get_cflags(self):
765765
cflags = super().get_cflags()
766766
if not self.is_debug:
767767
cflags += ['-DNDEBUG']
768+
# To make reproducible builds and the results of code size tests
769+
# consistent, don't embed the actual __FILE__ paths in release builds.
770+
cflags += ['-D__FILE__=""', '-Wno-builtin-macro-redefined']
768771
return cflags
769772

770773
def get_base_name(self):

0 commit comments

Comments
 (0)