summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiakai Zhang <jiakaiz@google.com>2024-04-16 16:43:49 +0100
committerJiakai Zhang <jiakaiz@google.com>2024-04-18 10:44:48 +0000
commitbda11bd68212f6a03381a849b0ee44bebf3ca5ba (patch)
treeda41e18160919cfbe4c251176659631d33a2076e
parent16567ac3d6925c0b84c819f2e475c2cadbde5dc3 (diff)
downloadart-bda11bd68212f6a03381a849b0ee44bebf3ca5ba.tar.gz
Add instructions for generating boot images for local Compiler Explorer.
Also, update the instructions to build Compiler Explorer only once. Bug: 330519779 Test: Follow the instructions. Change-Id: I9ca1a7de1b81237ff78faff73a277e5504f580a4
-rw-r--r--test/generate-boot-image/generate-boot-image.cc12
-rw-r--r--tools/compiler-explorer/compiler-explorer.md48
2 files changed, 53 insertions, 7 deletions
diff --git a/test/generate-boot-image/generate-boot-image.cc b/test/generate-boot-image/generate-boot-image.cc
index 671aa379f1..3cd992f0c6 100644
--- a/test/generate-boot-image/generate-boot-image.cc
+++ b/test/generate-boot-image/generate-boot-image.cc
@@ -20,6 +20,7 @@
#include <algorithm>
#include <cstdlib>
#include <iostream>
+#include <iterator>
#include <string>
#include <vector>
@@ -50,7 +51,7 @@ using ::art::testing::GetLibCoreDexLocations;
constexpr const char* kUsage = R"(
A commandline tool to generate a primary boot image for testing.
-Usage: generate-boot-image --output-dir=OUTPUT_DIR [OPTIONS]...
+Usage: generate-boot-image --output-dir=OUTPUT_DIR [OPTIONS]... [-- [DEX2OAT_OPTIONS]...]
Supported options:
--help: Print this text.
@@ -79,6 +80,7 @@ Supported options:
host. The default on target is based on the ISA of this binary.
--core-only=true|false: If true, only compile ART jars. Otherwise, also compile core-icu4j and
conscrypt. Default: false
+ --: Arguments following '--' are directly passed to dex2oat.
)";
struct Options {
@@ -92,6 +94,7 @@ struct Options {
std::string profile_file = "";
std::string instruction_set = "";
bool core_only = false;
+ std::vector<std::string> dex2oat_options;
};
[[noreturn]] void Usage(const std::string& message) {
@@ -162,6 +165,9 @@ int GenerateBootImage(const Options& options) {
args.push_back(StringPrintf("--image=%s/boot.art", path.c_str()));
args.push_back(StringPrintf("--oat-file=%s/boot.oat", path.c_str()));
+ std::move(
+ options.dex2oat_options.begin(), options.dex2oat_options.end(), std::back_inserter(args));
+
int exit_code = system(BuildCommand(args).c_str());
if (exit_code != 0) {
LOG(ERROR) << "dex2oat invocation failed. Exit code: " << exit_code;
@@ -203,6 +209,10 @@ int Main(int argc, char** argv) {
Usage(ART_FORMAT("Unrecognized --core-only value: '{}'", arg));
}
options.core_only = result == ParseBoolResult::kTrue;
+ } else if (arg == "--") {
+ for (i++; i < argc; i++) {
+ options.dex2oat_options.push_back(argv[i]);
+ }
} else {
Usage(ART_FORMAT("Unrecognized argument: '{}'", argv[i]));
}
diff --git a/tools/compiler-explorer/compiler-explorer.md b/tools/compiler-explorer/compiler-explorer.md
index ff05487575..95866c14ea 100644
--- a/tools/compiler-explorer/compiler-explorer.md
+++ b/tools/compiler-explorer/compiler-explorer.md
@@ -39,8 +39,8 @@ This doc describes how to run a local instance of Compiler Explorer
lunch aosp_cf_x86_64_phone-trunk_staging-userdebug
```
- Note: You may use a different `lunch` target, as long as it can build the host binaries in the
- later steps.
+ Note: You may use a different `lunch` target, as long as it can build the
+ host binaries in the later steps.
1. Configure Compiler Explorer.
@@ -51,6 +51,12 @@ This doc describes how to run a local instance of Compiler Explorer
xargs sed -i 's?{{compilersDir}}?'$COMPILER_EXPLORER_DIR/compilers'?'
```
+1. Build Compiler Explorer.
+
+ ```
+ (cd $COMPILER_EXPLORER_DIR/compiler-explorer && make prebuild)
+ ```
+
1. Build and copy compilers except dex2oat.
```
@@ -80,14 +86,44 @@ This doc describes how to run a local instance of Compiler Explorer
Note: You may choose to do this on `master-art` instead of on a full Android
source tree if you wish.
+1. Generate boot images (optional but recommended).
+
+ ```
+ declare -a instruction_sets=("arm" "arm64" "x86" "x86_64" "riscv64")
+ m generate-boot-image
+ rm -rf $COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app
+ mkdir -p $COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app/apex/com.android.art/javalib
+ cp $COMPILER_EXPLORER_DIR/compilers/dex2oat-local/bootjars/* \
+ $COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app/apex/com.android.art/javalib
+ mkdir -p $COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app/system/framework
+ for instruction_set in "${instruction_sets[@]}"; do
+ $ANDROID_HOST_OUT/bin/generate-boot-image64 \
+ --output-dir=$COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app/system/framework \
+ --compiler-filter=speed \
+ --use-profile=false \
+ --dex2oat-bin=$COMPILER_EXPLORER_DIR/compilers/dex2oat-local/x86_64/bin/dex2oat64 \
+ --android-root=$COMPILER_EXPLORER_DIR/compilers/dex2oat-local/app \
+ --core-only=true \
+ --instruction-set=$instruction_set \
+ -- \
+ --runtime-arg \
+ -Xgc:CMC
+ done
+ ```
+
+ Note: You may change `instruction_sets` on the first line to only include
+ the instruction sets that you need, to speed up boot image generation.
+
+ Note: Although this step is not required, having boot images makes dex2oat generate better code.
+
1. Start Compiler Explorer server.
```
- (cd $COMPILER_EXPLORER_DIR/compiler-explorer && make)
+ (cd $COMPILER_EXPLORER_DIR/compiler-explorer && make run-only)
```
- This may take a while. Once you see `Listening on http://localhost:10240/`,
- you can open a browser with that address to access Compiler Explorer.
+ Once you see `Listening on http://localhost:10240/`, you can open a browser
+ with that address to access Compiler Explorer.
When you iterate, press `Ctrl+C` to stop the server, and then repeat the last
-two steps.
+three steps.