Skip to content

Commit

Permalink
[native_toolchain_c] Setup Linux X64 toolchain for non-X64 hosts. (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmacnak-google authored Oct 26, 2023
1 parent d79a7cd commit 18bff8c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class CompilerResolver {
return aarch64LinuxGnuGcc;
case Architecture.ia32:
return i686LinuxGnuGcc;
case Architecture.x64:
return x86_64LinuxGnuGcc;
case Architecture.riscv64:
return riscv64LinuxGnuGcc;
}
Expand Down Expand Up @@ -160,6 +162,8 @@ class CompilerResolver {
return aarch64LinuxGnuGccAr;
case Architecture.ia32:
return i686LinuxGnuGccAr;
case Architecture.x64:
return x86_64LinuxGnuGccAr;
case Architecture.riscv64:
return riscv64LinuxGnuGccAr;
}
Expand Down
15 changes: 12 additions & 3 deletions pkgs/native_toolchain_c/lib/src/native_toolchain/gcc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');

Expand Down
6 changes: 6 additions & 0 deletions pkgs/native_toolchain_c/test/native_toolchain/gcc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ void main() {
i686LinuxGnuLd,
]);

testToolSet('x86_64LinuxGnuGcc', [
x86_64LinuxGnuGcc,
x86_64LinuxGnuGccAr,
x86_64LinuxGnuLd,
]);

testToolSet('riscv64LinuxGnuGcc', [
riscv64LinuxGnuGcc,
riscv64LinuxGnuGccAr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 18bff8c

Please sign in to comment.