michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

duplicate symbol #57

Closed Ekulelu closed 1 year ago

Ekulelu commented 4 years ago

there is "duplicate symbol" error when use zld, these symbols are in different lib. However, there is only warning when use the origin linker.

Ekulelu commented 4 years ago

I found this error is something about "Dead Code Stripping"

Ekulelu commented 4 years ago

I turn on the "Dead Code Stripping", but there is also a error, ld: Linking globals named '_ZTVN4xxx10network_cl9TcpSocketE': symbol multiply defined! for architecture arm64

michaeleisel commented 4 years ago

thanks for the report, do you have a test case i can reproduce? i.e., all the input files such as .o files as well as the invocation

michaeleisel commented 4 years ago

also, where did you see that this error was about dead code stripping?

Ekulelu commented 4 years ago

"ld: Linking globals named '_ZTVN4xxx10network_cl9TcpSocketE': symbol multiply defined! for architecture arm64" this error is nothing about dead code stripping. If turn on dead code stripping, there are more duplicate symbols errors. Sorry, the project occured the error is owned by company, and I can't give it to you. I will try to create a demo project for you when I have time.

michaeleisel commented 4 years ago

sounds good

Ekulelu commented 4 years ago

I have tried to create a demo project to reproduce the case, but failed. The demo project works so well.

michaeleisel commented 4 years ago

if you delete the cache at /tmp/zld-*, and then run zld again, do you still see the same problem?

Ekulelu commented 4 years ago

After I deleted the /tmp/zld-* , the first time build is ok, but the second time will failed

michaeleisel commented 4 years ago

ok, i think i may know the issue. when i get a chance i can dig deeper

michaeleisel commented 4 years ago

Can you try the latest release, 1.2.1?

Ekulelu commented 4 years ago

Thank you, I will try it on Monday.

------------------ 原始邮件 ------------------ 发件人: "notifications"<notifications@github.com>; 发送时间: 2020年10月17日(星期六) 晚上10:41 收件人: "michaeleisel/zld"<zld@noreply.github.com>; 抄送: "政"<709314090@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [michaeleisel/zld] duplicate symbol (#57)

Can you try the latest release, 1.2.1?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Ekulelu commented 4 years ago

I try 1.2.1, but it's still failed. The error is also " Linking globals named '_ZTVN4bigo10network_cl9TcpSocketE': symbol multiply defined! for architecture arm64"

Ekulelu commented 4 years ago

I find there are some 'TcpSocket.o' in different libraries in the /tmp/zld-* file like blow. If I delete all the 'TcpSocket.o', then the link process will report another multiply symbol error. I think the error has something to do with the content of /tmp/zld-*, but I don't know how the file effects the link process.

xxx/Pods/nerv/nerv.framework/nerv
   ....
   TcpSocket.o
   .....

xxx/Pods/chunklink/chunklink.framework/chunklink
     ....
   TcpSocket.o
   .....

There is another thing I confuse. TcpSocket is defined in C++ name space like blow, but the /tmp/zld-* seems to ignore the namespace. Dose this reason cause the link error?

namespace bigo {
    namespace network_cl {
         class TcpSocket {
              ........
         }
    }
}
michaeleisel commented 4 years ago

/tmp/zld-* causes eager loading of all the object files within it. that list consists of all the object files that were loaded for the last linker execution, and it may include object files that would no longer be loaded by stock ld, which in many cases loads lazily

ebdjinming commented 2 years ago

I have same problem, is there any advise to solve this problem?

michaeleisel commented 2 years ago

Can you provide a reproducible example?

ebdjinming commented 2 years ago

Maybe I can have a try.