-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When bazel executions actions in the sandbox, pwd is a path like this: ``` /private/var/tmp/_bazel_ksmiley/92410d0e3373f265902564b48493ac12/sandbox/darwin-sandbox/8/execroot/_main ``` Inside this directory are the inputs, which are symlinks to outside of this pwd: ``` /private/var/tmp/_bazel_ksmiley/92410d0e3373f265902564b48493ac12/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-dbg/bin/_objs/main/main.o -> /private/var/tmp/_bazel_ksmiley/92410d0e3373f265902564b48493ac12/execroot/_main/bazel-out/darwin_arm64-dbg/bin/_objs/main/main.o ``` ld64 resolves the absolute path to this object file, including resolving symlinks, _before_ it strips the -oso_prefix argument. Because of this the previous `__BAZEL_EXECUTION_ROOT__` replacement, which was the sandbox pwd, isn't actually a prefix of the canonicalized object file path, leading to -oso_prefix being a no-op, and absolute paths ending up in the binary. I think many folks didn't see this locally because it's common for Apple projects to disable sandboxing for local development for perf reasons, and that's when you're likely to have this debug info in the binary in the first place. With this change we add a new substitution that calculates the sandbox-independent prefix and passes that along instead.
- Loading branch information
Showing
6 changed files
with
70 additions
and
10 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,10 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
readonly binary="%{binary}s" | ||
|
||
# [ 51] 00001016 66 (N_OSO ) 00 0001 0000000000000000 'bazel-out/darwin_arm64-dbg-macos-arm64-min13.0-applebin_macos-ST-659b080861c8/bin/test/test_data/libcc_main.a(main.o)' | ||
output=$(dsymutil -s "$binary" | grep N_OSO) | ||
echo "$output" | grep " 'bazel-out" \ | ||
|| (echo "has non-relative N_OSO entries: $output" >&2 && exit 1) |
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