Issue 120234
Summary [clang-cl] Auto link `clang_rt` library when half-precision floating point types are used
Labels new issue
Assignees
Reporter zufuliu
    Tested LLVM 19.1.5, following code with pragma comment out failed to link. it seems frontend doesn't emit link hint for `clang_rt` library.
```c++
//#pragma comment(lib, "clang_rt.builtins-x86_64.lib")
__bf16 add16(__bf16 x, __bf16 y) {
 return x + y;
}
int main(int argc, char *argv[]) {
    int x = argv[0][0] - '0';
    return (int)add16((__bf16)argc, (__bf16)(x));
}
```

```console
D:\notepad4>clang-cl /c test.cpp

D:\notepad4>lld-link test.obj
lld-link: error: undefined symbol: __truncsfbf2
>>> referenced by test.obj:(struct __clang::__bf16 __cdecl add16(struct __clang::__bf16, struct __clang::__bf16))
>>> referenced by test.obj:(struct __clang::__bf16 __cdecl add16(struct __clang::__bf16, struct __clang::__bf16))
>>> referenced by test.obj:(struct __clang::__bf16 __cdecl add16(struct __clang::__bf16, struct __clang::__bf16))
>>> referenced 2 more times

D:\notepad4>link test.obj
Microsoft (R) Incremental Linker Version 14.42.34435.0
Copyright (C) Microsoft Corporation.  All rights reserved.

test.obj : error LNK2019: unresolved external symbol __truncsfbf2 referenced in function "struct __clang::__bf16 __cdecl add16(struct __clang::__bf16,struct __clang::__bf16)" (?add16@@YAU__bf16@__clang@@U12@0@Z)
test.exe : fatal error LNK1120: 1 unresolved externals

D:\notepad4>
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to