Commit 13de00c0 authored by machenbach's avatar machenbach Committed by Commit bot

[foozzie] Support multi-architecture builds

This adds optional multi-architecture builds, allowing to compile
x86 and x64 in one build. The correctness fuzzer can be configured to
compare the two executables, e.g. to compare x86 to x64 run the
launcher with: --second-d8=clang_x86/d8 in an x64 build.

Configuring the executable's architecture is now simplified and
inferred from the gn build configuration.

Building for clusterfuzz has now a new canonical target that can be
used by the infrastructure (defaults to d8).

The clusterfuzz release builder is now defined to compile
multi-arch builds, which will have an effect as soon as the
infrastructure refers to the new clusterfuzz target.

BUG=chromium:673246
NOTRY=true
TBR=mstarzinger,jarin

Review-Url: https://codereview.chromium.org/2649133010
Cr-Commit-Position: refs/heads/master@{#42884}
parent cb19ecd6
......@@ -754,6 +754,7 @@ action("v8_dump_build_config") {
]
args = [
rebase_path("$root_out_dir/v8_build_config.json", root_build_dir),
"current_cpu=\"$current_cpu\"",
"dcheck_always_on=$dcheck_always_on",
"is_asan=$is_asan",
"is_cfi=$is_cfi",
......@@ -762,6 +763,7 @@ action("v8_dump_build_config") {
"is_msan=$is_msan",
"is_tsan=$is_tsan",
"target_cpu=\"$target_cpu\"",
"v8_current_cpu=\"$v8_current_cpu\"",
"v8_enable_i18n_support=$v8_enable_i18n_support",
"v8_enable_inspector=$v8_enable_inspector",
"v8_target_cpu=\"$v8_target_cpu\"",
......@@ -2544,6 +2546,19 @@ group("gn_all") {
}
}
group("v8_clusterfuzz") {
deps = [
":d8",
]
if (v8_multi_arch_build) {
deps += [
":d8(//build/toolchain/linux:clang_x64)",
":d8(//build/toolchain/linux:clang_x86)",
]
}
}
group("v8_fuzzers") {
testonly = true
deps = [
......
......@@ -9,6 +9,9 @@ declare_args() {
# Includes files needed for correctness fuzzing.
v8_correctness_fuzzer = false
# Adds additional compile target for building multiple architectures at once.
v8_multi_arch_build = false
# Indicate if valgrind was fetched as a custom deps to make it available on
# swarming.
v8_has_valgrind = false
......
......@@ -638,7 +638,7 @@
},
'v8_correctness_fuzzer': {
'gn_args': 'v8_correctness_fuzzer=true',
'gn_args': 'v8_correctness_fuzzer=true v8_multi_arch_build=true',
},
'v8_disable_inspector': {
......
......@@ -92,15 +92,21 @@ ORIGINAL_SOURCE_HASH_LENGTH = 3
# Placeholder string if no original source file could be determined.
ORIGINAL_SOURCE_DEFAULT = 'none'
def infer_arch(d8):
"""Infer the V8 architecture from the build configuration next to the
executable.
"""
with open(os.path.join(os.path.dirname(d8), 'v8_build_config.json')) as f:
arch = json.load(f)['v8_current_cpu']
return 'ia32' if arch == 'x86' else arch
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--random-seed', type=int, required=True,
help='random seed passed to both runs')
parser.add_argument(
'--first-arch', help='first architecture', default='x64')
parser.add_argument(
'--second-arch', help='second architecture', default='x64')
parser.add_argument(
'--first-config', help='first configuration', default='fullcode')
parser.add_argument(
......@@ -115,15 +121,6 @@ def parse_args():
parser.add_argument('testcase', help='path to test case')
options = parser.parse_args()
# Ensure we make a sane comparison.
assert (options.first_arch != options.second_arch or
options.first_config != options.second_config) , (
'Need either arch or config difference.')
assert options.first_arch in SUPPORTED_ARCHS
assert options.second_arch in SUPPORTED_ARCHS
assert options.first_config in CONFIGS
assert options.second_config in CONFIGS
# Ensure we have a test case.
assert (os.path.exists(options.testcase) and
os.path.isfile(options.testcase)), (
......@@ -142,11 +139,18 @@ def parse_args():
assert os.path.exists(options.first_d8)
assert os.path.exists(options.second_d8)
# Ensure we use different executables when we claim we compare
# different architectures.
# TODO(machenbach): Infer arch from gn's build output.
if options.first_arch != options.second_arch:
assert options.first_d8 != options.second_d8
# Infer architecture from build artifacts.
options.first_arch = infer_arch(options.first_d8)
options.second_arch = infer_arch(options.second_d8)
# Ensure we make a sane comparison.
assert (options.first_arch != options.second_arch or
options.first_config != options.second_config), (
'Need either arch or config difference.')
assert options.first_arch in SUPPORTED_ARCHS
assert options.second_arch in SUPPORTED_ARCHS
assert options.first_config in CONFIGS
assert options.second_config in CONFIGS
return options
......
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