-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add -ffile-prefix-map for deterministic C++ compilation
Summary: Previously, with some toolchains, the debuginfo in object files produced by `cxx_compile` actions contained absolute paths for headers in the toolchain's standard library. This affected xplat's `minimal_xcode` toolchain. Different macOS RE runners do not necessarily all put the current directory in the same location when running actions, which introduced nondeterminism and wrecks cache utilization. Reviewed By: rmaz Differential Revision: D60678938 fbshipit-source-id: a8bfab64d39571a3bd5e7b3fb4ae16a977a7c3cf
- Loading branch information
1 parent
b70b171
commit e27ef6c
Showing
5 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
""" | ||
Usage: remap_cwd.py path/to/clang++ [args...] | ||
Runs `path/to/clang++ -ffile-prefix-map=$PWD= [args...]` | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
if __name__ == "__main__": | ||
cwd = os.getcwd() | ||
# Add trailing slash | ||
cwd = os.path.join(cwd, "") | ||
|
||
ret = subprocess.call( | ||
[ | ||
sys.argv[1], | ||
f"-ffile-prefix-map={cwd}=", | ||
*sys.argv[2:], | ||
], | ||
) | ||
sys.exit(ret) |