diff options
author | Ben Murdoch <benm@google.com> | 2016-11-29 16:50:11 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2017-01-12 12:33:05 +0000 |
commit | f91f0611dbaf29ca0f1d4aecb357ce243a19d2fa (patch) | |
tree | d24b57d9c6d116ea509c621669f8ed7ed8658d3f /snapshot_toolchain.gni | |
parent | 28ba1faee73929922c84d2503d2467afa1fea3c3 (diff) | |
download | v8-f91f0611dbaf29ca0f1d4aecb357ce243a19d2fa.tar.gz |
Merge V8 5.4.500.40
Test: Manual - built & ran d8
Change-Id: I4edfa2853d3e565b729723645395688ece3193f4
Diffstat (limited to 'snapshot_toolchain.gni')
-rw-r--r-- | snapshot_toolchain.gni | 97 |
1 files changed, 59 insertions, 38 deletions
diff --git a/snapshot_toolchain.gni b/snapshot_toolchain.gni index ccee7ff5..893bdc58 100644 --- a/snapshot_toolchain.gni +++ b/snapshot_toolchain.gni @@ -25,52 +25,73 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import("//build/config/v8_target_cpu.gni") + declare_args() { - # The snapshot needs to be compiled for the host, but compiled with - # a toolchain that matches the bit-width of the target. + # The v8 snapshot needs to be built by code that is compiled with a + # toolchain that matches the bit-width of the target CPU, but runs on + # the host. v8_snapshot_toolchain = "" } -# TODO(GYP): For now we only support 32-bit little-endian target builds from an -# x64 Linux host. Eventually we need to support all of the host/target -# configurations v8 runs on. +# Try to infer the appropriate snapshot toolchain for the v8_current_cpu +# where possible. +# +# Assume that v8_target_cpu (and hence v8_current_cpu) has been validated +# as supported on the current host CPU and OS in v8_target_cpu.gni. The +# logic below is complicated enough without also needing to do input +# validation. +# +# There are test cases for this code posted as an attachment to +# https://crbug.com/625353. +# +# TODO(GYP): Currently only regular (non-cross) compiles, and cross-compiles +# from x64 hosts to Intel, ARM, or MIPS targets, are implemented. Add support +# for the other supported configurations. + if (v8_snapshot_toolchain == "") { - if (host_cpu == "x64" && host_os == "linux") { - if (target_cpu == "arm" || target_cpu == "mipsel" || target_cpu == "x86") { - if (target_os == "android" || is_clang) { - v8_snapshot_toolchain = "//build/toolchain/linux:clang_x86" - } else if (target_os == "chromeos") { - # TODO(dpranke): crbug.com/608596: Remove this clause once the - # CrOS ebuilds are setting v8_snapshot_toolchain directly and - # we've cleaned up the sysroot settings in //build. - v8_snapshot_toolchain = "//build/toolchain/linux:clang_x86" - } else { - v8_snapshot_toolchain = "//build/toolchain/linux:x86" - } + if (current_os == host_os && current_cpu == host_cpu) { + # This is not a cross-compile, so build the snapshot with the current + # toolchain. + v8_snapshot_toolchain = current_toolchain + } else if (current_os == host_os && current_cpu == "x86" && + host_cpu == "x64") { + # This is an x64 -> x86 cross-compile, but x64 hosts can usually run x86 + # binaries built for the same OS, so build the snapshot with the current + # toolchain here, too. + v8_snapshot_toolchain = current_toolchain + } else if (current_os == "win" && host_os == "mac" && is_clang) { + # This is a mac -> win cross-compile, which is only supported w/ clang. + v8_snapshot_toolchain = "//build/toolchain/mac:clang_${v8_current_cpu}" + } else if (host_cpu == "x64") { + # This is a cross-compile from an x64 host to either a non-Intel target + # cpu or a different target OS. Clang will always be used by default on the + # host, unless this is a ChromeOS build, in which case the same toolchain + # (Clang or GCC) will be used for target and host by default. + if (is_chromeos && !is_clang) { + _clang = "" + } else { + _clang = "clang_" + } - } else if (target_cpu == "x64" || target_cpu == "arm64" || - target_cpu == "mips64el") { - if (target_os == "android" || is_clang) { - v8_snapshot_toolchain = "//build/toolchain/linux:clang_x64" - } else if (target_os == "chromeos") { - # TODO(dpranke): crbug.com/608596: Remove this clause once the - # CrOS ebuilds are setting v8_snapshot_toolchain directly and - # we've cleaned up the sysroot settings in //build. - v8_snapshot_toolchain = "//build/toolchain/linux:clang_x64" - } else { - v8_snapshot_toolchain = "//build/toolchain/linux:x64" - } + if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { + _cpus = v8_current_cpu + } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { + _cpus = "x64_v8_${v8_current_cpu}" + } else if (v8_current_cpu == "arm" || v8_current_cpu == "mipsel") { + _cpus = "x86_v8_${v8_current_cpu}" } else { - assert(false, "Need environment for this arch: $target_cpu") + # This branch should not be reached; leave _cpus blank so the assert + # below will fail. + _cpus = "" + } + + if (_cpus != "") { + v8_snapshot_toolchain = "//build/toolchain/${host_os}:${_clang}${_cpus}" } - } else if (host_os == "mac" && target_os == "win") { - v8_snapshot_toolchain = "//build/toolchain/mac:clang_$target_cpu" - } else { - v8_snapshot_toolchain = default_toolchain } } -# TODO(dpranke): snapshot_toolchain is provided for backwards compatibility -# and should be removed once all callers are updated to refer to -# v8_snapshot_toolchain directly. -snapshot_toolchain = v8_snapshot_toolchain +assert(v8_snapshot_toolchain != "", + "Do not know how to build a snapshot for $current_toolchain " + + "on $host_os $host_cpu") |