-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Closed
Copy link
Labels
clang:PCHPrecompiled headersPrecompiled headers
Description
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 since it precompiles the header-portion of source files.
Testcase
Dependencies on Debian/Ubuntu: clang, gcc-multilib
// test.h
#ifndef TEST_H_
#define TEST_H_
#include <riscv_vector.h>
#endif// 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:
$ clang --target=riscv64-linux-gnu -march=rv64gcv -c test.c -o test.oCompile with PCH:
$ 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.Expected Behaviour
PCH doesn't cause a difference in behaviour.
Actual Behaviour
Functions declared by #pragma clang riscv intrinsic vector (from <riscv_vector.h>) don't exist when using PCH.
Versions
Tested with Clang 18.1.8-2 on Arch Linux, Clang 18.1.8 on Android Termux, and Clang 18.0-59 on Ubuntu 24.04
Metadata
Metadata
Assignees
Labels
clang:PCHPrecompiled headersPrecompiled headers