Compiling Linux kernel with LLVM and SLH results in "clang frontend command failed with exit code 139"

38 Views Asked by At

I cloned https://gitlab.com/fedora-asahi/kernel-asahi.git; it's Linux kernel tailored for a Fedora distribution meant to run on Apple silicon. I am attempting to build it on a M1 Mac Mini (AArch64). I want to build the kernel with SLH protections enabled. The command I'm running is make LLVM=1 CFLAGS_KERNEL="-mspeculative-load-hardening -Wno-slh-asm-goto" Image. However, I got the following error message

Stack dump:
0.  Program arguments: clang -Wp,-MMD,fs/.open.o.d -nostdinc -I./arch/arm64/include -I./arch/arm64/include/generated -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ --t a#0r g0x0000ffff6946c5e8e tllvm::sys::PrintStackTrace(llvm::raw_ostream&, int)= a(a/lib64/libLLVM-17.sor+c0x91c5e8h)6
4 -#1l i0x0000ffff6946a358n ullvm::sys::RunSignalHandlers()x -(g/lib64/libLLVM-17.son+u0x91a358 )-
f i#2n t0x0000ffff693ac460e g(r/lib64/libLLVM-17.soa+t0x85c460e)d
- a#3s  0x0000ffff734cc800- W(elinux-vdso.so.1r+r0x800o)r
= u#4n k0x0000ffff6b34eb30n o(w/lib64/libLLVM-17.son+-0x27feb30w)a
r n#5i n0x0000ffff6b34d5ccg -(o/lib64/libLLVM-17.sop+t0x27fd5cci)o
n  #6- W0x0000ffff69875a98e rllvm::MachineFunctionPass::runOnFunction(llvm::Function&)r o(r/lib64/libLLVM-17.so=+i0xd25a98g)n
o r#7e d0x0000ffff695e1b40- ollvm::FPPassManager::runOnFunction(llvm::Function&)p t(i/lib64/libLLVM-17.som+i0xa91b40z)a
t i#8o n0x0000ffff695e8dbc- allvm::FPPassManager::runOnModule(llvm::Module&)r g(u/lib64/libLLVM-17.som+e0xa98dbcn)t
  -#9W e0x0000ffff695e2150r rllvm::legacy::PassManagerImpl::run(llvm::Module&)o r(=/lib64/libLLVM-17.soo+p0xa92150t)i
o#10n -0x0000ffff712d47f8i gclang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>)n o(r/lib64/libclang-cpp.so.17e+d0x19d47f8 )-
W#11e r0x0000ffff715dfe20r o(r/lib64/libclang-cpp.so.17=+u0x1cdfe20n)u
s#12e d0x0000ffff70344aa8- cclang::ParseAST(clang::Sema&, bool, bool)o m(m/lib64/libclang-cpp.so.17a+n0xa44aa8d)-
l#13i n0x0000ffff71fc33b4e -clang::FrontendAction::Execute()a r(g/lib64/libclang-cpp.so.17u+m0x26c33b4e)n
t#14  -0x0000ffff71f53b00m lclang::CompilerInstance::ExecuteAction(clang::FrontendAction&)i t(t/lib64/libclang-cpp.so.17l+e0x2653b00-)e
n#15d i0x0000ffff7203d554a nclang::ExecuteCompilerInvocation(clang::CompilerInstance*)  -(D/lib64/libclang-cpp.so.17C+C0x273d554_)U
S#16I N0x0000000000418470G _cc1_main(llvm::ArrayRef<char const*>, char const*, void*)P A(T/usr/bin/clang-17C+H0x418470A)B
L#17E _0x0000000000415eb0F U(N/usr/bin/clang-17C+T0x415eb0I)O
N#18_ E0x0000ffff71c2a604N T(R/lib64/libclang-cpp.so.17Y+ 0x232a604-)D
K#19A S0x0000ffff693ac140A Nllvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)_ S(H/lib64/libLLVM-17.soA+D0x85c140O)W
_#20S C0x0000ffff71c29b98A Lclang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) constE _(S/lib64/libclang-cpp.so.17H+I0x2329b98F)T
=#21  -0x0000ffff71bf7ac0f mclang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) consta c(r/lib64/libclang-cpp.so.17o+-0x22f7ac0p)r
e#22f i0x0000ffff71bf7cd4x -clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) constm a(p/lib64/libclang-cpp.so.17=+.0x22f7cd4/)=
 #23- s0x0000ffff71c0fa60t dclang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&)= g(n/lib64/libclang-cpp.so.17u+10x230fa601) 
-#24f s0x00000000004155f8h oclang_main(int, char**, llvm::ToolContext const&)r t(-/usr/bin/clang-17w+c0x4155f8h)a
r#25  -0x0000000000421578f umainn s(i/usr/bin/clang-17g+n0x421578e)d
-#26c h0x0000ffff687509dca r__libc_start_call_main  -(f/lib64/libc.so.6n+o0x309dc-)c
o#27m m0x0000ffff68750ab0o n__libc_start_main@GLIBC_2.17  -(f/lib64/libc.so.6n+o0x30ab0-)P
I#28E  0x0000000000412bf0- f_startn o(-/usr/bin/clang-17s+t0x412bf0r)i
ct-aliasing -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=1 -Wnoclang-: perror: sclang frontend command failed with exit code 139 (use -v to see invocation)a
bi -fnclang version 17.0.6 (Fedora 17.0.6-2.fc39)o
-Target: aaarch64-unknown-linux-gnus
yThread model: nposixc
hInstalledDir: r/usr/bino
nous-unwind-tables -fno-unwind-tables -mbranch-protection=pac-ret+bti -Wa,-march=armv8.5-a -DARM64_ASM_ARCH=\"armv8.5-a\" -DKASAN_SHADOW_SCALE_SHIFT= -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -fpatchable-function-entry=2 -fsanitize=kcfi -falign-functions=4 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -g -DRANDSTRUCT -frandomize-layout-seed-file=./scripts/basic/randstruct.seed -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=2648 -mspeculative-load-hardening -Wno-slh-asm-goto -DKBUILD_MODFILE=\"fs/open\" -DKBUILD_BASENAME=\"open\" -DKBUILD_MODNAME=\"open\" -D__KBUILD_MODNAME=kmod_open -c -o fs/open.o fs/open.c
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'fs/open.c'.
4.  Running pass 'AArch64 speculation hardening pass' on function '@__arm64_sys_openat2'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.

I can build the kernel just fine with gcc and with LLVM=1 sans the -mspeculative-load-hardening flag. So it looks like the -mspeculative-load-hardening flag is the problem.

I've attached the full build log here: BUILD_OUTPUT.txt

EDIT: When I try compiling now I instead get a failure to compile the start_kernel function in init/main.c. The output log mentions to attach a preprocessed source file and a run script. Here they are (they've been renamed to txt files so that I could attach them):

main-e50bd2.c.txt

main-e50bd2.sh.txt

0

There are 0 best solutions below