diff options
author | Googler <noreply@google.com> | 2018-07-10 08:57:30 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-10 08:58:41 -0700 |
commit | ecab1c8680f2eece7ff5a46860c768c6738e3467 (patch) | |
tree | 0d4a2a045d8db54fc8b406c5a7b65710e4d68da7 | |
parent | 76b6f20130f9bfd70132cbeb84799c5e21b8912e (diff) |
Prepare CROSSTOOL for dSYM simplification
Currently dSYM information is propagated using a zip file emitted by the linking action which contains a dwarf file and plist. A second action then unzips said file, discards the plist and propagates the dwarf file. This CL is part of a change which makes the link action emit the dwarf file directly.
This change adds logic to the CROSSTOOL and wrapped_clang to temporarily support both the old and new approaches using the presence of DSYM_HINT_DSYM_BUNDLE_ZIP as a signal as to which to use. After this change the new (and temporary) CROSSTOOL feature no_dsym_create_zip will allow suppressing DSYM_HINT_DSYM_BUNDLE_ZIP from being passed. Once the migration is complete we will remove both the signal variable and feature.
PiperOrigin-RevId: 203954795
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL | 144 | ||||
-rw-r--r-- | tools/osx/crosstool/CROSSTOOL.tpl | 120 | ||||
-rw-r--r-- | tools/osx/crosstool/wrapped_clang.cc | 50 |
3 files changed, 292 insertions, 22 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL index a4828f4d39..d137664dbf 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL @@ -225,6 +225,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -243,8 +246,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -1954,6 +1966,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -1972,8 +1987,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -3678,6 +3702,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -3696,8 +3723,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -5402,6 +5438,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -5420,8 +5459,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -7130,6 +7178,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -7148,8 +7199,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -8864,6 +8924,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -8882,8 +8945,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -10601,6 +10673,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -10619,8 +10694,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -12365,6 +12449,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -12383,8 +12470,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -14099,6 +14195,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -14117,8 +14216,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -15853,6 +15961,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -15871,8 +15982,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -17610,6 +17730,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -17628,8 +17751,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -19394,6 +19526,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -19412,8 +19547,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl index e065efbff8..6686ce0e69 100644 --- a/tools/osx/crosstool/CROSSTOOL.tpl +++ b/tools/osx/crosstool/CROSSTOOL.tpl @@ -201,6 +201,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -219,8 +222,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -1818,6 +1830,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -1836,8 +1851,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -3451,6 +3475,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -3469,8 +3496,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -5087,6 +5123,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -5105,8 +5144,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -6750,6 +6798,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -6768,8 +6819,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -8383,6 +8443,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -8401,8 +8464,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -10004,6 +10076,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -10022,8 +10097,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -11628,6 +11712,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -11646,8 +11733,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -13279,6 +13375,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -13297,8 +13396,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { @@ -14901,6 +15009,9 @@ toolchain { } } feature { + name: "no_dsym_create_zip" + } + feature { name: "generate_dsym_file" flag_set { action: "c-compile" @@ -14919,8 +15030,17 @@ toolchain { flag_group { flag: "DSYM_HINT_LINKED_BINARY=%{linked_binary}" flag: "DSYM_HINT_DSYM_PATH=%{dsym_path}" + } + } + flag_set { + action: "objc-executable" + action: "objc++-executable" + flag_group { flag: "DSYM_HINT_DSYM_BUNDLE_ZIP=%{dsym_bundle_zip}" } + with_feature { + not_feature: "no_dsym_create_zip" + } } } feature { diff --git a/tools/osx/crosstool/wrapped_clang.cc b/tools/osx/crosstool/wrapped_clang.cc index 91f41d3ce1..232f082dc1 100644 --- a/tools/osx/crosstool/wrapped_clang.cc +++ b/tools/osx/crosstool/wrapped_clang.cc @@ -22,8 +22,10 @@ // are passed in, then they all must be passed in. // "DSYM_HINT_LINKED_BINARY": Workspace-relative path to binary output of the // link action generating the dsym file. -// "DSYM_HINT_DSYM_PATH": Workspace-relative path to dSYM directory. -// "DSYM_HINT_DSYM_BUNDLE_ZIP": Workspace-relative path to dSYM zip. +// "DSYM_HINT_DSYM_PATH": Workspace-relative path to dSYM dwarf file or bundle. +// "DSYM_HINT_DSYM_BUNDLE_ZIP": (optional) Workspace-relative path to dSYM zip. +// - If this is specified, a dSYM bundle is created, otherwise just a regular +// DWARF file is created. // // Likewise, this wrapper also contains a workaround for a bug in ld that causes // flaky builds when using Bitcode symbol maps. ld allows the @@ -199,17 +201,15 @@ int main(int argc, char *argv[]) { // Check to see if we should postprocess with dsymutil. bool postprocess = false; + bool dsyms_use_zip_file = false; if ((!linked_binary.empty()) || (!dsym_path.empty()) || (!dsym_bundle_zip.empty())) { - if ((linked_binary.empty()) || (dsym_path.empty()) || - (dsym_bundle_zip.empty())) { + if ((linked_binary.empty()) || (dsym_path.empty())) { const char *missing_dsym_flag; if (linked_binary.empty()) { missing_dsym_flag = "DSYM_HINT_LINKED_BINARY"; - } else if (dsym_path.empty()) { - missing_dsym_flag = "DSYM_HINT_DSYM_PATH"; } else { - missing_dsym_flag = "DSYM_HINT_DSYM_BUNDLE_ZIP"; + missing_dsym_flag = "DSYM_HINT_DSYM_PATH"; } std::cerr << "Error in clang wrapper: If any dsym " "hint is defined, then " @@ -217,6 +217,7 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } else { postprocess = true; + dsyms_use_zip_file = !(dsym_bundle_zip.empty()); } } @@ -227,27 +228,32 @@ int main(int argc, char *argv[]) { if (postprocess) { std::vector<std::string> dsymutil_args = {"/usr/bin/xcrun", "dsymutil", linked_binary, "-o", dsym_path}; + if (!dsyms_use_zip_file) { + dsymutil_args.push_back("--flat"); + } if (RunSubProcess(dsymutil_args) != 0) { return EXIT_FAILURE; } - std::unique_ptr<char, decltype(std::free) *> cwd{getcwd(nullptr, 0), - std::free}; - if (cwd == nullptr) { - std::cerr << "Error determining current working directory\n"; - return EXIT_FAILURE; - } - std::vector<std::string> zip_args = { - "/usr/bin/zip", "-q", "-r", - std::string(cwd.get()) + "/" + dsym_bundle_zip, "."}; - if (chdir(dsym_path.c_str()) < 0) { - std::cerr << "Error changing directory to '" << dsym_path << "'\n"; - return EXIT_FAILURE; - } + 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"; + return EXIT_FAILURE; + } + std::vector<std::string> zip_args = { + "/usr/bin/zip", "-q", "-r", + std::string(cwd.get()) + "/" + dsym_bundle_zip, "."}; + if (chdir(dsym_path.c_str()) < 0) { + std::cerr << "Error changing directory to '" << dsym_path << "'\n"; + return EXIT_FAILURE; + } - if (RunSubProcess(zip_args) != 0) { - return EXIT_FAILURE; + if (RunSubProcess(zip_args) != 0) { + return EXIT_FAILURE; + } } } |