Skip to content

Commit 5da56b4

Browse files
committed
Use CIRCLRCI environment variable
When `__FILE__` macro is in code, this produces different paths in different environments, making the builds not reproducible. We use `-ffile-prefix-map` to avoid this problem but only when `deterministic_paths` is True: https://github.com/emscripten-core/emscripten/blob/d5c419f8aa428bc3d1d071d23227dd13a00b463c/tools/system_libs.py#L495-L501 which is set to True when embuilder is used in non-`USE_NINJA` mode: https://github.com/emscripten-core/emscripten/blob/1171adaa21048ba8dc82169b9d79952e8754b201/embuilder.py#L296 The rationale for this seems to be that we sometimes want correct absolute paths when we debug and test programs locally. But CircleCI runs several code size tests and if the those tests contain objects with `__FILE__` macro, the code sizes in those tests can be different in different CircleCI bots. This uses the environment variable `CIRCLECI`, which is True when we are in CircleCI bots, to decide whether we need to set `deterministic_paths`. This was prompted due to a recent change in libc++abi: https://github.com/llvm/llvm-project/blob/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxxabi/src/abort_message.h#L22 This `__FILE__` ends up being used from `other.test_minimal_runtime_code_size_hello_embind`, making the test's result different in different bots. But this can happen in other places and it is generally better to produce reproducible builds in CirclrCI bots anyway.
1 parent 978ac9b commit 5da56b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/system_libs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# Setting EMCC_USE_NINJA=2 means that ninja will automatically be run for each library needed at
4242
# link time.
4343
USE_NINJA = int(os.environ.get('EMCC_USE_NINJA', '0'))
44+
CIRCLECI = bool(os.environ.get('CIRCLECI', False))
4445

4546

4647
def files_in_path(path, filenames):
@@ -438,7 +439,7 @@ def get_link_flag(self):
438439
439440
This will trigger a build if this library is not in the cache.
440441
"""
441-
fullpath = self.build()
442+
fullpath = self.build(CIRCLECI)
442443
# For non-libraries (e.g. crt1.o) we pass the entire path to the linker
443444
if self.get_ext() != '.a':
444445
return fullpath

0 commit comments

Comments
 (0)