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

用mold链接brpc报duplicate symbol #1809

Closed
BiteTheDDDDt opened this issue Jun 19, 2022 · 4 comments
Closed

用mold链接brpc报duplicate symbol #1809

BiteTheDDDDt opened this issue Jun 19, 2022 · 4 comments

Comments

@BiteTheDDDDt
Copy link

Describe the bug (描述bug)
用ld/lld/gold链接都是可以的,但是mold链接就会报这个错,不知道是mold的问题还是brpc的问题?

To Reproduce (复现方法)

mold: error: duplicate symbol: /home/bitetheddddt/dbdev/incubator-doris/thirdparty/installed/lib64/libbrpc.a(collector.cpp.o): src/service/CMakeFiles/palo_be.dir/doris_main.cpp.o: guard variable for butil::detail::ClassNameHelper<long>::name[abi:cxx11]
mold: error: duplicate symbol: /home/bitetheddddt/dbdev/incubator-doris/thirdparty/installed/lib64/libbrpc.a(acceptor.cpp.o): src/exec/libExec.a(data_sink.cpp.o): guard variable for butil::detail::ClassNameHelper<int>::name[abi:cxx11]
mold: error: duplicate symbol: /home/bitetheddddt/dbdev/incubator-doris/thirdparty/installed/lib64/libbrpc.a(execution_queue.cpp.o): src/exec/libExec.a(data_sink.cpp.o): guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<long> >::name[abi:cxx11]
mold: error: duplicate symbol: /home/bitetheddddt/dbdev/incubator-doris/thirdparty/installed/lib64/libbrpc.a(collector.cpp.o): src/service/CMakeFiles/palo_be.dir/doris_main.cpp.o: guard variable for butil::detail::ClassNameHelper<bvar::detail::MaxTo<long> >::name[abi:cxx11]
mold: error: duplicate symbol: /home/bitetheddddt/dbdev/incubator-doris/thirdparty/installed/lib64/libbrpc.a(acceptor.cpp.o): src/exec/libExec.a(data_sink.cpp.o): guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<int> >::name[abi:cxx11]
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior (期望行为)

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots (更多上下文/截图)

@wwbmmm
Copy link
Contributor

wwbmmm commented Jul 28, 2022

看起来是mold的行为和其它ld不兼容,参考:rui314/mold#524
有一个解决方案是gcc编译源码时加上-fno-gnu-unique选项

@BiteTheDDDDt
Copy link
Author

从clang14升级到clang15,又遇到了类似的问题

ld.lld: error: duplicate symbol: guard variable for butil::detail::ClassNameHelper<long>::name[abi:cxx11]
>>> defined at doris_main.cpp
>>>            src/service/CMakeFiles/doris_be.dir/doris_main.cpp.o:(guard variable for butil::detail::ClassNameHelper<long>::name[abi:cxx11])
>>> defined at key.cpp.o:(.bss._ZGVN5butil6detail15ClassNameHelperIlE4nameB5cxx11E+0x0) in archive /mnt/disk1/pxl/doris/thirdparty/installed//lib64/libbrpc.a

ld.lld: error: duplicate symbol: guard variable for butil::detail::ClassNameHelper<bvar::detail::MaxTo<long>>::name[abi:cxx11]
>>> defined at doris_main.cpp
>>>            src/service/CMakeFiles/doris_be.dir/doris_main.cpp.o:(guard variable for butil::detail::ClassNameHelper<bvar::detail::MaxTo<long>>::name[abi:cxx11])
>>> defined at key.cpp.o:(.bss._ZGVN5butil6detail15ClassNameHelperIN4bvar6detail5MaxToIlEEE4nameB5cxx11E+0x0) in archive /mnt/disk1/pxl/doris/thirdparty/installed//lib64/libbrpc.a

ld.lld: error: duplicate symbol: guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<long>>::name[abi:cxx11]
>>> defined at rpc_fn_call.cpp
>>>            rpc_fn_call.cpp.o:(guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<long>>::name[abi:cxx11]) in archive src/exprs/libExprs.a
>>> defined at task_control.cpp.o:(.bss._ZGVN5butil6detail15ClassNameHelperIN4bvar6detail5AddToIlEEE4nameB5cxx11E+0x0) in archive /mnt/disk1/pxl/doris/thirdparty/installed//lib64/libbrpc.a

ld.lld: error: duplicate symbol: guard variable for butil::detail::ClassNameHelper<int>::name[abi:cxx11]
>>> defined at rpc_fn_call.cpp
>>>            rpc_fn_call.cpp.o:(guard variable for butil::detail::ClassNameHelper<int>::name[abi:cxx11]) in archive src/exprs/libExprs.a
>>> defined at index_service.cpp.o:(.bss._ZGVN5butil6detail15ClassNameHelperIiE4nameB5cxx11E+0x0) in archive /mnt/disk1/pxl/doris/thirdparty/installed//lib64/libbrpc.a

ld.lld: error: duplicate symbol: guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<int>>::name[abi:cxx11]
>>> defined at rpc_fn_call.cpp
>>>            rpc_fn_call.cpp.o:(guard variable for butil::detail::ClassNameHelper<bvar::detail::AddTo<int>>::name[abi:cxx11]) in archive src/exprs/libExprs.a
>>> defined at index_service.cpp.o:(.bss._ZGVN5butil6detail15ClassNameHelperIN4bvar6detail5AddToIiEEE4nameB5cxx11E+0x0) in archive /mnt/disk1/pxl/doris/thirdparty/installed//lib64/libbrpc.a
clang-15: error: linker command failed with exit code 1

@BiteTheDDDDt
Copy link
Author

试了一下用ld是可以的,lld不行

@wwbmmm
Copy link
Contributor

wwbmmm commented Oct 14, 2022

Fixed by #1936

@wwbmmm wwbmmm closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants