Issue 133044
Summary [lld-link] error : duplicate symbol
Labels new issue
Assignees
Reporter co-neco
    Hi, I want to build mariadb using CLANGCL toolset on windows.

How to reproduce the issue:
There are two source files as below:
hello.cpp
``` cpp
#include <iostream>

extern void ttt();

int main() {
    std::cout << "Hello, World!" << std::endl;
 ttt();
    return 0;
}
```

ttt.cpp
``` cpp
#include <iostream>

void ttt() {
    std::cout << "hello world\n";
}
```

The main.cpp use an extern function ttt defined in ttt.cpp, I have following build steps:
1. use cl compiler to build ttt.obj, hello.obj
2. use lib to build ttt.lib
3. use link to link ttt.lib and hello.obj to hello.exe:
`link /OUT:"hello.exe" ttt.lib /machine:ARM64 hello.obj ttt.obj`
the above process was successful. 
But if I use lld-link to run the linker command:
`lld-link /OUT:"hello.exe" ttt.lib /machine:ARM64 hello.obj ttt.obj`
It complained that 
```
lld-link: error: duplicate symbol: void __cdecl ttt(void)
>>> defined at ttt.obj
>>> defined at ttt.lib(ttt.obj)
```
And if I run:
``lld-link /OUT:"hello.exe" ttt.lib /machine:ARM64 hello.obj`
It completed without error.

After some examination, I found the output of 'dumpbin /symbols ttt.obj' command showed that ttt function is external, and its' code is in ttt.lib.
I think the implementation in ttt.lib and extern declaration in ttt.obj can both exist in the linker command, like the way Windows link.exe does, is it right?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to