-
Notifications
You must be signed in to change notification settings - Fork 254
Add support of cross-building the engine for ARM64 Linux Host #390
Add support of cross-building the engine for ARM64 Linux Host #390
Conversation
build/toolchain/linux/BUILD.gn
Outdated
| ar = "ar" | ||
| ld = cxx | ||
| strip = "strip" | ||
| strip = "${compiler_prefix}$prefix/llvm-strip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Also, what are the implications for x64 for changing from strip to llvm-strip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your response.
Why is this needed?
This is to fix the following error. We have to use the binaries under buildtools/linux-x64/clang/bin/. I think that originally wrong. dart-sdk is helpful. I guess it's better to modify readelf, nm, and ar as well...
[4439/6380] LINK ./font-subset
FAILED: font-subset exe.unstripped/font-subset
../../buildtools/linux-x64/clang/bin/clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -pthread --target=aarch64-linux-gnu --sysroot=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu -Wl,-O2 -Wl,--gc-sections -Wl,--as-needed -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -Wl,--disable-new-dtags -o ./exe.unstripped/font-subset -Wl,--build-id=sha1 -Wl,--start-group @./font-subset.rsp -Wl,--end-group -ldl && strip --strip-unneeded -o ./font-subset ./exe.unstripped/font-subset
strip: Unable to recognise the format of the input file `./exe.unstripped/font-subset'
[4444/6380] LINK ./dart_precompiled_runtime_product
FAILED: dart_precompiled_runtime_product exe.unstripped/dart_precompiled_runtime_product
../../buildtools/linux-x64/clang/bin/clang++ -rdynamic -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -pthread --target=aarch64-linux-gnu --sysroot=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu -Wl,-O2 -Wl,--gc-sections -Wl,--as-needed -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -Wl,--disable-new-dtags -o ./exe.unstripped/dart_precompiled_runtime_product -Wl,--build-id=sha1 -Wl,--start-group @./dart_precompiled_runtime_product.rsp -Wl,--end-group -ldl -lpthread && strip --strip-unneeded -o ./dart_precompiled_runtime_product ./exe.unstripped/dart_precompiled_runtime_product
strip: Unable to recognise the format of the input file `./exe.unstripped/dart_precompiled_runtime_product'
[4446/6380] LINK ./gen_snapshot_product
FAILED: gen_snapshot_product exe.unstripped/gen_snapshot_product
../../buildtools/linux-x64/clang/bin/clang++ -rdynamic -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -pthread --target=aarch64-linux-gnu --sysroot=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/local/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/lib/aarch64-linux-gnu\ -L/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu\ -Wl,-rpath-link=/root/flutter_work/build_engine/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu -Wl,-O2 -Wl,--gc-sections -Wl,--as-needed -Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link= -Wl,--disable-new-dtags -o ./exe.unstripped/gen_snapshot_product -Wl,--build-id=sha1 -Wl,--start-group @./gen_snapshot_product.rsp -Wl,--end-group -ldl -lpthread && strip --strip-unneeded -o ./gen_snapshot_product ./exe.unstripped/gen_snapshot_product
strip: Unable to recognise the format of the input file `./exe.unstripped/gen_snapshot_product'
[4452/6380] CXX clang_x64/obj/third_party/dart/runtime/lib/libdart_lib_jit.ffi_dynamic_library.o
ninja: build stopped: subcommand failed.
Also, what are the implications for x64 for changing from string to llvm-strip?
No implications for x64 because clang_x64 is used for self-building for x64, and the commands installed on a Host are used.
cc_toolchain("clang_x64") {
if (use_clang_type_profiler) {
prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin",
root_build_dir)
} else {
prefix = rebase_path("//buildtools/linux-x64/clang/bin", root_build_dir)
}
cc = "${compiler_prefix}$prefix/clang"
cxx = "${compiler_prefix}$prefix/clang++"
readelf = "readelf"
nm = "nm"
ar = "ar"
ld = cxx
strip = "strip"
toolchain_cpu = "x64"
toolchain_os = "linux"
is_clang = true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No implications for x64 because clang_x64 is used for self-building for x64
Sorry, I didn't expand the context to see that it was in an arm-specific path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dart-sdk is helpful
Interestingly they don't seem to use llvm-strip though; they just do prefixing in that file. Do you know why it's different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much.
First of all, strip command is for x86_64. So, we should use another command for ARM64. dart-sdk uses llvm-objcopy. (source code)
I should have used llvm_objcopy. In addition, "build / toolchain / gcc_toolchain.gni" needed to be modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it to use llvm_objcopy for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed. Could you review the source code when you have time?
|
When I change from The error message |
|
build/toolchain/gcc_toolchain.gni$ man nm |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot this part of the engine work was still outstanding. LGTM.
It looks like Dart is using llvm-objcopy for clang_x64 as well, so we should investigate whether to unify that at some point on our side, but limiting the changes to just arm64 here is the safer option.
|
Do you have a test PR in flutter/engine that uses this commit for the buildroot DEPS that is green, so we can be sure it's safe to land? |
I agree with you. I think it is better to use LLVM commands as well Dart-sdk if you have no specific reasons. The Linux desktop version is still the alpha version, and if you want to change it, I think it's better before the beta version. So, I'll investigate about clang_x64 after this work.
I created the PR (flutter/engine#22284) just now. |
Thanks! Everything is green there, so I'll go ahead and land this. |
|
Thanks. |
…r#390) Added cross-building Flutter Engine for ARM64 Linux platforms. This PR is part of ARM64 Linux support in the Flutter SDK.
Description
Added cross-building Flutter Engine for ARM64 Linux platforms. This PR is part of ARM64 Linux support in the Flutter SDK.
Related PRs
Related Issues
Tests
1. Build Test
First, I confirmed that Flutter Engine can be built for x64 and arm64. The procedure is as follows. All are operations on x64 Linux Host.
Get source code and setup build enviroment.
Cross-build for ARM64 Linux
Build for x64 Linux and Regression test.
2. Run Flutter SDK and app on ARM64 Linux (Jetson Nano)
Second, using the artifacts for ARM64 built by the above procedure, I have confirmed that the Flutter SDK and Flutter app can work fine on Jetson Nano (ARM64 CPU).
All are operations on ARM64 Linux Host (Jetson Nano).
Copy
dart-sdkwhich was locally built to${your installpath}/bin/cache/.Copy the Flutter SDK artifacts (build data) to
${your installpath}/bin/cache/artifacts/enginedirectory manually.out/linux_debug_arm64/flutter_patched_sdkto${your installpath}/bin/cache/artifacts/engine/common/flutter_patched_sdkout/linux_debug_arm64/flutter_linux, gen/const_finder.dart.snapshot, flutter_tester, font-subset, gen/frontend_server.dart.snapshot, icudtl.dat, libflutter_linux_gtk.so, gen/flutter/lib/snapshot/isolate_snapshot.bin, gen/flutter/lib/snapshot/vm_isolate_snapshot.binto${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64out/linux_release_arm64/flutter_patched_sdkto${your installpath}/bin/cache/artifacts/engine/common/flutter_patched_sdk_productout/linux_release_arm64/flutter_linux, libflutter_linux_gtk.soto${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-releaseout/linux_release_arm64/clang_x64/gen_snapshotto${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-release${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-profileis omitted.