diff options
author | akrieger <andrewskrieger@gmail.com> | 2025-10-15 22:12:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-16 02:12:46 +0000 |
commit | 705b99607c0c1aadc75fddef8738f22be206da25 (patch) | |
tree | 1326692d5e1e1d06c3704d776334833804680b70 /llvm/unittests/IR/RuntimeLibcallsTest.cpp | |
parent | f98a2567ae1d31da86e95bdfd9766d78a7870c94 (diff) | |
download | llvm-705b99607c0c1aadc75fddef8738f22be206da25.zip llvm-705b99607c0c1aadc75fddef8738f22be206da25.tar.gz llvm-705b99607c0c1aadc75fddef8738f22be206da25.tar.bz2 |
Allow weak/selectany external definitions in header units. (#162713)
weak and selectany are mechanisms for allowing the linker to resolve ODR
violations. [module.import/6] states
> A header unit shall not contain a definition of a non-inline function
or variable whose name has external linkage.
But this prevents compiling any headers with such weak symbols defined.
These occur in eg. some Windows SDK headers like `DirectXMath.h`.
```
#ifndef XMGLOBALCONST
#if defined(__GNUC__) && !defined(__MINGW32__)
#define XMGLOBALCONST extern const __attribute__((weak))
#else
#define XMGLOBALCONST extern const __declspec(selectany)
#endif
#endif
XMGLOBALCONST XMVECTORF32 g_XMSinCoefficients0 = { { { -0.16666667f, +0.0083333310f, -0.00019840874f, +2.7525562e-06f } } };
```
Proposed solution: Do not emit `diag::err_extern_def_in_header_unit` if
the `FD` or `VDecl` have either `SelectAnyAttr` or `WeakAttr`.
Diffstat (limited to 'llvm/unittests/IR/RuntimeLibcallsTest.cpp')
0 files changed, 0 insertions, 0 deletions