Skip to content

Commit 3e8701b

Browse files
committed
fix conflicts
1 parent 0136584 commit 3e8701b

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

crosstool/wrapped_clang.cc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ static std::unique_ptr<TempFile> WriteResponseFile(
249249

250250
void ProcessArgument(const std::string arg, const std::string developer_dir,
251251
const std::string sdk_root, const std::string cwd,
252-
std::string toolchain_path,
252+
std::string &linked_binary, std::string toolchain_path,
253253
std::function<void(const std::string &)> consumer);
254254

255255
bool ProcessResponseFile(const std::string arg, const std::string developer_dir,
256256
const std::string sdk_root, const std::string cwd,
257-
std::string toolchain_path,
257+
std::string &linked_binary, std::string toolchain_path,
258258
std::function<void(const std::string &)> consumer) {
259259
auto path = arg.substr(1);
260260
std::ifstream original_file(path);
@@ -268,7 +268,7 @@ bool ProcessResponseFile(const std::string arg, const std::string developer_dir,
268268
// Arguments in response files might be quoted/escaped, so we need to
269269
// unescape them ourselves.
270270
ProcessArgument(Unescape(arg_from_file), developer_dir, sdk_root, cwd,
271-
toolchain_path, consumer);
271+
linked_binary, toolchain_path, consumer);
272272
}
273273

274274
return true;
@@ -350,17 +350,20 @@ std::string GetToolchainPath(const std::string &toolchain_id) {
350350

351351
void ProcessArgument(const std::string arg, const std::string developer_dir,
352352
const std::string sdk_root, const std::string cwd,
353-
std::string toolchain_path,
353+
std::string &linked_binary, std::string toolchain_path,
354354
std::function<void(const std::string &)> consumer) {
355355
auto new_arg = arg;
356356
if (arg[0] == '@') {
357-
if (ProcessResponseFile(arg, developer_dir, sdk_root, cwd,
358-
toolchain_path,
359-
consumer)) {
357+
if (ProcessResponseFile(arg, developer_dir, sdk_root, cwd, linked_binary,
358+
toolchain_path, consumer)) {
360359
return;
361360
}
362361
}
363362

363+
if (SetArgIfFlagPresent(arg, "LINKED_BINARY", &linked_binary)) {
364+
return;
365+
}
366+
364367
FindAndReplace("__BAZEL_EXECUTION_ROOT__", cwd, &new_arg);
365368
FindAndReplace("__BAZEL_EXECUTION_ROOT_CANONICAL__", GetCanonicalPath(cwd), &new_arg);
366369
FindAndReplace("__BAZEL_XCODE_DEVELOPER_DIR__", developer_dir, &new_arg);
@@ -414,6 +417,7 @@ int main(int argc, char *argv[]) {
414417

415418
std::string developer_dir = GetMandatoryEnvVar("DEVELOPER_DIR");
416419
std::string sdk_root = GetMandatoryEnvVar("SDKROOT");
420+
std::string linked_binary;
417421

418422
const std::string cwd = GetCurrentDirectory();
419423
std::vector<std::string> invocation_args = {"/usr/bin/xcrun", tool_name};
@@ -425,7 +429,7 @@ int main(int argc, char *argv[]) {
425429
for (int i = 1; i < argc; i++) {
426430
std::string arg(argv[i]);
427431

428-
ProcessArgument(arg, developer_dir, sdk_root, cwd,
432+
ProcessArgument(arg, developer_dir, sdk_root, cwd, linked_binary,
429433
toolchain_path, consumer);
430434
}
431435

@@ -458,7 +462,9 @@ int main(int argc, char *argv[]) {
458462
output.close();
459463
}
460464

461-
bool generate_dsym = !dsym_path.empty();
465+
const char *dsym_path_raw_value = getenv("DSYM_HINT_DSYM_PATH");
466+
bool generate_dsym = dsym_path_raw_value != nullptr;
467+
bool strip_debug_symbols = getenv("STRIP_DEBUG_SYMBOLS") != nullptr;
462468
if (!generate_dsym && !strip_debug_symbols) {
463469
return 0;
464470
}
@@ -471,6 +477,7 @@ int main(int argc, char *argv[]) {
471477
}
472478

473479
if (generate_dsym) {
480+
std::string dsym_path = dsym_path_raw_value;
474481
const std::string bundle_suffix = ".dSYM";
475482
bool is_bundle = dsym_path.rfind(bundle_suffix) ==
476483
dsym_path.length() - bundle_suffix.length();
@@ -491,8 +498,7 @@ int main(int argc, char *argv[]) {
491498

492499
// When stripping is requested, we should still strip the binary
493500
// before returning
494-
const char *strip_debug_symbols = getenv("STRIP_DEBUG_SYMBOLS");
495-
if (strip_debug_symbols != nullptr) {
501+
if (strip_debug_symbols) {
496502
std::vector<std::string> strip_args = {"/usr/bin/xcrun", "strip", "-S",
497503
linked_binary};
498504
if (!RunSubProcess(strip_args)) {

0 commit comments

Comments
 (0)