Skip to content

Commit

Permalink
Reverts "Enable native compilation for windows-arm64 " (#141809)
Browse files Browse the repository at this point in the history
Reverts flutter/flutter#137618
Initiated by: Jasguerrero
This change reverts the following previous change:
Original Description:
It's now possible to natively compile a flutter app for
windows-arm64. Cross-compilation is not yet implemented.

Uses arm64 artifacts now available for Dart/Flutter.
Platform detection is based on Abi class, provided by Dart. Depending if
Dart is an arm64 or x64 binary, the Abi is set accordingly.
Initial bootstrap of dart artifacts (update_dart_sdk.ps1) is checking
PROCESSOR_ARCHITECTURE environment variable, which is the way to detect
host architecture on Windows.

This is available only for master channel (on other channels, it
fallbacks to windows-x64).

On windows-x64, it produces an x64 app. On windows-arm64, it produces an
arm64 app.
  • Loading branch information
auto-submit[bot] authored Jan 18, 2024
1 parent 9d9bd88 commit 1901d6f
Show file tree
Hide file tree
Showing 41 changed files with 110 additions and 258 deletions.
17 changes: 1 addition & 16 deletions bin/internal/update_dart_sdk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,7 @@ if (-not $dartSdkBaseUrl) {
if ($engineRealm) {
$dartSdkBaseUrl = "$dartSdkBaseUrl/$engineRealm"
}

# It's important to use the native Dart SDK as the default target architecture
# for Flutter Windows builds depend on the Dart executable's architecture.
$dartZipNameX64 = "dart-sdk-windows-x64.zip"
$dartZipNameArm64 = "dart-sdk-windows-arm64.zip"
$dartZipName = $dartZipNameX64
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$dartSdkArm64Url = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipNameArm64"
Try {
Invoke-WebRequest -Uri $dartSdkArm64Url -UseBasicParsing -Method Head | Out-Null
$dartZipName = $dartZipNameArm64
}
Catch {
Write-Host "The current channel's Dart SDK does not support Windows Arm64, falling back to Windows x64..."
}
}
$dartZipName = "dart-sdk-windows-x64.zip"
$dartSdkUrl = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipName"

if ((Test-Path $dartSdkPath) -or (Test-Path $dartSdkLicense)) {
Expand Down
7 changes: 2 additions & 5 deletions dev/devicelab/lib/tasks/perf_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:convert' show LineSplitter, json, utf8;
import 'dart:ffi' show Abi;
import 'dart:io';
import 'dart:math' as math;

Expand Down Expand Up @@ -954,12 +953,11 @@ class StartupTest {
'--target=$target',
]);
final String basename = path.basename(testDirectory);
final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';
applicationBinaryPath = path.join(
testDirectory,
'build',
'windows',
arch,
'x64',
'runner',
'Profile',
'$basename.exe'
Expand Down Expand Up @@ -1765,12 +1763,11 @@ class CompileTest {
await flutter('build', options: options);
watch.stop();
final String basename = path.basename(cwd);
final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';
final String exePath = path.join(
cwd,
'build',
'windows',
arch,
'x64',
'runner',
'release',
'$basename.exe');
Expand Down
4 changes: 1 addition & 3 deletions dev/devicelab/lib/tasks/plugin_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:ffi';
import 'dart:io';

import 'package:path/path.dart' as path;
Expand Down Expand Up @@ -329,9 +328,8 @@ public class $pluginClass: NSObject, FlutterPlugin {
throw TaskResult.failure('Platform unit tests failed');
}
case 'windows':
final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';
if (await exec(
path.join(rootPath, 'build', 'windows', arch, 'plugins', 'plugintest', 'Release', 'plugintest_test.exe'),
path.join(rootPath, 'build', 'windows', 'x64', 'plugins', 'plugintest', 'Release', 'plugintest_test.exe'),
<String>[],
canFail: true,
) != 0) {
Expand Down
7 changes: 2 additions & 5 deletions dev/devicelab/lib/tasks/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';

import '../framework/devices.dart';
Expand Down Expand Up @@ -174,14 +173,12 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
}
);

final String arch = Abi.current() == Abi.windowsX64 ? 'x64': 'arm64';

static final RegExp _buildOutput = RegExp(
r'Building Windows application\.\.\.\s*\d+(\.\d+)?(ms|s)',
multiLine: true,
);
static final RegExp _builtOutput = RegExp(
r'Built build\\windows\\(x64|arm64)\\runner\\(Debug|Release)\\\w+\.exe( \(\d+(\.\d+)?MB\))?\.',
r'Built build\\windows\\x64\\runner\\(Debug|Release)\\\w+\.exe( \(\d+(\.\d+)?MB\))?\.',
);

@override
Expand All @@ -208,7 +205,7 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {

return true;
},
'Built build\\windows\\$arch\\runner\\$buildMode\\app.exe',
'Built build\\windows\\x64\\runner\\$buildMode\\app.exe',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tools/bin/tool_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ or
else
'flutter',
]);
final String bundlePlatform = targetPlatform;
final String bundlePlatform = targetPlatform.startsWith('windows') ? 'windows' : targetPlatform;
final String target = '${buildMode}_bundle_${bundlePlatform}_assets';
final Process assembleProcess = await Process.start(
flutterExecutable,
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter_tools/lib/src/android/android_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ class AndroidDevice extends Device {
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
throw UnsupportedError('Invalid target platform for Android');
}
}
Expand Down Expand Up @@ -571,7 +570,6 @@ class AndroidDevice extends Device {
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_arm64:
case TargetPlatform.windows_x64:
_logger.printError('Android platforms are only supported.');
return LaunchResult.failed();
Expand Down
15 changes: 3 additions & 12 deletions packages/flutter_tools/lib/src/artifacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ TargetPlatform? _mapTargetPlatform(TargetPlatform? targetPlatform) {
case TargetPlatform.linux_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
Expand Down Expand Up @@ -527,7 +526,6 @@ class CachedArtifacts implements Artifacts {
case TargetPlatform.linux_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
return _getDesktopArtifactPath(artifact, platform, mode);
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
Expand Down Expand Up @@ -745,9 +743,8 @@ class CachedArtifacts implements Artifacts {
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
return _fileSystem.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, _platform, mode));
case Artifact.windowsCppClientWrapper:
final String platformDirName = _enginePlatformDirectoryName(platform);
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
return _fileSystem.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, _platform, mode));
return _fileSystem.path.join(engineArtifactsPath, 'windows-x64', _artifactToFileName(artifact, _platform, mode));
case Artifact.skyEnginePath:
final Directory dartPackageDirectory = _cache.getCacheDir('pkg');
return _fileSystem.path.join(dartPackageDirectory.path, _artifactToFileName(artifact, _platform));
Expand Down Expand Up @@ -778,7 +775,6 @@ class CachedArtifacts implements Artifacts {
case TargetPlatform.linux_arm64:
case TargetPlatform.darwin:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
// TODO(zanderso): remove once debug desktop artifacts are uploaded
// under a separate directory from the host artifacts.
// https://github.com/flutter/flutter/issues/38935
Expand Down Expand Up @@ -817,11 +813,10 @@ TargetPlatform _currentHostPlatform(Platform platform, OperatingSystemUtils oper
}
if (platform.isLinux) {
return operatingSystemUtils.hostPlatform == HostPlatform.linux_x64 ?
TargetPlatform.linux_x64 : TargetPlatform.linux_arm64;
TargetPlatform.linux_x64 : TargetPlatform.linux_arm64;
}
if (platform.isWindows) {
return operatingSystemUtils.hostPlatform == HostPlatform.windows_arm64 ?
TargetPlatform.windows_arm64 : TargetPlatform.windows_x64;
return TargetPlatform.windows_x64;
}
throw UnimplementedError('Host OS not supported.');
}
Expand Down Expand Up @@ -1094,8 +1089,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
return 'linux-x64';
case TargetPlatform.windows_x64:
return 'windows-x64';
case TargetPlatform.windows_arm64:
return 'windows-arm64';
case TargetPlatform.ios:
case TargetPlatform.android:
case TargetPlatform.android_arm:
Expand Down Expand Up @@ -1297,8 +1290,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
return 'linux-x64';
case TargetPlatform.windows_x64:
return 'windows-x64';
case TargetPlatform.windows_arm64:
return 'windows-arm64';
case TargetPlatform.ios:
case TargetPlatform.android:
case TargetPlatform.android_arm:
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/base/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ class AOTSnapshotter {
TargetPlatform.linux_x64,
TargetPlatform.linux_arm64,
TargetPlatform.windows_x64,
TargetPlatform.windows_arm64,
].contains(platform);
}
}
22 changes: 4 additions & 18 deletions packages/flutter_tools/lib/src/base/os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:ffi' show Abi;

