Support running x86_64 logic tests on Apple silicon#40
Support running x86_64 logic tests on Apple silicon#40bogo wants to merge 3 commits intogoogle:masterfrom
Conversation
test_runner/logic_test_util.py
Outdated
| test_archs = bundle_util.GetFileArchTypes(test_executable) | ||
|
|
||
| # if a logic bundle is built w/ x86 on Apple silicon, it won't be able to launch on the ARM64 sim; rework the xctest to fix this | ||
| if ios_constants.ARCH.X86_64 in test_archs: |
There was a problem hiding this comment.
Does this need to be an exclusive check? Because you could be testing a fat binary in which case you still wouldn't want to do this I think?
There was a problem hiding this comment.
Fair point. Do you think parametrizing the test runner with something like --force-run-x86 would be sufficient here? Then it could be passed as a test parameter from Bazel invocation.
There was a problem hiding this comment.
seems like host arch == arm64 && test_archs == x86_64 && no test host is a find conditional for now to make things "just work" for folks, but up to the google folks
There was a problem hiding this comment.
Keith, why testing with a fat binary is not expected? I don't have a local M1 machine to test it out. My understanding is the current implementation can work for both x86_64 only test bundle and fat test bundle.
There was a problem hiding this comment.
if you have a fat binary, this conditional will be true, but you should probably not do this and test the native arm64 slice instead if you have it.
There was a problem hiding this comment.
Make sense.
Bogo, could you help change the condition to be ios_constants.ARCH.X86_64 in test_archs and len(test_archs) == 1? Doing the host arch check seems not necessary. No matter if the host is M1 or intel, we can use x86_64 only xctest tool to execute x86_64 test bundle.
I will also need to change
xctestrunner/test_runner/xctestrun.py
Line 558 in db0fce1
There was a problem hiding this comment.
my conditional mentioned above also makes sure this wouldn't happen in cases where it's unnecessary, but it's not required
There was a problem hiding this comment.
@keith I thought about testing the host architecture, but figured it might be better to have the code paths as close as possible on Apple silicon and x86. Can add the necessary helpers if you feel it'd be worth it though.
|
Hey @bogo! This PR seems to be stale for quite some time. Is it abandoned? Do you need any help to finalize it? My team would like to be able to run x86 sim tests via bazel which mean we need to teach xctestrunner first |
|
@albertdai Can you take a look at this too? |
test_runner/logic_test_util.py
Outdated
| xctest_tool = shutil.copy( | ||
| xcode_info_util.GetXctestToolPath(ios_constants.SDK.IPHONESIMULATOR), | ||
| os.path.join(tempfile.mkdtemp(), "xctest") | ||
| ) |
There was a problem hiding this comment.
You can change LeaveOnlyArchType to LeaveOnlyArchType(input_file_path, output_file_path, arch_type). So we don't need to do this copy
|
Thanks for the help, @keith and @albertdai! Applied the changes you suggested. |
|
Seems like this patch needs tweaks for Xcode 13.3. Getting the following error when using it with Xcode 13.3: |
|
Hey @bogo @keith @albertdai ! We have been using custom xctestrunner from this commit with great success but would love to get this in main branch to get other fixes like #41 in too. Do you need any help with this PR to move it forward? Also looks like @thii caught some issues on 13.3 which means some more adjustments are needed |
|
Seems like we'd need to fix the new issues before doing anything, but note that on this repo @albertdai is the decider on this stuff as the only person with commit access |
I don't have a local Apple silicon machine to test out this issue on Xcode 13.3. @bogo Could you help double check with that from your side? |
|
I tested out locally with my intel macbook pro and confirmed the test runner with the commits can not work with Swift logic test on Xcode 13.3. So we need to fix the issues before merging the commits into master. |
|
@bogo do you need help with this PR? This is really valuable change |
|
@ivan-golub @albertdai will take a look at whether I can make it work again either later this week or early next week! |
|
Thanks Bogo. I feel the |
|
FYI: failure for swift logic tests seem to be present only for iOS 15.4 simulator, ie this will fail but this will not |
|
|
||
| # if a logic bundle is built w/ x86 on Apple silicon, it won't be able to launch on the ARM64 sim; rework the xctest to fix this | ||
| if ios_constants.ARCH.X86_64 in test_archs and len(test_archs) == 1: | ||
| replacement_xctest_tool = os.path.join(tempfile.mkdtemp(), "xctest") |
There was a problem hiding this comment.
| replacement_xctest_tool = os.path.join(tempfile.mkdtemp(), "xctest") | |
| replacement_xctest_tool = os.path.join(os.path.dirname(xctest_tool), "xctest_x86_64") |
this fixes swift logic test issue with xcode 13.3 and ios 15.4 as @albertdai suspected here #40 (comment)
There was a problem hiding this comment.
this could fail depending on how the user installed xcode, as it won't have permissions in some cases
|
FYI this broke with Xcode 13.4.0, the issue appears to be a change in iOS, I'm debugging a bit |
| ) | ||
| xctest_tool = replacement_xctest_tool | ||
| platform_developer_dir = os.path.join(xcode_info_util.GetSdkPlatformPath(ios_constants.SDK.IPHONESIMULATOR), "Developer") | ||
| simctl_env_vars[_SIMCTL_ENV_VAR_PREFIX + "DYLD_FALLBACK_LIBRARY_PATH"] = "{0}/usr/lib".format(platform_developer_dir) |
There was a problem hiding this comment.
| simctl_env_vars[_SIMCTL_ENV_VAR_PREFIX + "DYLD_FALLBACK_LIBRARY_PATH"] = "{0}/usr/lib".format(platform_developer_dir) | |
| simctl_env_vars[_SIMCTL_ENV_VAR_PREFIX + "DYLD_LIBRARY_PATH"] = "{0}/usr/lib".format(platform_developer_dir) |
this fixes Xcode 13.4 support, and still works for earlier versions. I'm not sure why yet but something about the semantics of this changed.
This PR adds support for running x86_64 logic tests on Apple silicon by following the patterns introduced in 7f8fc8. This is most helpful in the current Bazel/rules_apple context, where the only Simulator binaries produced are x86. This approach to running logic tests on Apple silicon is discussed in MobileNativeFoundation/discussions#141.
Since
xctestis stripped down to x86 only if the x86 slice is present, this should not affect existing Intel Macs, and should be automatically skipped once rules_apple and Bazel correctly support Apple silicon Simulator.