How is thinlto error detected in build system?

I was seeing an error reported for the thinLTO backend but that error code was not reflected by the clang driver. For example, in the regression test thttps://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/thinlto_backend.ll#L34, the clang run results in an error, but the return code of the clang process is still 0. I’m wondering how you usually detect such failures in your builds.

> clang -target x86_64-unknown-linux-gnu -O2 -o thinlto_backend.ll.tmp3.o -x ir 
thinlto_backend.ll.tmp1.o -c -fthinlto-index=thinlto_backend.ll.tmp.thinlto.bc 2>&1
Error running ThinLTO backend: Error loading imported file thinlto_backend.ll.tmp2.o : Could not find module summary

> echo $?
0

I’m not sure this is a by-design of using clang driver to do some ad-hoc actions, but rather an end-to-end compilation. By ad-hoc actions I meant all program actions here: https://github.com/llvm/llvm-project/blob/main/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp#L40 . Those actions do not return an error code and when invoked by the driver they end up with a “success” as the error code : https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/FrontendAction.cpp#L1051

I encountered the same problem, has this problem been solved now?

It’s not unfortunately. We worked it around in our build system.

Can you share the solution? The only way I can think of right now is to capture the error log of it

@htyu