Skip to content

Commit cf07fdd

Browse files
committed
Request cloning using COPYFILE_CLONE
1 parent ee11d3f commit cf07fdd

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

tools/common/file_system.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ bool CopyFile(const std::string &src, const std::string &dest) {
3333
#ifdef __APPLE__
3434
// The `copyfile` function with `COPYFILE_ALL` mode preserves permissions and
3535
// modification time.
36-
return copyfile(src.c_str(), dest.c_str(), nullptr, COPYFILE_ALL) == 0;
36+
return copyfile(src.c_str(), dest.c_str(), nullptr,
37+
COPYFILE_ALL | COPYFILE_CLONE) == 0;
3738
#elif __unix__
3839
// On Linux, we can use `sendfile` to copy it more easily than calling
3940
// `read`/`write` in a loop.

tools/worker/work_processor.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ void WorkProcessor::ProcessWorkRequest(
160160
if (!is_wmo) {
161161
// Copy the output files from the incremental storage area back to the
162162
// locations where Bazel declared the files.
163-
// TODO(allevato): Investigate copy-on-write on macOS, or hard-linking in
164-
// general, as a possible optimization.
165163
for (auto expected_object_pair : output_file_map.incremental_outputs()) {
166164
if (!CopyFile(expected_object_pair.second, expected_object_pair.first)) {
167165
std::cerr << "Could not copy " << expected_object_pair.second << " to "

0 commit comments

Comments
 (0)