<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109634>109634</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Can't compile RISC-V vector intrisics with precompiled headers (PCH)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Ferdi265
</td>
</tr>
</table>
<pre>
## Summary
Clang supports RISC-V vector intrinsics (`#include <riscv_vector.h>`), but fails to compile them when precompiled headers (PCH) are being used. This affects [clangd](https://github.com/clangd/clangd/issues/2143) since it precompiles the header-portion of source files.
## Testcase
Dependencies on Debian/Ubuntu: clang, gcc-multilib
```c
// test.h
#ifndef TEST_H_
#define TEST_H_
#include <riscv_vector.h>
#endif
```
```c
// test.c
#include "test.h"
vuint64m4_t v_add(vuint64m4_t a, vuint64m4_t b, size_t vl) {
return __riscv_vadd_vv_u64m4(a, b, vl);
}
```
Compile without PCH:
```shell
$ clang --target=riscv64-linux-gnu -march=rv64gcv -c test.c -o test.o
```
Compile with PCH:
```shell
$ clang --target=riscv64-linux-gnu -march=rv64gcv -x c-header test.h -o test.h.pch
$ clang --target=riscv64-linux-gnu -march=rv64gcv -include-pch test.h.pch -c test.c -o test.o
test.c:4:12: error: call to undeclared function '__riscv_vadd_vv_u64m4'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
4 | return __riscv_vadd_vv_u64m4(a, b, vl);
| ^
test.c:4:12: error: returning 'int' from a function with incompatible result type 'vuint64m4_t' (aka '__rvv_uint64m4_t')
4 | return __riscv_vadd_vv_u64m4(a, b, vl);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk2P2zYT_jX0ZSBDS0qWfdDBa6-RnN4X3W17NChyJLGlKIEfSraH_vaCktarbJNtgCCCYQvD-X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