1 编译器选择
JackA1ltman edited this page 2026-04-04 23:24:57 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

编译器选择

基础编译 · 第二步

由于旧内核的历史原因,我们没有 XML 和 repo 工具(部分 5.4/4.19 内核除外),编译工具的选择因此更加多样化。

内核版本 ≤ 4.14

Clang二选一

  • AOSP Clang 12Lineage-20.0 分支): https://github.com/LineageOS/android_prebuilts_clang_kernel_linux-x86_clang-r416183b
  • ZyC Clang 10 https://github.com/ZyCromerZ/Clang/releases/download/10.0.1-20220724-release/Clang-10.0.1-20220724.tar.gz

GCCGoogle GCC 4.9android12L-release 分支)

  • ARM64https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9.git
  • ARMhttps://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9.git

该版本 GCC 不含编译器本体,主要用于充当解释器角色。编译命令需添加 LD=ld.lld

内核版本 ≥ 4.19

Clang推荐

  • LLVM 22 https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.2/LLVM-22.1.2-Linux-X64.tar.xz (或 LLVM 1922 均可)
  • Clang Neutron 18https://github.com/Neutron-Toolchains/antman

编译命令:LLVM=1 LLVM_IAS=1

其他可选 Clang

  • ZyC Clanghttps://github.com/ZyCromerZ/Clang
  • Yuki Clang 1818.0.0 分支):https://gitlab.com/TheXPerienceProject/yuki_clang/-/tree/18.0.0
  • AOSP Clang 912https://github.com/Nicklas373/aosp-clang
  • Proton Clang 1319https://gitlab.com/LeCmnGend/clang13 仅限 Ubuntu 18.0420.04
  • LLVM Clang 11master 分支):https://github.com/EviraKernel/Clang-11
  • AOSP Clang 1010.0 分支):https://github.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-6364210.git

纯 GCC 编译可选方案

  • EVA GCChttps://github.com/mvaisakh/gcc-build
  • Linaro GCC(推荐 4.9 / 7.5https://releases.linaro.org/components/toolchain/binaries/ 选择 arm-linux-gnueabiaarch64-linux-gnu
  • ARM 公司 GCC(推荐 9.2https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads 选择 arm-none-linux-gnueabihfaarch64-none-linux-gnu
  • 具有完整编译功能的 Google GCC 4.9
    • ARM64master 分支):https://github.com/KudProject/aarch64-linux-android-4.9.git
    • ARMmain 分支):https://github.com/dandelion64-Archives/arm-linux-androideabi-4.9.git

部分 4.19 内核也可能需要 Clang 10 等低版本编译器。通过修改源码可获得对 Clang 20+ 的支持,但这属于进阶内容。