You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu18.04编译Android11.5.4内核遇'-EL'选项错误求助

问题描述

成功编译U-Boot后,在Ubuntu 18.04环境下编译Android 11.5.4内核时触发以下错误,无法继续:

/usr/bin/as: unrecognized option '-EL'
clang-11: error: assembler command failed with exit code 1 (use -v to see invocation)

已安装的编译环境:

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip u-boot-tools

额外安装了clang 11和llvm 11,但问题未解决,求可用的编译环境参考。

完整编译日志:

===== Build Kernel =====>
CONFIG_KERNEL_VERSION: 5.4
------device/amlogic/vnptt_smb_3/build.config.meson.arm64.trunk-----
KERNEL_DEVICETREE: s4_s905y4_ap222_drm
=====ab update & vendor boot mode=====
=================================
========================================================
= build config: /media/thanhchung/data/s905y4_r_fw/device/amlogic/vnptt_smb_3/build.config.meson.arm64.trunk
. common/build.config.common
. common/build.config.aarch64
. device/amlogic/common/kernelbuild/build.config.common

DEFCONFIG=meson64_a64_defconfig
EXTRA_CMDS=''

#It is a must to set GPU driver's version
GPU_DRV_VERSION=r25p0

KERNEL_DEVICETREE=s4_s905y4_ap222_drm
KERNEL_DEVICETREE_DDR_1G=s4_s905y4_ap222_drm_1g
DTBO_DEVICETREE=android_overlay_dt
PRODUCT_DIRNAME=device/amlogic/vnptt_smb_3
BOARD_DEVICENAME=vnptt_smb_3

ENABLE_KASAN=false

# Not saving any kernel images. This build step is meant purely to generate the .kos.
FILES=""


EXT_MODULES="
vendor/amlogic/common/wifi_bt/wifi/configs/5_4
vendor/amlogic/common/wifi_bt/bluetooth/configs/5_4
vendor/amlogic/common/gpu/bifrost
vendor/amlogic/common/tdk_linuxdriver
hardware/amlogic/media_modules
device/amlogic/common/dolby_ms12/kmod
"

STOP_SHIP_TRACEPRINTK=1

PATH=/media/thanhchung/data/s905y4_r_fw/build/build-tools/path/linux-x86:/media/thanhchung/data/s905y4_r_fw/prebuilts/clang/host/linux-x86/clang-r383902/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

========================================================
 Setting up for build
+ '[' ']'
+ '[' '' == true ']'
+ '[' -n '' ']'
+ cp common/arch/arm64/configs/meson64_a64_R_defconfig common/arch/arm64/configs/meson64_a64_gki_defconfig
+ '[' '!' -z '' ']'
+ '[' '' == user ']'
+ cd common
+ make CC=clang HOSTCC=clang LD=ld.lld NM=llvm-nm OBJCOPY=llvm-objcopy O=/media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common meson64_a64_gki_defconfig
make[1]: Entering directory '/media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common'
  GEN     Makefile
#
# No change to .config
#
make[1]: Leaving directory '/media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common'
+ rm -fr common/arch/arm64/configs/meson64_a64_gki_defconfig
+ set +x
========================================================
 Building kernel
+ grep '\.ko$'
+ find /media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common/ -type f
+ xargs rm -fr
+ '[' ']'
+ cd /media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common
+ make O=/media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common CC=clang HOSTCC=clang LD=ld.lld NM=llvm-nm OBJCOPY=llvm-objcopy
arch/arm64/Makefile:52: Detected assembler with broken .inst; disassembly will be unreliable
  GEN     Makefile
grep: /media/thanhchung/data/s905y4_r_fw/common/.config: No such file or directory
  CC      scripts/mod/empty.o
/usr/bin/as: unrecognized option '-EL'
clang-11: error: assembler command failed with exit code 1 (use -v to see invocation)
make[2]: *** [/media/thanhchung/data/s905y4_r_fw/common/scripts/Makefile.build:283: scripts/mod/empty.o] Error 1
make[1]: *** [/media/thanhchung/data/s905y4_r_fw/common/Makefile:1229: prepare0] Error 2
make[1]: *** Waiting for unfinished jobs....
  DTC     arch/arm64/boot/dts/amlogic/s4_s905y4_ap222_drm.dtb
make: *** [/media/thanhchung/data/s905y4_r_fw/common/Makefile:179: sub-make] Error 2
build kernel error
解决方案

问题根源

错误是因为系统默认的GNU汇编器/usr/bin/as不支持ARM64所需的-EL(小端模式)选项,而编译ARM64内核需要使用LLVM汇编器llvm-as。

修复步骤

  1. 指定LLVM汇编器编译
    修改编译命令,添加AS=llvm-as参数,强制clang使用LLVM汇编器:

    make O=/media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common CC=clang HOSTCC=clang LD=ld.lld NM=llvm-nm OBJCOPY=llvm-objcopy AS=llvm-as
    
  2. 完善LLVM工具链安装
    Ubuntu 18.04默认的llvm-11包可能不完整,安装全量组件:

    sudo apt-get install llvm-11 llvm-11-dev llvm-11-tools clang-11 lld-11
    
  3. 确保prebuilts clang优先级
    你的PATH中已经包含Android源码自带的prebuilts clang路径/media/thanhchung/data/s905y4_r_fw/prebuilts/clang/host/linux-x86/clang-r383902/bin,确认该路径在系统clang之前,避免调用系统版本。可通过echo $PATH查看顺序,若位置不对,手动调整:

    export PATH=/media/thanhchung/data/s905y4_r_fw/prebuilts/clang/host/linux-x86/clang-r383902/bin:$PATH
    
  4. 验证汇编器可用性
    检查当前使用的汇编器:

    which as  # 若输出/usr/bin/as,说明系统汇编器仍在优先位置
    llvm-as --version  # 确认LLVM汇编器可正常调用
    

内容的提问来源于stack exchange,提问作者ChunhThanhDe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 08:05:38