android / ndk

The Android Native Development Kit
1.99k stars 257 forks source link

[ISSUE] Issue while compiling android kernel #1511

Closed prabhatKrMishra closed 3 years ago

prabhatKrMishra commented 3 years ago
<inline asm>:1:69: error: invalid operand for instruction
        dup     v1.4s, w14              ;movi   v0.16b, #0              ;aese   v0.16b, v1.16b          ;umov   w14, v0.4s[0]   ;
                                                                                                                                                                    ^
LLVM ERROR: Error parsing inline asm

PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: ld.lld --plugin-opt=O3 -O2 -r -o vmlinux.o -T .tmp_lto.lds --whole-archive built-in.o --no-whole-archive --start-group arch/arm64/lib/lib.a lib/lib.a --end-group 
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'AArch64 Assembly Printer' on function '@ce_aes_expandkey'
 #0 0x00000000025af2f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x25af2f8)
 #1 0x00000000025af180 llvm::sys::RunSignalHandlers() (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x25af180)
 #2 0x00000000025af7bd (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x25af7bd)
 #3 0x00007fccdefbf3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007fccde9d018b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fccde9af859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #6 0x0000000002585e0c (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2585e0c)
 #7 0x0000000002582d47 (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2582d47)
 #8 0x00000000018608f7 (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x18608f7)
 #9 0x000000000185fe82 llvm::AsmPrinter::emitInlineAsm(llvm::MachineInstr const*) const (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x185fe82)
#10 0x000000000185d587 llvm::AsmPrinter::emitFunctionBody() (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x185d587)
#11 0x00000000027a8ba4 (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x27a8ba4)
#12 0x0000000001f6a729 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x1f6a729)
#13 0x0000000001975264 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x1975264)
#14 0x0000000001974f7f llvm::FPPassManager::runOnModule(llvm::Module&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x1974f7f)
#15 0x0000000002299be4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2299be4)
#16 0x0000000002ac1d2a (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2ac1d2a)
#17 0x0000000002ab7e98 llvm::lto::backend(llvm::lto::Config const&, std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream, std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, unsigned int, std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >, llvm::ModuleSummaryIndex&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2ab7e98)
#18 0x0000000002ab6fed llvm::lto::LTO::runRegularLTO(std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream, std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2ab6fed)
#19 0x00000000020b7a0e llvm::lto::LTO::run(std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream, std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, std::__1::function<std::__1::function<std::__1::unique_ptr<llvm::lto::NativeObjectStream, std::__1::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)> (unsigned int, llvm::StringRef)>) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x20b7a0e)
#20 0x00000000020a5879 lld::elf::BitcodeCompiler::compile() (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x20a5879)
#21 0x0000000002098e58 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true> >() (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2098e58)
#22 0x0000000002087aa8 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2087aa8)
#23 0x0000000002073e83 lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2073e83)
#24 0x00000000020723b9 lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x20723b9)
#25 0x0000000002071a4b (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x2071a4b)
#26 0x00000000020717b9 main (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x20717b9)
#27 0x00007fccde9b10b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#28 0x00000000033a1401 _start (/home/pkm/ANDROID/kernel/tools/clang/host/linux-x86/clang-r407598/bin/lld+0x33a1401)
../scripts/link-vmlinux.sh: line 101: 529200 Aborted                 ${LD} ${LDFLAGS} -r -o ${1} $(lto_lds) ${objects}
pirama-arumuga-nainar commented 3 years ago

Based on the stack trace, this is using clang-r407598. @pkm774 Can you share which kernel version you're building?

prabhatKrMishra commented 3 years ago

I cherry-picked commits from here for Clang LTO support. https://github.com/mvaisakh/android_kernel_asus_sdm660/tree/clang-LTO Commit start from https://github.com/mvaisakh/android_kernel_asus_sdm660/commit/240802f5fea8aad3019b0ff7d5b54ecfac57715f and end to https://github.com/mvaisakh/android_kernel_asus_sdm660/commit/1382a1bb60d85d41159644eb65a7d3ab914655c2 My kernel version is 4.4.205.

nickdesaulniers commented 3 years ago

bummer, I can't move issues, but this would be better reported at https://github.com/ClangBuiltLinux/linux/issues.

A few red flags here:

  1. --plugin-opt=O3; generally the kernel uses -O2. -O3 just enables more aggressive loop unrolling which can hurt binary size.
  2. LTO wasn't supported in Android kernels until 4.9, so 4.4 requires backporting which can be easy to miss patches and make things harder for folks to reproduce issues.

I suspect the code in question has been removed the upstream linux kernel; the umov w14, v0.4s[0] looks suspicious but I wasn't able to find it quickly in the kernel sources.

@pkm774 can you please refile this issue in https://github.com/ClangBuiltLinux/linux/issues; it's not specific to the NDK.

DanAlbert commented 3 years ago

it's not specific to the NDK.

The compiler directs folks here for all crashes produced by our compiler (platform too):

PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace.

idk how freeform that config is in the LLVM build, but maybe it could be tweaked to say "$NDK_BUG_URL, $PLATFORM_BUG_URL, $KERNEL_CLANG_BUG_URL, whichever is most appropriate"? (though even better would be loading that from a file so we can customize it for each of our distributions)

nickdesaulniers commented 3 years ago

this may have been fixed by commit 019cd46984d0 ("crypto: arm64/aes-ce-cipher - move assembler code to .S file") which landed in v4.16-rc1.