diff --git a/pkg/smith/lib/configuration.dart b/pkg/smith/lib/configuration.dart index 85a11f3f0ba..ec3167e37f8 100644 --- a/pkg/smith/lib/configuration.dart +++ b/pkg/smith/lib/configuration.dart @@ -622,6 +622,45 @@ class Architecture extends NamedEnum { } const Architecture._(String name) : super(name); + + static final Architecture host = _computeHost(); + static Architecture _computeHost() { + String? arch; + if (Platform.isWindows) { + arch = Platform.environment["PROCESSOR_ARCHITECTURE"]; + } else { + arch = (Process.runSync("uname", ["-m"]).stdout as String).trim(); + } + + switch (arch) { + case "i386": + case "i686": + case "ia32": + case "x86": + case "X86": + return ia32; + case "x64": + case "x86-64": + case "x86_64": + case "amd64": + case "AMD64": + return x64; + case "armv7l": + case "ARM": + return arm; + case "aarch64": + case "arm64": + case "arm64e": + case "ARM64": + return arm64; + case "riscv32": + return riscv32; + case "riscv64": + return riscv64; + } + + throw "Unknown host architecture: $arch"; + } } class Compiler extends NamedEnum { diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart index 3f8451a12c9..ed15fda4cb5 100644 --- a/pkg/test_runner/lib/src/options.dart +++ b/pkg/test_runner/lib/src/options.dart @@ -107,7 +107,7 @@ none: No runtime, compile only.''') ..addMultiOption('arch', abbr: 'a', allowed: ['all', ...Architecture.names], - defaultsTo: [Architecture.x64.name], + defaultsTo: [Architecture.host.name], hide: true, help: '''The architecture to run tests for. @@ -935,7 +935,7 @@ void findConfigurations(Map options) { var architectureOption = options['arch'] as List; var architectures = [ if (architectureOption.isEmpty) - Architecture.x64 + Architecture.host else if (!architectureOption.contains('all')) ...architectureOption.map(Architecture.find) ];