Skip to content

Commit

Permalink
Always enable deterministic_paths (emscripten-core#23256)
Browse files Browse the repository at this point in the history
This removes `deterministic_paths` option by turning it on all the time,
in order to produce reproducible builds, both for `__FILE__` macro and
debug info paths.

This is an alternative to emscripten-core#23212, which did not remove
`deterministic_paths` but always set only `-fmacro-prefix-map` on.

This PR is what was suggested in

emscripten-core#23195 (comment)
and

emscripten-core#23212 (comment).

Fixes emscripten-core#23195.
  • Loading branch information
aheejin authored Jan 2, 2025
1 parent a7dc5cd commit c040578
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def main():
if USE_NINJA:
library.generate()
else:
library.build(deterministic_paths=True)
library.build()
elif what == 'sysroot':
if do_clear:
cache.erase_file('sysroot_install.stamp')
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170928
170950
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
142143
142154
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144730
144741
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
232437
232468
15 changes: 6 additions & 9 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,17 +422,15 @@ def erase(self):
def get_path(self, absolute=False):
return cache.get_lib_name(self.get_filename(), absolute=absolute)

def build(self, deterministic_paths=False):
def build(self):
"""
Gets the cached path of this library.
This will trigger a build if this library is not in the cache.
"""
self.deterministic_paths = deterministic_paths
return cache.get(self.get_path(), self.do_build, force=USE_NINJA == 2, quiet=USE_NINJA)

def generate(self):
self.deterministic_paths = False
return cache.get(self.get_path(), self.do_generate, force=USE_NINJA == 2, quiet=USE_NINJA,
deferred=True)

Expand Down Expand Up @@ -600,12 +598,11 @@ def get_cflags(self):
if self.includes:
cflags += ['-I' + utils.path_from_root(i) for i in self._inherit_list('includes')]

if self.deterministic_paths:
source_dir = utils.path_from_root()
relative_source_dir = os.path.relpath(source_dir, self.build_dir)
cflags += [f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}']
cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}',
f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}']
source_dir = utils.path_from_root()
relative_source_dir = os.path.relpath(source_dir, self.build_dir)
cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}',
f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}',
f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}']
return cflags

def get_base_name_prefix(self):
Expand Down

0 comments on commit c040578

Please sign in to comment.