From fac27417e8a4a08738ed689450b98f1544274f6a Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 25 Oct 2023 11:02:45 -0700 Subject: [PATCH] [native_toolchain_c] Setup Linux X64 toolchain for non-X64 hosts. --- .../lib/src/cbuilder/compiler_resolver.dart | 4 ++++ .../lib/src/native_toolchain/gcc.dart | 15 ++++++++++++--- .../test/native_toolchain/gcc_test.dart | 6 ++++++ .../test/native_toolchain/recognizer_test.dart | 3 +++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart index cb4afb8a6..f724085a4 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart @@ -74,6 +74,8 @@ class CompilerResolver { return aarch64LinuxGnuGcc; case Architecture.ia32: return i686LinuxGnuGcc; + case Architecture.x64: + return x86_64LinuxGnuGcc; case Architecture.riscv64: return riscv64LinuxGnuGcc; } @@ -160,6 +162,8 @@ class CompilerResolver { return aarch64LinuxGnuGccAr; case Architecture.ia32: return i686LinuxGnuGccAr; + case Architecture.x64: + return x86_64LinuxGnuGccAr; case Architecture.riscv64: return riscv64LinuxGnuGccAr; } diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/gcc.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/gcc.dart index 3550f99ac..c3ea2942f 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/gcc.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/gcc.dart @@ -7,15 +7,15 @@ import 'package:native_assets_cli/native_assets_cli.dart'; import '../tool/tool.dart'; import '../tool/tool_resolver.dart'; -/// The GNU Compiler Collection. +/// The GNU Compiler Collection for [Architecture.current]. /// /// https://gcc.gnu.org/ final gcc = Tool(name: 'GCC'); -/// The GNU GCC archiver. +/// The GNU GCC archiver for [Architecture.current]. final gnuArchiver = Tool(name: 'GNU archiver'); -/// The GNU linker. +/// The GNU linker for [Architecture.current]. /// /// https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/ld.html final gnuLinker = Tool(name: 'GNU linker'); @@ -29,6 +29,15 @@ final i686LinuxGnuGccAr = _gnuArchiver('i686-linux-gnu'); /// [gnuLinker] with [Tool.defaultResolver] for [Architecture.ia32]. final i686LinuxGnuLd = _gnuLinker('i686-linux-gnu'); +/// [gcc] with [Tool.defaultResolver] for [Architecture.x64]. +final x86_64LinuxGnuGcc = _gcc('x86_64-linux-gnu'); + +/// [gnuArchiver] with [Tool.defaultResolver] for [Architecture.x64]. +final x86_64LinuxGnuGccAr = _gnuArchiver('x86_64-linux-gnu'); + +/// [gnuLinker] with [Tool.defaultResolver] for [Architecture.x64]. +final x86_64LinuxGnuLd = _gnuLinker('x86_64-linux-gnu'); + /// [gcc] with [Tool.defaultResolver] for [Architecture.arm]. final armLinuxGnueabihfGcc = _gcc('arm-linux-gnueabihf'); diff --git a/pkgs/native_toolchain_c/test/native_toolchain/gcc_test.dart b/pkgs/native_toolchain_c/test/native_toolchain/gcc_test.dart index 570b08990..c87f53e07 100644 --- a/pkgs/native_toolchain_c/test/native_toolchain/gcc_test.dart +++ b/pkgs/native_toolchain_c/test/native_toolchain/gcc_test.dart @@ -60,6 +60,12 @@ void main() { i686LinuxGnuLd, ]); + testToolSet('x86_64LinuxGnuGcc', [ + x86_64LinuxGnuGcc, + x86_64LinuxGnuGccAr, + x86_64LinuxGnuLd, + ]); + testToolSet('riscv64LinuxGnuGcc', [ riscv64LinuxGnuGcc, riscv64LinuxGnuGccAr, diff --git a/pkgs/native_toolchain_c/test/native_toolchain/recognizer_test.dart b/pkgs/native_toolchain_c/test/native_toolchain/recognizer_test.dart index b26676ec7..0f18d39bb 100644 --- a/pkgs/native_toolchain_c/test/native_toolchain/recognizer_test.dart +++ b/pkgs/native_toolchain_c/test/native_toolchain/recognizer_test.dart @@ -42,6 +42,9 @@ void main() async { RecognizerTest(riscv64LinuxGnuGcc, CompilerRecognizer.new), RecognizerTest(riscv64LinuxGnuGccAr, ArchiverRecognizer.new), RecognizerTest(riscv64LinuxGnuLd, LinkerRecognizer.new), + RecognizerTest(x86_64LinuxGnuGcc, CompilerRecognizer.new), + RecognizerTest(x86_64LinuxGnuGccAr, ArchiverRecognizer.new), + RecognizerTest(x86_64LinuxGnuLd, LinkerRecognizer.new), ]; for (final test in tests) {