Skip to content

Commit

Permalink
Define __FILE__ as an empty string in release mode
Browse files Browse the repository at this point in the history
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 emscripten-core#23195.
  • Loading branch information
aheejin committed Dec 17, 2024
1 parent f615920 commit ad696a2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ad696a2

Please sign in to comment.