Commit 8b5c2bdd authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[mksnapshot] Add runtime flag to specify the target architecture

The mksnapshot-specific runtime flag --target-arch, together with
--target-os, specifies the target platform for the generated embedded.S
file.

Bug: v8:9103
Change-Id: Icb03a381101e7ab0db4a5fbbf3be8e23ed0b1a1c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1624165
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61739}
parent af1b77b1
......@@ -1208,6 +1208,7 @@ template("run_mksnapshot") {
# mksnapshot needs to know which target OS to use at runtime. It's weird,
# but the target OS is really |current_os|.
"--target_os=$current_os",
"--target_arch=$current_cpu",
]
args += invoker.args
......
......@@ -1209,6 +1209,8 @@ DEFINE_STRING(startup_src, nullptr,
"Write V8 startup as C++ src. (mksnapshot only)")
DEFINE_STRING(startup_blob, nullptr,
"Write V8 startup blob file. (mksnapshot only)")
DEFINE_STRING(target_arch, nullptr,
"The mksnapshot target arch. (mksnapshot only)")
DEFINE_STRING(target_os, nullptr, "The mksnapshot target os. (mksnapshot only)")
//
......
......@@ -155,9 +155,14 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
}
void SetEmbeddedVariant(const char* embedded_variant) {
if (embedded_variant == nullptr) return;
embedded_variant_ = embedded_variant;
}
void SetTargetArch(const char* target_arch) { target_arch_ = target_arch; }
void SetTargetOs(const char* target_os) { target_os_ = target_os; }
void WriteEmbedded(const i::EmbeddedData* blob) const {
MaybeWriteEmbeddedFile(blob);
}
......@@ -473,8 +478,18 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
std::map<const char*, int> external_filenames_;
std::vector<const char*> external_filenames_by_index_;
// The file to generate or nullptr.
const char* embedded_src_path_ = nullptr;
// The variant is only used in multi-snapshot builds and otherwise set to
// "Default".
const char* embedded_variant_ = kDefaultEmbeddedVariant;
// {target_arch} and {target_os} control the generated assembly format. Note
// these may differ from both host- and target-platforms specified through
// e.g. V8_OS_* and V8_TARGET_ARCH_* defines.
const char* target_arch_ = nullptr;
const char* target_os_ = nullptr;
};
} // namespace internal
......
......@@ -239,9 +239,9 @@ int main(int argc, char** argv) {
i::EmbeddedFileWriter embedded_writer;
embedded_writer.SetEmbeddedFile(i::FLAG_embedded_src);
if (i::FLAG_embedded_variant != nullptr) {
embedded_writer.SetEmbeddedVariant(i::FLAG_embedded_variant);
}
embedded_writer.SetTargetArch(i::FLAG_target_arch);
embedded_writer.SetTargetOs(i::FLAG_target_os);
std::unique_ptr<char> embed_script(
GetExtraCode(argc >= 2 ? argv[1] : nullptr, "embedding"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment