Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lld-link] error : duplicate symbol #133044

Open
co-neco opened this issue Mar 26, 2025 · 0 comments
Open

[lld-link] error : duplicate symbol #133044

co-neco opened this issue Mar 26, 2025 · 0 comments

Comments

@co-neco
Copy link

co-neco commented Mar 26, 2025

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:

  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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants