Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 89b49b1

Browse files
author
Hidenori Matsubayashi
authored
Add support of cross-building the engine for ARM64 Linux Host (#390)
Added cross-building Flutter Engine for ARM64 Linux platforms. This PR is part of ARM64 Linux support in the Flutter SDK.
1 parent 0c6a191 commit 89b49b1

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
Google Inc.
77
Jim Simon <jim.j.simon@gmail.com>
88
The Fuchsia Authors
9+
Hidenori Matsubayashi <Hidenori.Matsubayashi@sony.com>

build/config/sysroot.gni

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ if (current_toolchain == default_toolchain && target_sysroot != "") {
2727
} else if (is_linux && !is_chromeos) {
2828
if (current_cpu == "mipsel") {
2929
sysroot = rebase_path("//mipsel-sysroot/sysroot")
30-
} else if (use_default_linux_sysroot && !is_fuchsia && current_cpu == "x64") {
31-
sysroot = rebase_path("//build/linux/debian_sid_amd64-sysroot")
30+
} else if (use_default_linux_sysroot && !is_fuchsia) {
31+
if (current_cpu == "x64") {
32+
sysroot = rebase_path("//build/linux/debian_sid_amd64-sysroot")
33+
} else {
34+
sysroot = rebase_path("//build/linux/debian_sid_arm64-sysroot")
35+
}
3236
assert(
3337
exec_script("//build/dir_exists.py", [ sysroot ], "string") == "True",
3438
"Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$current_cpu")

build/toolchain/gcc_toolchain.gni

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ analyzer_wrapper =
4545
# Location of the strip executable. When specified, strip will be run on
4646
# all shared libraries and executables as they are built. The pre-stripped
4747
# artifacts will be put in lib.stripped/ and exe.stripped/.
48+
# - llvm_objcopy
49+
# Location of the llvm-objcopy executable. Used as strip instead of strip
50+
# when specified.
4851
template("gcc_toolchain") {
4952
toolchain(target_name) {
5053
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
@@ -169,7 +172,7 @@ template("gcc_toolchain") {
169172
tocfile = sofile + ".TOC"
170173
temporary_tocname = sofile + ".tmp"
171174
link_command = "$ld -shared {{ldflags}} $coverage_flags -o $sofile -Wl,--build-id=sha1 -Wl,-soname=$soname @$rspfile"
172-
toc_command = "{ $readelf -d $sofile | grep SONAME ; $nm -gD -f p $sofile | cut -f1-2 -d' '; } > $temporary_tocname"
175+
toc_command = "{ $readelf -d $sofile | grep SONAME ; $nm -gD -f posix $sofile | cut -f1-2 -d' '; } > $temporary_tocname"
173176
replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi"
174177

175178
command = "$link_command && $toc_command && $replace_command"
@@ -214,7 +217,7 @@ template("gcc_toolchain") {
214217
rspfile = "$outfile.rsp"
215218
unstripped_outfile = outfile
216219

217-
if (defined(invoker.strip)) {
220+
if (defined(invoker.strip) || defined(invoker.llvm_objcopy)) {
218221
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
219222
}
220223

@@ -224,6 +227,10 @@ template("gcc_toolchain") {
224227
strip_command =
225228
"${strip} --strip-unneeded -o $outfile $unstripped_outfile"
226229
command += " && " + strip_command
230+
} else if (defined(invoker.llvm_objcopy)) {
231+
strip = invoker.llvm_objcopy
232+
strip_command = "${strip} --strip-all $unstripped_outfile $outfile"
233+
command += " && " + strip_command
227234
}
228235
if (defined(invoker.postlink)) {
229236
command += " && " + invoker.postlink

build/toolchain/linux/BUILD.gn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ gcc_toolchain("clang_arm64") {
9797
cxx = "${compiler_prefix}$prefix/clang++"
9898

9999
readelf = "readelf"
100-
nm = "nm"
101-
ar = "ar"
100+
nm = "${prefix}/llvm-nm"
101+
ar = "${prefix}/llvm-ar"
102102
ld = cxx
103-
strip = "strip"
103+
llvm_objcopy = "${prefix}/llvm-objcopy"
104104

105105
toolchain_cpu = "arm64"
106106
toolchain_os = "linux"

0 commit comments

Comments
 (0)