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 t, 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 $?

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: llvm-project/ExecuteCompilerInvocation.cpp at main · llvm/llvm-project · GitHub . Those actions do not return an error code and when invoked by the driver they end up with a “success” as the error code : llvm-project/FrontendAction.cpp at main · llvm/llvm-project · GitHub