import 'package:archive/archive.dart';
import 'package:file/file.dart';
import 'package:meta/meta.dart';
Expand Down Expand Up @@ -474,17 +472,8 @@ class _WindowsUtils extends OperatingSystemUtils {
required super.processManager,
}) : super._private();

HostPlatform? _hostPlatform;

@override
HostPlatform get hostPlatform {
if (_hostPlatform == null) {
final Abi abi = Abi.current();
_hostPlatform = (abi == Abi.windowsArm64) ? HostPlatform.windows_arm64 :
HostPlatform.windows_x64;
}
return _hostPlatform!;
}
HostPlatform hostPlatform = HostPlatform.windows_x64;

@override
void makeExecutable(File file) {}
Expand Down Expand Up @@ -618,17 +607,15 @@ enum HostPlatform {
darwin_arm64,
linux_x64,
linux_arm64,
windows_x64,
windows_arm64;
windows_x64;

String get platformName {
return switch (this) {
HostPlatform.darwin_x64 => 'x64',
HostPlatform.darwin_arm64 => 'arm64',
HostPlatform.linux_x64 => 'x64',
HostPlatform.linux_arm64 => 'arm64',
HostPlatform.windows_x64 => 'x64',
HostPlatform.windows_arm64 => 'arm64',
HostPlatform.windows_x64 => 'x64'
};
}
}
Expand All @@ -639,7 +626,6 @@ String getNameForHostPlatform(HostPlatform platform) {
HostPlatform.darwin_arm64 => 'darwin-arm64',
HostPlatform.linux_x64 => 'linux-x64',
HostPlatform.linux_arm64 => 'linux-arm64',
HostPlatform.windows_x64 => 'windows-x64',
HostPlatform.windows_arm64 => 'windows-arm64',
HostPlatform.windows_x64 => 'windows-x64'
};
}
7 changes: 0 additions & 7 deletions packages/flutter_tools/lib/src/build_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ enum TargetPlatform {
linux_x64,
linux_arm64,
windows_x64,
windows_arm64,
fuchsia_arm64,
fuchsia_x64,
tester,
Expand Down Expand Up @@ -545,7 +544,6 @@ enum TargetPlatform {
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
throw UnsupportedError('Unexpected Fuchsia platform $this');
}
}
Expand All @@ -557,7 +555,6 @@ enum TargetPlatform {
case TargetPlatform.windows_x64:
return 'x64';
case TargetPlatform.linux_arm64:
case TargetPlatform.windows_arm64:
return 'arm64';
case TargetPlatform.android:
case TargetPlatform.android_arm:
Expand Down Expand Up @@ -716,8 +713,6 @@ String getNameForTargetPlatform(TargetPlatform platform, {DarwinArch? darwinArch
return 'linux-arm64';
case TargetPlatform.windows_x64:
return 'windows-x64';
case TargetPlatform.windows_arm64:
return 'windows-arm64';
case TargetPlatform.fuchsia_arm64:
return 'fuchsia-arm64';
case TargetPlatform.fuchsia_x64:
Expand Down Expand Up @@ -761,8 +756,6 @@ TargetPlatform getTargetPlatformForName(String platform) {
return TargetPlatform.linux_arm64;
case 'windows-x64':
return TargetPlatform.windows_x64;
case 'windows-arm64':
return TargetPlatform.windows_arm64;
case 'web-javascript':
return TargetPlatform.web_javascript;
case 'flutter-tester':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class KernelSnapshot extends Target {
switch (targetPlatform) {
case TargetPlatform.darwin:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.linux_x64:
forceLinkPlatform = true;
case TargetPlatform.android:
Expand Down Expand Up @@ -234,7 +233,7 @@ class KernelSnapshot extends Target {
TargetPlatform.darwin => 'macos',
TargetPlatform.ios => 'ios',
TargetPlatform.linux_arm64 || TargetPlatform.linux_x64 => 'linux',
TargetPlatform.windows_arm64 || TargetPlatform.windows_x64 => 'windows',
TargetPlatform.windows_x64 => 'windows',
TargetPlatform.tester || TargetPlatform.web_javascript => null,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class NativeAssets extends Target {
fileSystem,
buildRunner,
);
case TargetPlatform.windows_arm64:
case TargetPlatform.windows_x64:
dependencies = await _buildWindows(
environment,
Expand Down Expand Up @@ -355,7 +354,6 @@ class NativeAssets extends Target {
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
throwToolExit('Unsupported Android target platform: $targetPlatform.');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class DevelopmentShaderCompiler {
case TargetPlatform.linux_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
Expand Down
Loading

0 comments on commit 1901d6f

Please sign in to comment.