Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7933 Discussions

ICC uses GNU linkonce instead of COMDAT for `__gxx_personality_v0`

ruiu
Beginner
1,098 Views

ICC 19.1.3.20200925 seem to use GNU linkonce section instead of COMMON section for `__gxx_personality_v0` function.

 

GNU linkonce is a old way to do so-called "vague linking", and COMDAT superseded it very long ago.

 

`__gxx_personality_v0` is a function used by the C++ runtime to handle exceptions. That function is provided by libc.

 

If you use a linker that doesn't support GNU linkonce (such as LLVM lld or mold) to statically-link ICC-generated object files with GCC-generated object files, you'll get a duplicate symbol error for `__gxx_personality_v0` because the linker fails to de-duplicate symbols.

 

I believe ICC generate COMDAT sections most of the time. `__gxx_personality_v0` is an exception in which ICC for some reason generate a GNU linkonce section. There might be legacy code in ICC which is used only for `__gxx_personality_v0`.

 

My question is, is there any reason to stick with GNU linkonce? Can ICC always generate COMDAT?

0 Kudos
11 Replies
ShanmukhS_Intel
Moderator
1,075 Views

Hi,

 

Thank you for posting on Intel Communities.

 

You could use "ffunction-sections" optimization option which places each function in its own COMDAT section. By default it's in "OFF" state.

 

Please refer below link for help regarding "ffunction-sections" compiler option.

 

https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/optimization-options/ffunction-sections.html

 

Best Regards,

Shanmukh.SS

 

0 Kudos
ruiu
Beginner
1,065 Views

I think that you misunderstood my point. I'm a compiler toolchain developer (I was working for Google in the LLVM team), and I'm pointing out an ICC's issue. Can you please forward my message to the compiler team?

0 Kudos
ShanmukhS_Intel
Moderator
978 Views

Hi,


Regrets for inconvenience caused regarding the difference in understanding. We are looking into your mentioned issue. We will get back to you soon.


Best regards,

Shanmukh.SS


0 Kudos
Viet_H_Intel
Moderator
967 Views

Can you tell us the OS, gcc version you have?

Does this issue occur with the latest ICC 2021.5 ( in oneAPI2022.1.2 HPC toolkits)?

Would you also provide a reproducer and steps to show a "duplicate symbol error for gxx_personality_v0?


Thanks,

Viet


0 Kudos
Viet_H_Intel
Moderator
923 Views

Hi,


Can you give us a test case and steps to produce a "duplicate symbol error for gxx_personality_v0?


Thanks,


0 Kudos
ruiu
Beginner
907 Views

You can no longer produce the duplicate symbol error because I made a change to the mold linker to ignore ICC-generated .gnu.linkonce.d sections.

 

Here is a bug: https://github.com/rui314/mold/issues/271

 

So, searchbv.cpp.o in libsse_icc.a uses .gnu.linkonce instead of COMDAT. As I wrote in the first post, the use of .gnu.linkonce is effectively deprecated and major tools have migrated to COMDAT more than a decade ago. I want ICC to also stop producing .gnu.linkonce sections and instead use COMDAT.

 

Thanks,

Rui

0 Kudos
Viet_H_Intel
Moderator
902 Views

I followed your github link, but don't see any test case to reproduce it.


Does this issue occur with ICC2021.5?


AFAIK, we don't support other linkers (llvm lld, mold) to link objects built with icc/icpc.


Thanks,

viet


0 Kudos
ruiu
Beginner
889 Views

The user of the linker uses ICC, but I don't have a copy of ICC.

You don't need a tool to see what's in the object file. Just run `readelf -a` on `searchbv.cpp.o` in `libsse_icc.a`. I believe you'll see .gnu.linkonce section in the output.

0 Kudos
Viet_H_Intel
Moderator
886 Views

Yes, I could do that. But I need to have a source code to compile and generate the object to investigate.


Thanks,


0 Kudos
Viet_H_Intel
Moderator
706 Views

Hi,


If this is still an issue, please provide it a reproducer at source code level. If not, we can close this thread.


Thanks,


0 Kudos
Viet_H_Intel
Moderator
682 Views

Let's close this thread for now. If you have a reproducer, please reply to this thread.


Thanks,


0 Kudos
Reply