From c040578295262568c23fcf8d666ec6bcb4ec63ca Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Thu, 2 Jan 2025 13:40:40 -0800 Subject: [PATCH] Always enable deterministic_paths (#23256) 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 #23212, which did not remove `deterministic_paths` but always set only `-fmacro-prefix-map` on. This PR is what was suggested in https://github.com/emscripten-core/emscripten/issues/23195#issuecomment-2549861247 and https://github.com/emscripten-core/emscripten/pull/23212#discussion_r1891058881. Fixes #23195. --- embuilder.py | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- .../codesize/test_codesize_cxx_except_wasm.size | 2 +- .../test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- tools/system_libs.py | 15 ++++++--------- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/embuilder.py b/embuilder.py index 4b706c1d6df76..af634eea12d13 100755 --- a/embuilder.py +++ b/embuilder.py @@ -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') diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index c2c735ee85f4b..f802ede453a94 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -170928 +170950 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index e5a548bdc8852..dcc00991302e1 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142143 +142154 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index b3e5808388b4f..61de9cf43ee1e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -144730 +144741 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index d7b5814d237cc..6c8a3c4a397f0 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232437 +232468 diff --git a/tools/system_libs.py b/tools/system_libs.py index ef896f6ec96ac..25ec00099e735 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -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) @@ -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):