Open5
WasmLinux: sys_ni.c ビルド時にICEするのをどうにかしたい
とりあえずbacktraceを確認すると、アセンブラ内でクラッシュしていることがわかる。
#0 0x00007f3b22a0941a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xa0941a)
#1 0x00007f3b22a07334 llvm::sys::RunSignalHandlers() (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xa07334)
#2 0x00007f3b229537a4 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x9537a4)
#3 0x00007f3b2d1d9bb0 __restore_rt (/lib64/libc.so.6+0x3dbb0)
#4 0x00007f3b24084ed7 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2084ed7)
#5 0x00007f3b24080e84 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2080e84)
#6 0x00007f3b24025230 llvm::MCAssembler::Finish() (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2025230)
#7 0x00007f3b232dece9 llvm::AsmPrinter::doFinalization(llvm::Module&) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x12dece9)
#8 0x00007f3b22b5b411 llvm::FPPassManager::doFinalization(llvm::Module&) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xb5b411)
#9 0x00007f3b22b55cb1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xb55cb1)
#10 0x00007f3b2aea582e clang::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>>) (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x1aa582e)
#11 0x00007f3b2b2435ae (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x1e435ae)
#12 0x00007f3b29e94566 clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0xa94566)
#13 0x00007f3b2bcc3629 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x28c3629)
#14 0x00007f3b2bc3d0a4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x283d0a4)
#15 0x00007f3b2bd40962 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x2940962)
#16 0x00000000004151e2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x4151e2)
#17 0x0000000000412065 (/usr/bin/clang-18+0x412065)
#18 0x00007f3b2b8c96bd (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x24c96bd)
#19 0x00007f3b22953534 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x953534)
#20 0x00007f3b2b8c8e67 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x24c8e67)
#21 0x00007f3b2b890f76 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x2490f76)
#22 0x00007f3b2b8911e7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x24911e7)
#23 0x00007f3b2b8ac7f9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/lib64/libclang-cpp.so.18pre20231018.g5a56f0074cf322+0x24ac7f9)
#24 0x0000000000411984 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0x411984)
#25 0x000000000041fb66 main (/usr/bin/clang-18+0x41fb66)
#26 0x00007f3b2d1c3b8a __libc_start_call_main (/lib64/libc.so.6+0x27b8a)
#27 0x00007f3b2d1c3c4b __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27c4b)
#28 0x000000000040ea45 _start (/usr/bin/clang-18+0x40ea45)
... これもう終わってないか。。?つまり、WebAssemblyで使えない機能のチェックが不十分と考えられる。まぁcomputed goto使うだけでクラッシュしたりするし。。
コンパイラを一段づつ実行する
いつもの -fno-integrated-as -fno-integrated-cc1 -save-temps
を使うと、 as
までケースを減らすことができた。
$ /usr/bin/clang-18 -cc1as -triple wasm32 -filetype obj -main-file-name sys_ni.c -target-cpu generic -I ./arch/lkl/include -I ./arch/lkl/include/generated -I ./include -I ./arch/lkl/include/uapi -I ./arch/lkl/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -fdebug-compilation-dir=/home/oku/repos/linux -dwarf-version=4 -mrelocation-model static -o kernel/sys_ni.o sys_ni.s
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/bin/clang-18 -cc1as -triple wasm32 -filetype obj -main-file-name sys_ni.c -target-cpu generic -I ./arch/lkl/include -I ./arch/lkl/include/generated -I ./include -I ./arch/lkl/include/uapi -I ./arch/lkl/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -fdebug-compilation-dir=/home/oku/repos/linux -dwarf-version=4 -mrelocation-model static -o kernel/sys_ni.o sys_ni.s
#0 0x00007f5a6e20941a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xa0941a)
#1 0x00007f5a6e207334 llvm::sys::RunSignalHandlers() (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xa07334)
#2 0x00007f5a6e209acb (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0xa09acb)
#3 0x00007f5a74a5fbb0 __restore_rt (/lib64/libc.so.6+0x3dbb0)
#4 0x00007f5a6f884ed7 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2084ed7)
#5 0x00007f5a6f880e84 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2080e84)
#6 0x00007f5a6f825230 llvm::MCAssembler::Finish() (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x2025230)
#7 0x00007f5a6f8a0d80 (/lib64/libLLVM-18pre20231018.g5a56f0074cf322.so+0x20a0d80)
#8 0x000000000041abe7 cc1as_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x41abe7)
#9 0x000000000041228d (/usr/bin/clang-18+0x41228d)
#10 0x00000000004111b6 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0x4111b6)
#11 0x000000000041fb66 main (/usr/bin/clang-18+0x41fb66)
#12 0x00007f5a74a49b8a __libc_start_call_main (/lib64/libc.so.6+0x27b8a)
#13 0x00007f5a74a49c4b __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27c4b)
#14 0x000000000040ea45 _start (/usr/bin/clang-18+0x40ea45
ケースの最小化
これがダメだった。 ...weakがダメってこと。。?
.text
.file "sys_ni.c"
# Start of file scope inline assembly
.weak sys_io_setup
.set sys_io_setup,sys_ni_syscall
これはCプリプロセッサでinline assemblyとして出力されているようだ。
asm( ".weak " "sys_io_setup" "\n\t" ".set " "sys_io_setup" "," "sys_ni_syscall");
うーん。。たぶん専用のマクロを用意する必要があるが面倒なので後回し。
いったん手動で。。
というかtimerfdとかinotifyは別に有っても良いよねぇ。。どこかのタイミングで有効にしないと。。
ちょっと減らした
futexとかどうすんだろうな。。(他人事)