Skip to content

Commit

Permalink
Revert "[tools] Allow precompiling gen_kernel and compile_platform"
Browse files Browse the repository at this point in the history
This reverts commit 5cda2a8.

Reason for revert: broke Flutter build. 

Original change's description:
> [tools] Allow precompiling gen_kernel and compile_platform
>
> When iterating on core library changes or changes in the AOT compiler
> many seconds are wasted waiting on gen_kernel/compile_platform to
> parse Dart code. This happens because we are running these tools
> from sources on prebuilt Dart SDK.
>
> This CL allows SDK developer to opt-in into AOT compiling these
> tools by adding `precompile_tools=true` to their DART_GN_ARGS.
>
> AOT compilation is performed using prebuilt SDK - so these
> executables do not need to be recompiled if core libraries or
> VM changes reducing iteration cycles.
>
> pkg/vm/tool/precompiler2 is tweaked to detect when DART_GN_ARGS
> contains `precompile_tools=true` and use precompiled
> gen_kernel.exe instead of running it from source.
>
> Using precompiled compile_platform takes vm_platform_strong.dill
> build from 20 seconds to 3 seconds.
>
> Using precompiled gen_kernel takes small benchmark build from
> ~10 seconds to 2 seconds.
>
> TEST=manually tested
>
> Change-Id: Ieec6ad4e1081023d140eb744f0a3cd0c754414ca
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367940
> Commit-Queue: Slava Egorov <[email protected]>
> Reviewed-by: Martin Kustermann <[email protected]>

Change-Id: Id3e4eb44d33516f31c165d9a1e55911e8d356e7f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367960
Commit-Queue: Slava Egorov <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: Alexander Markov <[email protected]>
  • Loading branch information
mraleph authored and Commit Queue committed May 23, 2024
1 parent 9451535 commit a17d709
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 351 deletions.
7 changes: 0 additions & 7 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@ group("analysis_server") {
deps = [ "utils/analysis_server" ]
}

group("tools") {
deps = [
"utils:compile_platform.exe",
"utils:gen_kernel.exe",
]
}

# This is the target that is built on the dart2js build bots.
# It must depend on anything that is required by the dart2js
# test suites.
Expand Down
4 changes: 2 additions & 2 deletions build/dart/dart_action.gni
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (_is_dart) {
import("../toolchain/rbe.gni")
}

template("compiled_action") {
template("_compiled_action") {
assert(defined(invoker.tool), "tool must be defined for $target_name")
assert(defined(invoker.outputs), "outputs must be defined for $target_name")
assert(defined(invoker.args), "args must be defined for $target_name")
Expand Down Expand Up @@ -244,7 +244,7 @@ template("_built_tool_action") {
vm_args += invoker.vm_args
}

compiled_action(target_name) {
_compiled_action(target_name) {
forward_variables_from(invoker,
[
"depfile",
Expand Down
151 changes: 0 additions & 151 deletions build/gn_dart_compile_exe.py

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/front_end/tool/_fasta/entry_points.dart
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,6 @@ Future<void> compilePlatformInternal(CompilerContext c, Uri fullOutput,
}

Future<List<Uri>> computeHostDependencies(Uri hostPlatform) {
// Do not try to parse compile_platform if it was precompiled into a binary.
if (!Platform.script.toFilePath().endsWith('.dart')) {
return Future.value([]);
}

// Returns a list of source files that make up the Fasta compiler (the files
// the Dart VM reads to run Fasta). Until Fasta is self-hosting (in strong
// mode), this is only an approximation, albeit accurate. Once Fasta is
Expand Down
67 changes: 25 additions & 42 deletions pkg/vm/tool/precompiler2
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@

set -e

function follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}

# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
PROG_NAME="$(follow_links "$BASH_SOURCE")"

# Handle the case where dart-sdk/bin has been symlinked to.
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"

SDK_DIR="$CUR_DIR/../../.."

OPTIONS=()
GEN_KERNEL_OPTIONS=()
PACKAGES=
Expand All @@ -39,9 +22,6 @@ BUILD_ASM=0
ARGV=()
for arg in "$@"; do
case $arg in
--packages=sdk)
PACKAGES="$SDK_DIR/.dart_tool/package_config.json"
;;
--packages=*)
PACKAGES="$arg"
;;
Expand Down Expand Up @@ -91,47 +71,50 @@ else
GEN_SNAPSHOT_FILENAME="--elf=${SNAPSHOT_FILE}"
fi

function follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}

# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
PROG_NAME="$(follow_links "$BASH_SOURCE")"

# Handle the case where dart-sdk/bin has been symlinked to.
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"

SDK_DIR="$CUR_DIR/../../.."

if [[ `uname` == 'Darwin' ]]; then
OUT_DIR="$SDK_DIR/xcodebuild"
else
OUT_DIR="$SDK_DIR/out"
fi

HOST_ARCH="X64"
if [[ `uname -m` == 'arm64' ]]; then
HOST_ARCH="ARM64"
fi

export DART_CONFIGURATION=${DART_CONFIGURATION:-Release$HOST_ARCH}
BUILD_DIR="$OUT_DIR/$DART_CONFIGURATION"
export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
BIN_DIR="$OUT_DIR/$DART_CONFIGURATION"

DART="${SDK_DIR}/tools/sdks/dart-sdk/bin/dart"
if [ ! -f "$DART" ]; then
DART="$BUILD_DIR/dart"
DART="$BIN_DIR/dart"
fi

function gen_kernel() {
if [[ "$DART_GN_ARGS" == *"precompile_tools=true"* ]]; then
# Precompile gen_kernel to an AOT app.
ninja -C "$BUILD_DIR" gen_kernel.exe
"$BUILD_DIR/gen_kernel.exe" $@
else
$DART ${DART_VM_FLAGS} "${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" $@
fi
}

# Step 1: Generate Kernel binary from the input Dart source.
gen_kernel --platform "${BUILD_DIR}/vm_platform_strong.dill" \
$DART \
${DART_VM_FLAGS} \
"${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" \
--platform "${BIN_DIR}/vm_platform_strong.dill" \
--aot \
"${GEN_KERNEL_OPTIONS[@]}" \
$PACKAGES \
-o "$SNAPSHOT_FILE.dill" \
"$SOURCE_FILE"



# Step 2: Generate snapshot from the Kernel binary.
"$BUILD_DIR"/gen_snapshot \
"$BIN_DIR"/gen_snapshot \
${GEN_SNAPSHOT_FLAGS} \
"$GEN_SNAPSHOT_OPTION" \
"$GEN_SNAPSHOT_FILENAME" \
Expand Down
6 changes: 0 additions & 6 deletions sdk_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ declare_args() {

# The location in the build output directory of the built Dart SDK.
dart_sdk_output = "dart-sdk"

# When set to `true` will cause compile_platform action to use a precompiled
# compile_platform.dart script instead of running it from source. This
# can significantly improve iteration time when iteration on changes in
# core libraries.
precompile_tools = false
}

if (default_git_folder == "") {
Expand Down
59 changes: 0 additions & 59 deletions utils/BUILD.gn

This file was deleted.

Loading

0 comments on commit a17d709

Please sign in to comment.