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

java.lang.RuntimeException when building for multiple archs an ios_application that depends on an apple_framework #2518

Open
vakhidbetrakhmadov opened this issue Aug 26, 2024 · 1 comment · Fixed by revolut-mobile/rules_apple#7 · May be fixed by #2519

Comments

@vakhidbetrakhmadov
Copy link
Contributor

Hi,

When building an ios_application that depends on an apple_framework from rules_ios, following error occures:

$ bazelisk build --apple_platform_type=ios --ios_multi_cpus=x86_64,sim_arm64 --//:test_case=apple_framework HelloWorldSwift
Analyzing: target //:HelloWorldSwift (90 packages loaded, 1135 targets configured)
    currently loading: @@build_bazel_rules_ios//rules/test_host_app
[1 / 1] checking cached actions
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//:HelloWorldSwift, config=BuildConfigurationKey[38f23fb72e03f0a597d6c10cf5be599a95e3ea63a333be1217596f4f4081746c]}' (requested by nodes 'ConfiguredTargetKey{label=//:HelloWorldSwift, config=BuildConfigurationKey[2e520ce0ae79be1571c07d6987a022b56061727d1a2cc69b5284af9c1a3729b9]}')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:550)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: net.starlark.java.eval.Starlark$UncheckedEvalException: IllegalStateException thrown during Starlark evaluation (//:HelloWorldSwift)
        at <starlark>.link_multi_arch_binary(<builtin>:0)
        at <starlark>._register_binary_linking_action(/private/var/tmp/_bazel_vakhid.betrakhmadov/683f29226f77b774d9de4d50b9c730af/external/build_bazel_rules_apple/apple/internal/linking_support.bzl:243)
        at <starlark>._ios_application_impl(/private/var/tmp/_bazel_vakhid.betrakhmadov/683f29226f77b774d9de4d50b9c730af/external/build_bazel_rules_apple/apple/internal/ios_rules.bzl:241)
Caused by: java.lang.IllegalStateException: Split transition keys are different between 'deps' [[Optional.of(ios_x86_64)]] and '$child_configuration_dummy' [[Optional.of(ios_sim_arm64), Optional.of(ios_x86_64)]]
        at com.google.common.base.Preconditions.checkState(Preconditions.java:854)
        at com.google.devtools.build.lib.rules.objc.AppleBinary.linkMultiArchBinary(AppleBinary.java:82)
        at com.google.devtools.build.lib.rules.objc.AppleStarlarkCommon.linkMultiArchBinary(AppleStarlarkCommon.java:311)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at net.starlark.java.eval.MethodDescriptor.call(MethodDescriptor.java:178)
        at net.starlark.java.eval.BuiltinFunction.fastcall(BuiltinFunction.java:78)
        at net.starlark.java.eval.Starlark.fastcall(Starlark.java:806)
        at net.starlark.java.eval.Eval.evalCall(Eval.java:682)
        at net.starlark.java.eval.Eval.eval(Eval.java:497)
        at net.starlark.java.eval.Eval.execAssignment(Eval.java:109)
        at net.starlark.java.eval.Eval.exec(Eval.java:268)
        at net.starlark.java.eval.Eval.execStatements(Eval.java:82)
        at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:66)
        at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:179)
        at net.starlark.java.eval.Starlark.fastcall(Starlark.java:806)
        at net.starlark.java.eval.Eval.evalCall(Eval.java:682)
        at net.starlark.java.eval.Eval.eval(Eval.java:497)
        at net.starlark.java.eval.Eval.execAssignment(Eval.java:109)
        at net.starlark.java.eval.Eval.exec(Eval.java:268)
        at net.starlark.java.eval.Eval.execStatements(Eval.java:82)
        at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:66)
        at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:179)
        at net.starlark.java.eval.Starlark.fastcall(Starlark.java:806)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.evalRule(StarlarkRuleConfiguredTargetUtil.java:100)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:376)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:194)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:1308)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:385)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:312)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

I have created a minimal repro example that can be found here: https://github.com/vakhidbetrakhmadov/ios_multi_cpus_repro.

To reproduce the error above, please run bazelisk build --apple_platform_type=ios --ios_multi_cpus=x86_64,sim_arm64 --//:test_case=apple_framework HelloWorldSwift.

As a comparison, when apple_framework is replaced with swift_library, it compiles just fine.

To observe that, please run bazelisk build --apple_platform_type=ios --ios_multi_cpus=x86_64,sim_arm64 --//:test_case=swift_library HelloWorldSwift.

Same is true when compiling for a single arch.

To observe that, please run bazelisk build --apple_platform_type=ios --ios_multi_cpus=x86_64 --//:test_case=apple_framework HelloWorldSwift or bazelisk build --apple_platform_type=ios --ios_multi_cpus=sim_arm64 --//:test_case=apple_framework HelloWorldSwift.

@vakhidbetrakhmadov
Copy link
Contributor Author

vakhidbetrakhmadov commented Aug 26, 2024

After some debugging, i think i was able to find the issue.
Following patch seems to resolve the issue.

$ bazelisk build --apple_platform_type=ios --ios_multi_cpus=x86_64,sim_arm64 --//:test_case=apple_framework HelloWorldSwift
...
INFO: Build completed successfully, 2 total actions

I am not sure if the patch is good enough, or if it's event the best way to solve the issue, but i will open a PR, and i will appreciate feedback and guidance 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants
@vakhidbetrakhmadov and others