クロスコンパイルとは?
クロスコンパイルは、あるプラットフォーム(host)上でソフトウェアを構築し、別のプラットフォーム(target)で実行できるようにすることです。例えば x86 の macOS マシンから ARM64 Linux バイナリを生成します。target のアーキテクチャと OS 向けに構成されたツールチェーンを使います。これにより、1 つの CI runner が自身では実行できないプラットフォーム向けの artifact を生成できます。
なぜ重要か
すべての target アーキテクチャでネイティブに構築するには、それぞれに runner を維持する必要があり、遅く高コストです。クロスコンパイルは、1 つの runner が多くの target 向けのバイナリを出力できるようにしますが、host はしばしばエミュレーションなしに cross-built の出力を実行できないため、テストが複雑になります。
関連する概念
- host プラットフォームが異なる target プラットフォーム向けに構築する
- target triple が target を正確に名付ける
- cross-built バイナリのテストにはしばしばエミュレーションが必要
関連ガイド
What Is a Toolchain?A toolchain is the coordinated set of tools used to build software, such as the compiler, linker, and build s…
What Is a Target Triple?A target triple is a string like x86_64-unknown-linux-gnu that identifies the architecture, vendor, OS, and A…
What Is Static Linking?Static linking bundles a program's library dependencies directly into the executable at build time, producing…