aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-07-25 10:52:12 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-25 10:53:50 -0700
commit3f46dd0f6d5a042fc28d265411a6014f666a40c1 (patch)
tree036accce85c29f38563dbcdbd4fdc5d2d7a5214a /tools
parent24d3a01b53a603059091a690e0bddb20ef5fbc98 (diff)
Add new debug_prefix_map_pwd_is_dot CROSSTOOL feature
This feature sets `-fdebug_prefix_map=$PWD=.` as an argument to Clang in order to standardize the paths to debug symbols (by making them relative to the exec root). Note that this needs to be implemented inside wrapped_clang instead of as an argument to the action itself for caching purposes, as PWD can change based on the action's executor. PiperOrigin-RevId: 206019016
Diffstat (limited to 'tools')
-rw-r--r--tools/osx/crosstool/CROSSTOOL.tpl180
-rw-r--r--tools/osx/crosstool/wrapped_clang.cc18
2 files changed, 192 insertions, 6 deletions
diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl
index 6686ce0e69..0e2964393d 100644
--- a/tools/osx/crosstool/CROSSTOOL.tpl
+++ b/tools/osx/crosstool/CROSSTOOL.tpl
@@ -201,6 +201,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -1830,6 +1848,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -3475,6 +3511,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -5123,6 +5177,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -6798,6 +6870,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -8443,6 +8533,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -10076,6 +10184,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -11712,6 +11838,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -13375,6 +13519,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
@@ -15009,6 +15171,24 @@ toolchain {
}
}
feature {
+ name: "debug_prefix_map_pwd_is_dot"
+ flag_set {
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "linkstamp-compile"
+ action: "objc-compile"
+ action: "objc++-compile"
+ flag_group {
+ flag: "DEBUG_PREFIX_MAP_PWD=."
+ }
+ }
+ }
+ feature {
name: "no_dsym_create_zip"
}
feature {
diff --git a/tools/osx/crosstool/wrapped_clang.cc b/tools/osx/crosstool/wrapped_clang.cc
index 5f283a37fa..25ead4b994 100644
--- a/tools/osx/crosstool/wrapped_clang.cc
+++ b/tools/osx/crosstool/wrapped_clang.cc
@@ -177,6 +177,15 @@ int main(int argc, char *argv[]) {
std::vector<std::string> processed_args = {"/usr/bin/xcrun", tool_name};
std::string linked_binary, dsym_path, dsym_bundle_zip, bitcode_symbol_map;
+ std::string dest_dir;
+
+ std::unique_ptr<char, decltype(std::free) *> cwd{getcwd(nullptr, 0),
+ std::free};
+ if (cwd == nullptr) {
+ std::cerr << "Error determining current working directory\n";
+ abort();
+ }
+
for (int i = 1; i < argc; i++) {
std::string arg(argv[i]);
@@ -196,6 +205,9 @@ int main(int argc, char *argv[]) {
std::ofstream bitcode_symbol_map_file(bitcode_symbol_map);
arg = bitcode_symbol_map;
}
+ if (SetArgIfFlagPresent(arg, "DEBUG_PREFIX_MAP_PWD", &dest_dir)) {
+ arg = "-fdebug-prefix-map=" + std::string(cwd.get()) + "=" + dest_dir;
+ }
FindAndReplace("__BAZEL_XCODE_DEVELOPER_DIR__", developer_dir, &arg);
FindAndReplace("__BAZEL_XCODE_SDKROOT__", sdk_root, &arg);
processed_args.push_back(arg);
@@ -240,12 +252,6 @@ int main(int argc, char *argv[]) {
RunSubProcess(dsymutil_args);
if (dsyms_use_zip_file) {
- std::unique_ptr<char, decltype(std::free) *> cwd{getcwd(nullptr, 0),
- std::free};
- if (cwd == nullptr) {
- std::cerr << "Error determining current working directory\n";
- abort();
- }
std::vector<std::string> zip_args = {
"/usr/bin/zip", "-q", "-r",
std::string(cwd.get()) + "/" + dsym_bundle_zip, "."};