Skip to content

Commit 5c092c4

Browse files
authored
Don't use cp -c if src and dst are on different devices when copying dSYMs (#2766)
dSYMs are currently copied using `cp -cp` on MacOS, which means MacOS will use clonefile(). While this optimizes speed and storage, this will also fail if src and dst are not on the same filesystem. This will typically happen if the sandbox and bazel-out are on different filesystems.
1 parent 0158abf commit 5c092c4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

apple/internal/partials/debug_symbols.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,14 @@ def _generate_dsym_binaries(
150150
mnemonic = "DsymDwarf",
151151
progress_message = "Copy DWARF into dSYM `%s`" % dsym_binary.short_path,
152152
command = """
153-
if [[ $OSTYPE == darwin* ]]; then
153+
# Only use `-c` if we're on Darwin and src and dst are on the same filesystem
154+
if [[ $OSTYPE == darwin* && $(stat -f "%d" {src}) == $(stat -f "%d" $(dirname {dst})) ]]; then
154155
readonly flags='-cp'
155156
else
156157
readonly flags='-p'
157158
fi
158-
cp $flags '%s' '%s'
159-
""" % (dsym_binary.path, output_binary.path),
159+
cp $flags "{src}" "{dst}"
160+
""".format(src = dsym_binary.path, dst = output_binary.path),
160161
)
161162
else:
162163
lipo.create(

0 commit comments

Comments
 (0)