Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Linux X64 toolchain for non-X64 hosts. #164

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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].
rmacnak-google marked this conversation as resolved.
Show resolved Hide resolved
final x86_64LinuxGnuGcc = _gcc('x86_64-linux-gnu');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on x64 hosts? Can one install the x86_64-linux-gnu-gcc on an x64 host? If so, will it be an alias for gcc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On an X64 Debian machine, if I install g++ I get both /usr/bin/g++ and /usr/bin/x86_64-linux-gnu-g++.


/// [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