Skip to content

Commit

Permalink
Add oso_prefix_is_pwd macOS feature
Browse files Browse the repository at this point in the history
With Xcode 11 Apple's linker introduced a new oso_prefix option which
removes the given prefix from the path in debug info. This improves the
goal of producing reproducible builds.

More info: https://milen.me/writings/apple-linker-ld64-deterministic-builds-oso-prefix

RELNOTES: Add opt in 'oso_prefix_is_pwd' feature for Apple builds

Closes #11671.

PiperOrigin-RevId: 321124428
  • Loading branch information
keith authored and copybara-github committed Jul 14, 2020
1 parent 8953b66 commit 930424b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/osx/crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5451,6 +5451,17 @@ def _impl(ctx):
requires = [feature_set(features = ["opt"])],
)

oso_prefix_feature = feature(
name = "oso_prefix_is_pwd",
flag_sets = [
flag_set(
actions = all_link_actions +
["objc-executable", "objc++-executable"],
flag_groups = [flag_group(flags = ["OSO_PREFIX_MAP_PWD"])],
),
],
)

generate_dsym_file_feature = feature(
name = "generate_dsym_file",
flag_sets = [
Expand Down Expand Up @@ -5782,6 +5793,7 @@ def _impl(ctx):
default_compile_flags_feature,
debug_prefix_map_pwd_is_dot_feature,
generate_dsym_file_feature,
oso_prefix_feature,
contains_objc_source_feature,
objc_actions_feature,
strip_debug_symbols_feature,
Expand Down Expand Up @@ -5853,6 +5865,7 @@ def _impl(ctx):
default_compile_flags_feature,
debug_prefix_map_pwd_is_dot_feature,
generate_dsym_file_feature,
oso_prefix_feature,
contains_objc_source_feature,
objc_actions_feature,
strip_debug_symbols_feature,
Expand Down Expand Up @@ -5926,6 +5939,7 @@ def _impl(ctx):
default_compile_flags_feature,
debug_prefix_map_pwd_is_dot_feature,
generate_dsym_file_feature,
oso_prefix_feature,
contains_objc_source_feature,
objc_actions_feature,
strip_debug_symbols_feature,
Expand Down
3 changes: 3 additions & 0 deletions tools/osx/crosstool/wrapped_clang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ int main(int argc, char *argv[]) {
if (SetArgIfFlagPresent(arg, "DEBUG_PREFIX_MAP_PWD", &dest_dir)) {
arg = "-fdebug-prefix-map=" + std::string(cwd.get()) + "=" + dest_dir;
}
if (arg.compare("OSO_PREFIX_MAP_PWD") == 0) {
arg = "-Wl,-oso_prefix," + std::string(cwd.get()) + "/";
}
FindAndReplace("__BAZEL_XCODE_DEVELOPER_DIR__", developer_dir, &arg);
FindAndReplace("__BAZEL_XCODE_SDKROOT__", sdk_root, &arg);

Expand Down

0 comments on commit 930424b

Please sign in to comment.