Title: [214250] trunk/Tools
- Revision
- 214250
- Author
- clo...@igalia.com
- Date
- 2017-03-22 07:36:32 -0700 (Wed, 22 Mar 2017)
Log Message
[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.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (214249 => 214250)
--- trunk/Tools/ChangeLog 2017-03-22 11:59:33 UTC (rev 214249)
+++ trunk/Tools/ChangeLog 2017-03-22 14:36:32 UTC (rev 214250)
@@ -1,3 +1,30 @@
+2017-03-22 Carlos Alberto Lopez Perez <clo...@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 <cgar...@igalia.com>
[GTK] Several WPT tests are failing since they were added in the last update in r213882
Modified: trunk/Tools/Scripts/webkitdirs.pm (214249 => 214250)
--- trunk/Tools/Scripts/webkitdirs.pm 2017-03-22 11:59:33 UTC (rev 214249)
+++ trunk/Tools/Scripts/webkitdirs.pm 2017-03-22 14:36:32 UTC (rev 214250)
@@ -40,6 +40,7 @@
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;
@@ -343,12 +344,16 @@
}
}
} 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;
}
}
@@ -358,12 +363,6 @@
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`;
chomp $architecture;
@@ -370,7 +369,8 @@
}
}
- $architecture = 'x86_64' if ($architecture =~ /amd64/ && isBSD());
+ $architecture = 'x86_64' if $architecture =~ /amd64/i;
+ $architecture = 'arm64' if $architecture =~ /aarch64/i;
}
sub determineASanIsEnabled
@@ -1185,11 +1185,6 @@
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;
@@ -1197,16 +1192,28 @@
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()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes