Issue 109634
Summary [clang] Can't compile RISC-V vector intrisics with precompiled headers (PCH)
Labels clang
Assignees
Reporter Ferdi265
    ## 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.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to