assembly /usr/bin/作为:无法识别的选项“-EL”

fquxozlt  于 2023-02-16  发布在  其他
关注(0)|答案(3)|浏览(713)

因此,在为我的1Plus手机编译Android内核时,经过3天的多次尝试,我放弃了,并尝试在这里询问是否有人以前遇到过这个问题。
这个bug对我来说有点模糊,但是我感觉问题来自于我最近对GNU/Linux发行版(Gentoo)的更改,它在不应该覆盖AS环境变量时以某种方式覆盖了它;它在组装VDSO时失败了,但我不知道重写是从哪里来的。(也许他们修改了make命令,以便允许支持标记重写等。)
编辑,小号:

make RANLIB=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ranlib CC='/media/sda2/git/linux-x86/clang-bootstrap/bin/clang -fintegrated-as' LD=/media/sda2/git/linux-x86/clang-bootstrap/bin/ld.lld AR=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ar AS=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-as NM=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-nm OBJCOPY=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objcopy OBJDUMP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objdump READELF=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-readelf OBJSIZE=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-size STRIP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-strip
  CC      kernel/bounds.s
  CC      arch/arm64/kernel/asm-offsets.s
In file included from arch/arm64/kernel/asm-offsets.c:25:
In file included from ./include/linux/kvm_host.h:39:
In file included from ./arch/arm64/include/asm/kvm_host.h:42:
In file included from ./include/kvm/arm_pmu.h:21:
In file included from ./include/linux/perf_event.h:57:
In file included from ./include/linux/cgroup.h:28:
./include/linux/cgroup-defs.h:475:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
        struct cgroup cgrp;
                      ^
1 warning generated.
  CALL    scripts/checksyscalls.sh
  LDS     arch/arm64/kernel/vdso/vdso.lds
  VDSOA   arch/arm64/kernel/vdso/gettimeofday.o 
/usr/bin/as: unrecognized option '-EL'
clang-12: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [arch/arm64/kernel/vdso/Makefile:57: arch/arm64/kernel/vdso/gettimeofday.o] Error 1
make: *** [arch/arm64/Makefile:201: vdso_prepare] Error 2

环境变量:

# https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
export PATH='/media/sda2/git/aarch64-linux-android-4.9/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/aarch64-linux-android-4.9/lib':${LD_LIBRARY_PATH}

# git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
export PATH='/media/sda2/git/linux-x86/clang-bootstrap/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/linux-x86/clang-bootstrap/lib':${LD_LIBRARY_PATH}

export ARCH=arm64 
export SUBARCH=arm64
export CROSS_COMPILE='aarch64-linux-android-'
export CROSS_COMPILER=$PATH
export CLANG_TRIPLE='aarch64-linux-gnu-'
export KCFLAGS='-pipe -O3'
export KCPPFLAGS='-pipe -O3'

使用的内核:https://github.com/LineageOS/android_kernel_oneplus_sm8250
有什么想法吗?
我使用Google的clang预构建编译器(可以自己构建,但为了节省时间),以便使用polly编译Android内核,因为Gentoo LLVM团队显然还没有它的使用标志。
更糟糕的是,我想使用Ubuntu binutils/automake等/创建一个docker环境来编译这个内核,但这对我来说没有多大意义,因为我应该能够在自己的主机系统上完成它。
谢谢你的帮助和照顾。

siv3szwd

siv3szwd1#

我解决了这个问题。在删除了链接器的LD=/media/sda 2/git/linux-x86/clang-bootstrap/bin/ld.lld之后,它工作了,我想clang链接器默认使用的是/usr/bin/as,而不是谷歌预建的aarch 64-linux-android-as。我需要进一步调查。我会在找到更多信息后编辑这篇文章。

csga3l58

csga3l582#

我遇到过同样的问题,根本原因是应该在PATH之前添加CLANG_PATH。

// have chance to use /usr/bin/as
export PATH=$PATH:$CLANG_PATH // wrong

export PATH=${CLANG_PATH}:${PATH} // correct

忽略
1.正确设置交叉编译工具补丁
原因是您没有正确设置CROSS_COMPILE和CROSS_COMPILE_ARM32。
aarch 64-linux-android-as在PATH中找不到,所以使用/usr/bin/as,应该把交叉编译工具放到patch中,或者只设置绝对patch,如下所示:

export CROSS_COMPILE=$CROSS/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export CROSS_COMPILE_ARM32=$CROSS/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-

1.进行解除配置时不设置LD

- make CC=clang LD=ld.lld HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig
+ make CC=clang HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig

我在一个脚本中对这个问题做了修改,但在另一个构建脚本中从未遇到过。通过比较这两个文件,我发现正确的文件在make defconfig中没有设置LD=ld.lld。

r55awzrz

r55awzrz3#

我有和你一样的错误,但是我找不到在哪里声明环境变量:您提到的。我能问一下在哪里申报吗?

========================================================
 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
+ find /media/thanhchung/data/s905y4_r_fw/out/android11-5.4/common/ -type f
+ grep '\.ko$'
+ 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
  DTC     arch/arm64/boot/dts/amlogic/s4_s905y4_ap222_drm.dtb
  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....
make: *** [/media/thanhchung/data/s905y4_r_fw/common/Makefile:179: sub-make] Error 2

相关问题