| Issue |
61493
|
| Summary |
Error when using Apple's simd.h header with C++ modules
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
rnikander
|
I don't know if this a problem with clang or with Apple's header or what. But I'm not able to include the simd vector types in certain module files. Here is a minimal example. I'm using the latest clang.
`ModuleWithVectors.cc`
```c++
module;
#include <simd/simd.h>
export module ModWithVectors;
export simd::double2 foo() {
// The include simd.h seems to work as expected for this code.
double x = 3.0;
simd::double2 vec = simd_make_double2(x, x);
return vec;
}
```
`ModImpl.cc`
```c++
module;
#include <simd/simd.h>
module ModWithVectors;
// #include <simd/simd.h>
simd::double2 foo_impl() {
double x = 3.0;
simd::double2 vec = simd_make_double2(x, x); // error about 'no matching function call'
return vec;
}
```
```sh
CC="/Users/rob/Dev/llvm-project/build/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -std=c++2b"
$CC -x c++-module ModWithVectors.cc --precompile -o ModWithVectors.pcm
$CC -c -fprebuilt-module-path=. ModImpl.cc -o ModImpl.cc.o
```
Fails with:
```text
ModImpl.cc:11:25: error: no matching function for call to 'simd_make_double2'
simd::double2 vec = simd_make_double2(x, x);
^~~~~~~~~~~~~~~~~
1 error generated.
```
If I try putting the include after the module declaration, I get other errors.
```text
In file included from /Users/rob/Dev/llvm-project/build/lib/clang/17/include/x86gprintrin.h:40:
/Users/rob/Dev/llvm-project/build/lib/clang/17/include/cmpccxaddintrin.h:19:9: error: declaration of '_CMPCCX_ENUM' in module ModWithVectors follows declaration in the global module
typedef enum {
```
The declaration, in `simd/vector_make.h`, looks like this. That should be usable in `ModImpl.cc`, no?
```c++
/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit
* floating-point numbers. */
static inline SIMD_CFUNC simd_double2 simd_make_double2(double x, double y) {
simd_double2 result;
result.x = x;
result.y = y;
return result;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs