<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75441>75441</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Distributed thinlto `Error loading imported file` return 0
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zcfh
      </td>
    </tr>
</table>

<pre>
    #problem
The following script can reproduce the scenario I mentioned. When using `-fthinlto-index` to optimization, if the dependent file cannot be found, only an error will be output, and the return value will still be 0, making it impossible to determine whether an error occurred.
# script
```shell
project=tmp_thinlto_test
# mkdir -p $project
# cd $project

main_str='int lib_func(int val);
int main(int argc, char **argv) {
  return lib_func(1);
}
'

lib_str='int lib_func(int val) {
  return val + 123;
}
'

echo "$main_str" > file1.cc
echo "$lib_str" > file2.cc


set -x
pwd
clang++ -c file1.cc file2.cc -O2 -g -flto=thin
clang++ -flto=thin -fuse-ld=lld -Wl,--thinlto-emit-imports-files,--thinlto-index-only -O2 file1.o file2.o

# file1.o dep file2.o
rm file2.o
clang++ -O2 -o file1.native.o -x ir file1.o -c -fthinlto-index=./file1.o.thinlto.bc


echo "return code $?"
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVMGO2zgM_Rr5QsiwaSduDj7MNA2wp70s0ONAlmhbW1kyJDmZ9usXcpxMsh2gQKBY4iP59ChShKAHS9Sy3SvbHTOxxNH59pfsx6xz6mfLsJq96wxNrDiy4uWfkaB3xriLtgME6fUcQQoLnmbv1CIJ4kgQJFnhtYO_YCIbtbOkcvg-koUlJE-2L3gfR21NdFxbRe9sX0B04OaoJ_1LJB-GX0H3a0BFM1lFNkKvDaWM1kXoEpnFqgR01vwEYYG8dx4u2phkdkucl5jswqo1kqe4eAtnYRa6wkLcwEXCTeJHIqgj6Gl2IejOUCKmKJKftCW4jBRH8h_JnJ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