Check values of variables before extracting index in perl
https://bugs.webkit.org/show_bug.cgi?id=202333

Patch by Paulo Matos <pmatos@igalia.com> on 2019-10-17
Reviewed by Jonathan Bedard.

If compiler doesn't properly report the host and target it was
compiled for, lacking better information we just go ahead and assume
there is no cross compilation involved.

* Scripts/webkitdirs.pm:
(isCrossCompilation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 198a770..5efff43 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,17 @@
+2019-10-17  Paulo Matos  <pmatos@igalia.com>
+
+        Check values of variables before extracting index in perl
+        https://bugs.webkit.org/show_bug.cgi?id=202333
+
+        Reviewed by Jonathan Bedard.
+
+        If compiler doesn't properly report the host and target it was
+        compiled for, lacking better information we just go ahead and assume
+        there is no cross compilation involved.
+        
+        * Scripts/webkitdirs.pm:
+        (isCrossCompilation):
+
 2019-10-17  Pablo Saavedra  <psaavedra@igalia.com>
 
         Add a driver for MiniBrowser running with WPE for
diff --git a/Tools/Scripts/webkitdirs.pm b/Tools/Scripts/webkitdirs.pm
index ae7942e..15de5e3 100755
--- a/Tools/Scripts/webkitdirs.pm
+++ b/Tools/Scripts/webkitdirs.pm
@@ -1390,7 +1390,12 @@
         my $compilerOptions = `$compiler -v 2>&1`;
         my @host = $compilerOptions =~ m/--host=(.*?)\s/;
         my @target = $compilerOptions =~ m/--target=(.*?)\s/;
-        if ($target[0] ne "" && $host[0] ne "") {
+        if (!@target || !@host) {
+            # Sometimes a compiler does not report the host of target it was compiled for,
+            # in which case, lacking better information we assume we are not cross-compiling.
+            return 0;
+        }
+        elsif ($target[0] ne "" && $host[0] ne "") {
                 return ($host[0] ne $target[0]);
         } else {
                 # $tempDir gets automatically deleted when goes out of scope