+2017-03-22 Carlos Alberto Lopez Perez <clopez@igalia.com>
+
+ [Linux] determineArchitecture is not cross-compile aware
+ https://bugs.webkit.org/show_bug.cgi?id=169886
+
+ Reviewed by Michael Catanzaro.
+
+ Try to detect the target architecture name from the GCC triplet
+ when cross-building.
+
+ The aarch64 architecture is renamed to arm64 (this is coherent with
+ the rest of the perl tooling that consults the architecture determined
+ in determineArchitecture(), the check for this arch is always done
+ with the arm64 name).
+
+ * Scripts/webkitdirs.pm: Remove the isARM() function: its dead code
+ and not cross-build aware.
+ (determineArchitecture): When crossbuilding, try to detect the target
+ architecture name from the GCC triplet.
+ Remove also the fallback option to run the arch command, because this
+ command doesn't print the expected on Mac/BSD, and on Linux is the
+ same than uname -m. See https://bugs.webkit.org/show_bug.cgi?id=152958#c6
+ (isCrossCompilation): Some cross-compilers (buildroot one for example)
+ don't define the --host option. Add another option to detect that
+ we are cross-building by building a dummy program and checking if
+ we can run it.
+
2017-03-22 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Several WPT tests are failing since they were added in the last update in r213882
use File::Find;
use File::Path qw(make_path mkpath rmtree);
use File::Spec;
+use File::Temp qw(tempdir);
use File::stat;
use List::Util;
use POSIX;
}
}
} elsif (isCMakeBuild()) {
- if (open my $cmake_sysinfo, "cmake --system-information |") {
+ if (isCrossCompilation()) {
+ my $compiler = "gcc";
+ $compiler = $ENV{'CC'} if (defined($ENV{'CC'}));
+ my @compiler_machine = split('-', `$compiler -dumpmachine`);
+ $architecture = $compiler_machine[0];
+ } elsif (open my $cmake_sysinfo, "cmake --system-information |") {
while (<$cmake_sysinfo>) {
next unless index($_, 'CMAKE_SYSTEM_PROCESSOR') == 0;
if (/^CMAKE_SYSTEM_PROCESSOR \"([^"]+)\"/) {
$architecture = $1;
- $architecture = 'x86_64' if $architecture eq 'amd64';
last;
}
}
}
if (!isAnyWindows()) {
- if (!$architecture) {
- # Fall back to output of `arch', if it is present.
- $architecture = `arch`;
- chomp $architecture;
- }
-
if (!$architecture) {
# Fall back to output of `uname -m', if it is present.
$architecture = `uname -m`;
}
}
- $architecture = 'x86_64' if ($architecture =~ /amd64/ && isBSD());
+ $architecture = 'x86_64' if $architecture =~ /amd64/i;
+ $architecture = 'arm64' if $architecture =~ /aarch64/i;
}
sub determineASanIsEnabled
return ($^O eq "freebsd") || ($^O eq "openbsd") || ($^O eq "netbsd") || 0;
}
-sub isARM()
-{
- return ($Config{archname} =~ /^arm[v\-]/) || ($Config{archname} =~ /^aarch64[v\-]/);
-}
-
sub isX86_64()
{
return (architecture() eq "x86_64") || 0;
sub isCrossCompilation()
{
- my $compiler = "";
- $compiler = $ENV{'CC'} if (defined($ENV{'CC'}));
- if ($compiler =~ /gcc/) {
- my $compiler_options = `$compiler -v 2>&1`;
- my @host = $compiler_options =~ m/--host=(.*?)\s/;
- my @target = $compiler_options =~ m/--target=(.*?)\s/;
-
- return ($host[0] ne "" && $target[0] ne "" && $host[0] ne $target[0]);
- }
- return 0;
+ my $compiler = "";
+ $compiler = $ENV{'CC'} if (defined($ENV{'CC'}));
+ if ($compiler =~ /gcc/) {
+ 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 "") {
+ return ($host[0] ne $target[0]);
+ } else {
+ # $tempDir gets automatically deleted when goes out of scope
+ my $tempDir = File::Temp->newdir();
+ my $testProgramSourcePath = File::Spec->catfile($tempDir, "testcross.c");
+ my $testProgramBinaryPath = File::Spec->catfile($tempDir, "testcross");
+ open(my $testProgramSourceHandler, ">", $testProgramSourcePath);
+ print $testProgramSourceHandler "int main() { return 0; }\n";
+ system("$compiler $testProgramSourcePath -o $testProgramBinaryPath > /dev/null 2>&1") == 0 or return 0;
+ # Crosscompiling if the program fails to run (because it was built for other arch)
+ system("$testProgramBinaryPath > /dev/null 2>&1") == 0 or return 1;
+ return 0;
+ }
+ }
+ return 0;
}
sub isAppleWebKit()