Skip to content

Commit f2c9bda

Browse files
sstricklCommit Queue
authored andcommitted
Reland "[pkg/vm] Handle cross compilation in dart_precompiled_runtime2."
This is a reland of commit 103ffd6 Parent CL adds "aarch64" as a `uname -m` possibility for ARM64. TEST=manual testing Original change's description: > [pkg/vm] Handle cross compilation in dart_precompiled_runtime2. > > When cross compiling, use qemu-<arch> to run dartaotruntime for > the target architecture. > > TEST=manual testing with native X64 and cross-compiling ARM64 on X64. > > Change-Id: I6ce4e2cfa3108108fe05c7a1fcd2c400a8a47492 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404600 > Reviewed-by: Slava Egorov <[email protected]> > Commit-Queue: Tess Strickland <[email protected]> Change-Id: I4407f64e804fbc19d05440ed961a67b5e1c2c047 Cq-Include-Trybots: luci.dart.try:benchmark-linux-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405761 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 7e080fa commit f2c9bda

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

pkg/vm/tool/dart_precompiled_runtime2

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,43 @@ PROG_NAME="$(follow_links "$BASH_SOURCE")"
2323
# Handle the case where dart-sdk/bin has been symlinked to.
2424
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
2525

26+
. "$CUR_DIR/shared_functions.sh"
27+
2628
if [[ `uname` == 'Darwin' ]];
2729
then
2830
OUT_DIR="$CUR_DIR"/../../../xcodebuild/
2931
else
3032
OUT_DIR="$CUR_DIR"/../../../out/
3133
fi
3234

35+
HOST_ARCH="$(host_arch)"
36+
3337
export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
38+
TARGET_ARCH="$(parse_target_arch "$DART_CONFIGURATION")"
3439
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
40+
if [ ! -d "$BIN_DIR" ]; then
41+
echo "$BIN_DIR is not a directory" >&2
42+
exit 1
43+
fi
44+
45+
QEMU=""
46+
# If the target architecture differs from the host architecture, use qemu
47+
# to run the cross-compiled binary. Cross compilation is denoted by an X
48+
# between the build mode and the architecture name, re.g., ReleaseXARM64 on X64.
49+
if [[ "$DART_CONFIGURATION" =~ (Debug|Release|Product)X[^6] ]] && \
50+
is_cross_compiled "$HOST_ARCH" "$TARGET_ARCH"; then
51+
case "$TARGET_ARCH" in
52+
"ARM64")
53+
QEMU="qemu-aarch64 -L /usr/aarch64-linux-gnu/"
54+
;;
55+
"ARM")
56+
QEMU="qemu-arm -L /usr/arm-linux-gnueabihf/"
57+
;;
58+
*)
59+
echo "No qemu handling for running $TARGET_ARCH binaries on $HOST_ARCH" >&2
60+
exit 1
61+
;;
62+
esac
63+
fi
3564

36-
exec "$BIN_DIR"/dartaotruntime "$@"
65+
exec $QEMU "$BIN_DIR"/dartaotruntime "$@"

0 commit comments

Comments
 (0)