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

[vm] Support building Android target on Mac M1 arm64 #48792

Closed
dcharkes opened this issue Apr 12, 2022 · 2 comments
Closed

[vm] Support building Android target on Mac M1 arm64 #48792

dcharkes opened this issue Apr 12, 2022 · 2 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@dcharkes
Copy link
Contributor

dcharkes commented Apr 12, 2022

Trying to build for Android on a Mac arm64 M1 fails:

dacoharkes-macbookpro2:sdk dacoharkes$ tools/build.py --os=android -aarm create_platform_sdk
ERROR at //build/config/android/config.gni:30:5: Assertion failed.
    assert(false, "Need Android toolchain support for your build CPU arch.")
    ^-----
Need Android toolchain support for your build CPU arch.

if (host_cpu == "x64" || host_cpu == "x86") {
android_host_arch = "x86_64"
} else {
assert(false, "Need Android toolchain support for your build CPU arch.")
}

If we add the architecture there

  if (host_cpu == "x64" || host_cpu == "x86") {
    android_host_arch = "x86_64"
  } else if (host_cpu == "arm64") {
    android_host_arch = "arm64"
  } else {
    assert(false, "Need Android toolchain support for your build CPU arch.")
  }

then the build does not know how to build files

ninja -C xcodebuild/DebugAndroidARM -j1000 -l64 create_platform_sdk
ninja: Entering directory `xcodebuild/DebugAndroidARM'
ninja: error: '../../third_party/android_tools/ndk/sources/android/cpufeatures/cpu-features.c', needed by 'obj/third_party/android_tools/ndk/sources/android/cpufeatures/cpu_features.cpu-features.o', missing and no known rule to make it
ninja -C xcodebuild/DebugAndroidARM -j1000 -l64 create_platform_sdk done.

(Note: adding those two lines does make tools/generate_idefiles.py -aarm64 succeed.)

@dcharkes dcharkes added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label Apr 12, 2022
copybara-service bot pushed a commit that referenced this issue Apr 20, 2022
TEST=local
Bug: #48792
Change-Id: Ia43dd46f90ef5f592e324bb889c20c221f69998a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241102
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
copybara-service bot pushed a commit that referenced this issue Apr 20, 2022
This reverts commit b503967.

Reason for revert: vm-kernel-precomp-linux-debug-simarm_x64

Original change's description:
> [build] Fix Android build for ARM64 Mac.
>
> TEST=local
> Bug: #48792
> Change-Id: Ia43dd46f90ef5f592e324bb889c20c221f69998a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241102
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: William Hesse <whesse@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=whesse@google.com,rmacnak@google.com,dacoharkes@google.com

Change-Id: I0cfdb5653dff7675afdb005df0c37f7560b26ee3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: #48792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241860
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
copybara-service bot pushed a commit that referenced this issue May 10, 2022
Account for simarm_x64 in TargetCpuForArch.

TEST=local
Bug: #48792
Change-Id: I820cb49ee8925c50196cb2472266f9e248c9089d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243642
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
@a-siva
Copy link
Contributor

a-siva commented May 13, 2022

Can this be closed ?

@dcharkes
Copy link
Contributor Author

dcharkes commented May 13, 2022

The build now mostly succeeds locally for JIT and AOT.

tools/build.py --os=android -aarm,arm64 runtime dart_precompiled_runtime
== ARM64 Mac

./tools/build.py --os=android --arch=x64,x64c,arm64,arm64c,arm_x64 runtime
Okay
./tools/build.py --arch=x64,x64c,arm64,arm64c runtime
Okay

./tools/build.py --arch=ia32 runtime
Exception: Failed to find a C host architecture for ia32. Need one of ['x86'] but only ['arm64', 'x64'] are available.
./tools/build.py --arch=simarm runtime
Exception: Failed to find a C target architecture for simarm. Need one of ['arm', 'riscv32', 'x86'] but only ['arm64', 'x64'] are available.
./tools/build.py --arch=simriscv32 runtime
Exception: Failed to find a C target architecture for simriscv32. Need one of ['arm', 'riscv32', 'x86'] but only ['arm64', 'x64'] are available.

== ARM64 Linux

./tools/build.py --os=android,fuchsia ...
Missing toolchain
./tools/build.py --arch=arm,arm64,simriscv64 runtime
Okay
./tools/build.py --arch=x64 runtime
Exception: Failed to find a C host architecture for x64. Need one of ['x64'] but only ['arm64'] are available.
./tools/build.py --arch=ia32 runtime
Exception: Failed to find a C host architecture for ia32. Need one of ['x86'] but only ['arm64'] are available.


== X64 Linux

./tools/build.py --os=android --arch=ia32,x64,x64c,arm,arm64,arm64c runtime
Okay
./tools/build.py --os=fuchsia --arch=x64,x64c,arm64,arm64c runtime
Okay
./tools/build.py --arch=ia32,x64,x64c,arm,arm64,arm64c,simarm,simarm64,simarm64c,simriscv32,simriscv64 runtime
Okay
./tools/build.py --arch=riscv64 --no-clang --no-goma runtime
Okay
./tools/build.py --arch=riscv32 --no-clang --no-goma runtime
Missing toolchain

from @rmacnak-google in https://dart-review.googlesource.com/c/sdk/+/241102

create_platform_sdk doesn't work yet:

$ tools/build.py --os=android -aarm create_platform_sdk
[...]
xcodebuild/DebugAndroidARM/clang_arm64/dart
[...]
output: ../../runtime/vm/object.h: 1060: error: expected "target_value" = 28, actual "host_value" = 24
version=2.18.0-edge.37eff8b8bcd124cec3534157b7c397097e112a3c (be) (Thu May 12 22:59:15 2022 +0000) on "macos_arm"
pid=69542, thread=259, isolate_group=vm-isolate(0x155813400), isolate=vm-isolate(0x155817600)
isolate_instructions=102487860, vm_instructions=102487860
  pc 0x00000001027ecb70 fp 0x000000016da06530 dart::Profiler::DumpStackTrace(void*)+0x68
  pc 0x00000001024879e4 fp 0x000000016da06550 dart::Assert::Fail(char const*, ...) const+0x28
  pc 0x000000010089c314 fp 0x000000016f8725b0 dart::Object::InVMIsolateHeap() const+0x0
  pc 0x0000000100880bd4 fp 0x000000016f872650 dart::Object::Init(dart::IsolateGroup*)+0x4ec

It looks like the DART_PRECOMPILER is not defined, but it should. (It works on Linux x64 targeting arm/arm64.)

So, we're done if we don't care about create_platform_sdk, and otherwise almost done.

copybara-service bot pushed a commit that referenced this issue May 17, 2022
…ots.

If this is a cross-word-size configuration, the JIT cannot run.

TEST=local
Bug: #48792
Change-Id: I7aca0c2da4e352c121f531bdf3eb6402aead1569
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244743
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants