Skip to content

Commit ee75682

Browse files
nglevinluispadron
authored andcommitted
Switch from building paths out of the split transition key to using target_gnu_system_name, for consistency with static library archive behavior and to aid in future onboarding of Bazel platforms.
Further, have the dSYM bundle paths either match the flat file dSYM outputs behavior ("dynamic" XCFrameworks) or avoid subdirectories (other linked Apple binary output rules). Cherry-pick: bee6a12
1 parent aca0a39 commit ee75682

6 files changed

Lines changed: 28 additions & 19 deletions

File tree

apple/internal/linking_support.bzl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def _link_multi_arch_binary(
232232
]
233233
attr_linkopts = [token for opt in attr_linkopts for token in ctx.tokenize(opt)]
234234

235+
multi_arch_build = len(cc_toolchains) > 1
236+
235237
for split_transition_key, child_toolchain in cc_toolchains.items():
236238
cc_toolchain = child_toolchain[cc_common.CcToolchainInfo]
237239
deps = split_deps.get(split_transition_key, [])
@@ -271,13 +273,20 @@ def _link_multi_arch_binary(
271273
else:
272274
dsym_bundle_name = ctx.label.name
273275

274-
# Avoiding "intermediates" as this will be the canonical dSYM in a single arch build
275-
dsym_output = ctx.actions.declare_directory(
276-
"{split_transition_key}/{dsym_bundle_name}.dSYM".format(
277-
split_transition_key = split_transition_key,
278-
dsym_bundle_name = dsym_bundle_name,
279-
),
280-
)
276+
if multi_arch_build:
277+
dsym_output = intermediates.directory(
278+
actions = ctx.actions,
279+
target_name = ctx.label.name,
280+
output_discriminator = cc_toolchain.target_gnu_system_name,
281+
dir_name = dsym_bundle_name,
282+
)
283+
else:
284+
# Avoiding "intermediates" as this will be the only dSYM in a single arch build.
285+
dsym_output = ctx.actions.declare_directory(
286+
"{dsym_bundle_name}.dSYM".format(
287+
dsym_bundle_name = dsym_bundle_name,
288+
),
289+
)
281290
elif dsym_variants != "flat":
282291
fail("""
283292
Internal Error: Found unsupported dsym_variant_flag: {dsym_variants}.
@@ -295,7 +304,7 @@ Please report this as a bug to the Apple BUILD Rules team.
295304
dsym_output = intermediates.file(
296305
actions = ctx.actions,
297306
target_name = ctx.label.name,
298-
output_discriminator = split_transition_key,
307+
output_discriminator = cc_toolchain.target_gnu_system_name,
299308
file_name = "{}.dwarf".format(main_binary_unstripped_basename),
300309
)
301310

@@ -314,7 +323,7 @@ Please report this as a bug to the Apple BUILD Rules team.
314323
linkmap = intermediates.file(
315324
actions = ctx.actions,
316325
target_name = ctx.label.name,
317-
output_discriminator = split_transition_key,
326+
output_discriminator = cc_toolchain.target_gnu_system_name,
318327
file_name = ctx.label.name + ".linkmap",
319328
)
320329
extensions["linkmap_exec_path"] = linkmap.path # linkmap file

apple/internal/partials/debug_symbols.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ def _bundle_dsym_files(
396396
dsym_variants = platform_prerequisites.build_settings.dsym_variant_flag
397397

398398
if dsym_variants == "bundle":
399-
if len(dsym_inputs) == 1:
400-
# If we only have one dSYM binary, we can just use it as-is, no need to merge + lipo its
401-
# contents.
399+
if len(dsym_inputs) == 1 and not output_discriminator:
400+
# If we only have one dSYM bundle and we don't need to rename the dSYM bundle, we can
401+
# just use it as-is, no need to merge + lipo its contents.
402402
return [], dsym_inputs.values()[0]
403403

404404
# 1. Lipo the binaries (Resources/DWARF/{main_binary_basename}).

test/starlark_tests/apple_xcframework_tests.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ def apple_xcframework_test_suite(name):
349349
target_under_test = "//test/starlark_tests/targets_under_test/apple:ios_dynamic_xcframework",
350350
output_group_name = "dsyms",
351351
expected_outputs = [
352-
"ios_arm64_device/ios_dynamic_xcframework.dSYM",
353-
"ios_x86_64_simulator/ios_dynamic_xcframework.dSYM",
352+
"ios_dynamic_xcframework_ios_device.framework.dSYM",
353+
"ios_dynamic_xcframework_ios_simulator.framework.dSYM",
354354
],
355355
tags = [name],
356356
)

test/starlark_tests/macos_application_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def macos_application_test_suite(name):
324324
name = "{}_runfiles_dsymutil_bundle_test".format(name),
325325
target_under_test = "//test/starlark_tests/targets_under_test/macos:app",
326326
expected_runfiles = [
327-
"third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/darwin_arm64/app.app.dSYM",
327+
"third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/app.app.dSYM",
328328
],
329329
tags = [name],
330330
)

test/starlark_tests/macos_command_line_application_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def macos_command_line_application_test_suite(name):
226226
name = "{}_runfiles_dsymutil_bundle_test".format(name),
227227
target_under_test = "//test/starlark_tests/targets_under_test/macos:cmd_app_basic",
228228
expected_runfiles = [
229-
"third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/darwin_arm64/cmd_app_basic.dSYM",
229+
"third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/cmd_app_basic.dSYM",
230230
],
231231
tags = [name],
232232
)

test/starlark_tests/visionos_application_tests.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def visionos_application_test_suite(name):
186186
target_under_test = "//test/starlark_tests/targets_under_test/visionos:app",
187187
output_group_name = "dsyms",
188188
expected_outputs = [
189-
"visionos_sim_arm64/app.app.dSYM",
189+
"app.app.dSYM",
190190
],
191191
tags = [
192192
name,
@@ -210,10 +210,10 @@ def visionos_application_test_suite(name):
210210
name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name),
211211
target_under_test = "//test/starlark_tests/targets_under_test/visionos:app",
212212
expected_direct_dsyms = [
213-
"visionos_sim_arm64/app.app.dSYM",
213+
"app.app.dSYM",
214214
],
215215
expected_transitive_dsyms = [
216-
"visionos_sim_arm64/app.app.dSYM",
216+
"app.app.dSYM",
217217
],
218218
tags = [
219219
name,

0 commit comments

Comments
 (0)