Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
7749 Discussions

ICC uses GNU linkonce instead of COMDAT for `__gxx_personality_v0`

ruiu
Beginner
740 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
717 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-refer...

 

Best Regards,

Shanmukh.SS

 

ruiu
Beginner
707 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?

ShanmukhS_Intel
Moderator
620 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


Viet_H_Intel
Moderator
609 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


Viet_H_Intel
Moderator
565 Views

Hi,


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


Thanks,


ruiu
Beginner
549 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

Viet_H_Intel
Moderator
544 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


ruiu
Beginner
531 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.

Viet_H_Intel
Moderator
528 Views

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


Thanks,


Viet_H_Intel
Moderator
348 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,


Viet_H_Intel
Moderator
324 Views

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


Thanks,


Reply