Open
Description
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
#include <iostream>
extern void ttt();
int main() {
std::cout << "Hello, World!" << std::endl;
ttt();
return 0;
}
ttt.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:
- use cl compiler to build ttt.obj, hello.obj
- use lib to build ttt.lib
- 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.
I think the implementations in ttt.lib and ttt.obj can both exist in the linker command, because ttt is the same one, so lld-link can choose only one, like what Windows link.exe does, is it right?