zld icon indicating copy to clipboard operation
zld copied to clipboard

duplicate symbol

Open Ekulelu opened this issue 4 years ago • 18 comments

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 avatar Sep 08 '20 08:09 Ekulelu

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

Ekulelu avatar Sep 08 '20 09:09 Ekulelu

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

Ekulelu avatar Sep 08 '20 09:09 Ekulelu

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 avatar Sep 08 '20 11:09 michaeleisel

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

michaeleisel avatar Sep 08 '20 11:09 michaeleisel

"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.

Ekulelu avatar Sep 09 '20 03:09 Ekulelu

sounds good

michaeleisel avatar Sep 09 '20 12:09 michaeleisel

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

Ekulelu avatar Sep 10 '20 03:09 Ekulelu

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

michaeleisel avatar Sep 10 '20 11:09 michaeleisel

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

Ekulelu avatar Sep 10 '20 11:09 Ekulelu

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

michaeleisel avatar Sep 10 '20 12:09 michaeleisel

Can you try the latest release, 1.2.1?

michaeleisel avatar Oct 17 '20 14:10 michaeleisel

Thank you, I will try it on Monday.

------------------ 原始邮件 ------------------ 发件人: "notifications"<[email protected]>; 发送时间: 2020年10月17日(星期六) 晚上10:41 收件人: "michaeleisel/zld"<[email protected]>; 抄送: "政"<[email protected]>; "Author"<[email protected]>; 主题: 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 avatar Oct 17 '20 14:10 Ekulelu

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 avatar Oct 19 '20 02:10 Ekulelu

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 {
              ........
         }
    }
}

Ekulelu avatar Oct 22 '20 03:10 Ekulelu

/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

michaeleisel avatar Oct 22 '20 11:10 michaeleisel

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

ebdjinming avatar Aug 02 '22 03:08 ebdjinming

Can you provide a reproducible example?

michaeleisel avatar Aug 02 '22 13:08 michaeleisel

Maybe I can have a try.

ebdjinming avatar Aug 04 '22 00:08 ebdjinming