| OLD | NEW |
| 1 # Copyright 2015 the V8 project authors. All rights reserved. | 1 # Copyright 2015 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 import("//build/config/v8_target_cpu.gni") | 28 import("//build/config/v8_target_cpu.gni") |
| 29 | 29 |
| 30 declare_args() { | 30 declare_args() { |
| 31 # The snapshot needs to be compiled for the host, but compiled with | 31 # The v8 snapshot needs to be built by code that is compiled with a |
| 32 # a toolchain that matches the bit-width of the target. | 32 # toolchain that matches the bit-width of the target CPU, but runs on |
| 33 # the host. |
| 33 v8_snapshot_toolchain = "" | 34 v8_snapshot_toolchain = "" |
| 34 } | 35 } |
| 35 | 36 |
| 36 # TODO(GYP): For now we only support 32-bit little-endian target builds from an | 37 # Try to infer the appropriate snapshot toolchain for the v8_current_cpu |
| 37 # x64 Linux host. Eventually we need to support all of the host/target | 38 # where possible. |
| 38 # configurations v8 runs on. | 39 # |
| 40 # Assume that v8_target_cpu (and hence v8_current_cpu) has been validated |
| 41 # as supported on the current host CPU and OS in v8_target_cpu.gni. The |
| 42 # logic below is complicated enough without also needing to do input |
| 43 # validation. |
| 44 # |
| 45 # There are test cases for this code posted as an attachment to |
| 46 # https://crbug.com/625353. |
| 47 # |
| 48 # TODO(GYP): Currently only regular (non-cross) compiles, and cross-compiles |
| 49 # from x64 hosts to Intel, ARM, or MIPS targets, are implemented. Add support |
| 50 # for the other supported configurations. |
| 51 |
| 39 if (v8_snapshot_toolchain == "") { | 52 if (v8_snapshot_toolchain == "") { |
| 40 if (host_cpu == "x64" && host_os == "linux") { | 53 |
| 41 if (current_cpu == "arm" || current_cpu == "mipsel" || | 54 if (current_os == host_os && current_cpu == host_cpu) { |
| 42 current_cpu == "x86") { | 55 # This is not a cross-compile, so build the snapshot with the current |
| 43 _snapshot_cpu = "x86" | 56 # toolchain. |
| 57 v8_snapshot_toolchain = current_toolchain |
| 58 |
| 59 } else if (current_os == host_os && current_cpu == "x86" && |
| 60 host_cpu == "x64") { |
| 61 # This is an x64 -> x86 cross-compile, but x64 hosts can usually run x86 |
| 62 # binaries built for the same OS, so build the snapshot with the current |
| 63 # toolchain here, too. |
| 64 v8_snapshot_toolchain = current_toolchain |
| 65 |
| 66 } else if (current_os == "win" && host_os == "mac" && is_clang) { |
| 67 # This is a mac -> win cross-compile, which is only supported w/ clang. |
| 68 v8_snapshot_toolchain = "//build/toolchain/mac:clang_${v8_current_cpu}" |
| 69 |
| 70 } else if (host_cpu == "x64") { |
| 71 # This is a cross-compile from an x64 host to either a non-Intel target |
| 72 # cpu or a different target OS. Assume the same toolchain (Clang or GCC |
| 73 # or MSVS) for target and host, unless this is an Android build, where |
| 74 # Clang is always used on the host. |
| 75 if (is_clang || is_android) { |
| 76 _clang = "clang_" |
| 44 } else { | 77 } else { |
| 45 assert(current_cpu == "arm64" || current_cpu == "x64" || | 78 _clang = "" |
| 46 current_cpu == "mips64el", | |
| 47 "Need environment for this arch: $current_cpu") | |
| 48 _snapshot_cpu = "x64" | |
| 49 } | 79 } |
| 50 | 80 |
| 51 if (v8_current_cpu != _snapshot_cpu) { | 81 if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { |
| 52 _cpus = "${_snapshot_cpu}_v8_${v8_current_cpu}" | 82 _cpus = v8_current_cpu |
| 83 } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { |
| 84 _cpus = "x64_v8_${v8_current_cpu}" |
| 85 } else if (v8_current_cpu == "arm" || v8_current_cpu == "mips") { |
| 86 _cpus = "x86_v8_${v8_current_cpu}" |
| 53 } else { | 87 } else { |
| 54 _cpus = _snapshot_cpu | 88 # This branch should not be reached; leave _cpus blank so the assert |
| 89 # below will fail. |
| 90 _cpus = "" |
| 55 } | 91 } |
| 56 | 92 |
| 57 if ((host_os == "linux" && current_os == "android") || is_clang) { | 93 if (_cpus != "") { |
| 58 v8_snapshot_toolchain = "//build/toolchain/linux:clang_${_cpus}" | 94 v8_snapshot_toolchain = "//build/toolchain/${host_os}:${_clang}${_cpus}" |
| 59 } else { | |
| 60 v8_snapshot_toolchain = "//build/toolchain/linux:${_cpus}" | |
| 61 } | 95 } |
| 62 } else if (host_os == "mac" && current_os == "win") { | |
| 63 assert(v8_current_cpu == current_cpu, | |
| 64 "v8 target must match the regular target on this platform") | |
| 65 v8_snapshot_toolchain = "//build/toolchain/mac:clang_$current_cpu" | |
| 66 } else { | |
| 67 v8_snapshot_toolchain = default_toolchain | |
| 68 } | 96 } |
| 69 } | 97 } |
| 98 |
| 99 assert(v8_snapshot_toolchain != "", |
| 100 "Do not know how to build a snapshot for $current_toolchain " + |
| 101 "on $host_os $host_cpu") |
| OLD | NEW |