Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BITCODE_TOUCH_SYMBOL_MAP #12379

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5961,7 +5961,7 @@ def _impl(ctx):
"-Xlinker",
"-bitcode_symbol_map",
"-Xlinker",
"BITCODE_TOUCH_SYMBOL_MAP=%{bitcode_symbol_map_path}",
"%{bitcode_symbol_map_path}",
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion tools/osx/crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6010,7 +6010,7 @@ def _impl(ctx):
"-Xlinker",
"-bitcode_symbol_map",
"-Xlinker",
"BITCODE_TOUCH_SYMBOL_MAP=%{bitcode_symbol_map_path}",
"%{bitcode_symbol_map_path}",
],
expand_if_available = "bitcode_symbol_map_path",
),
Expand Down
20 changes: 1 addition & 19 deletions tools/osx/crosstool/wrapped_clang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
// "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 dwarf file.
//
// Likewise, this wrapper also contains a workaround for a bug in ld that causes
// flaky builds when using Bitcode symbol maps. ld allows the
// -bitcode_symbol_map to be either a directory (into which the file will be
// written) or a file, but the return value of the call to ::stat is never
// checked so examining the S_ISDIR bit of the struct afterwards returns
// true/false randomly depending on what data happened to be in memory at the
// time it was called:
// https://github.com/michaelweiser/ld64/blob/9c3700b64ed03e2d55ba094176bf6a172bf2bc6b/src/ld/Options.cpp#L3261
// To address this, we prepend a special "BITCODE_TOUCH_SYMBOL_MAP=" flag to the
// symbol map filename and touch it before passing it along to clang, forcing
// the file to exist.

#include <libgen.h>
#include <spawn.h>
Expand Down Expand Up @@ -191,7 +179,7 @@ int main(int argc, char *argv[]) {

std::vector<std::string> processed_args = {"/usr/bin/xcrun", tool_name};

std::string linked_binary, dsym_path, bitcode_symbol_map;
std::string linked_binary, dsym_path;
std::string dest_dir;

std::unique_ptr<char, decltype(std::free) *> cwd{getcwd(nullptr, 0),
Expand All @@ -211,12 +199,6 @@ int main(int argc, char *argv[]) {
if (SetArgIfFlagPresent(arg, "DSYM_HINT_DSYM_PATH", &dsym_path)) {
continue;
}
if (SetArgIfFlagPresent(arg, "BITCODE_TOUCH_SYMBOL_MAP",
&bitcode_symbol_map)) {
// Touch bitcode_symbol_map.
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;
}
Expand Down