Community
cancel
Showing results for 
Search instead for 
Did you mean: 
fatvlad1744
Beginner
109 Views

Undefined symbols when building with debug information and -std=c++20

Hello!

I'm using Intel HPC toolkit installed on my Fedora OS through yum repository and getting unexpected undefined symbol error when compiling

  • against C++20 standard (-std=c++20)
  • with debug information flag (either -g/-g2/-ggdb)

Here's the example program that uses std::allocator<char>:

 

#include <iostream>
#include <memory>

int main() {
    auto buf = std::allocator<char>{}.allocate(10);
}

 

If compiled with icpc -std=c++20 main.cpp no errors are thrown and program starts successfully. However, when compiled with icpc -g2 -std=c++20 main.cpp the following link errors appear:

 

$ icpc -g2 -std=c++20 main.cpp && ./a.out
ld: /tmp/icpcRngryW.o: in function `main':
/home/main.cpp:10: undefined reference to `std::allocator<char>::allocate(unsigned long)'

 

 Versions:

 

$ uname -a
Linux localhost.localdomain 5.8.15-301.fc33.x86_64 #1 SMP Thu Oct 15 16:58:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ icpc --version
icpc (ICC) 2021.2.0 20210228
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.
$ g++ --version
g++ (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ld --version
GNU ld version 2.35-10.fc33
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

 

Worth mentioning that I was compiling a large codebase that potentially uses a huge variety of symbols from standard library and only std::allocator<char> was missing.

Also adding -march=native resolves the issue somehow, so it happens only with generic build.
EDIT: Looks like -march=native is not directly related to the resolution. -march=native enables optimizations and therefore strips unneeded symbols.

Any clues? Thanks.

0 Kudos
2 Replies
NoorjahanSk_Intel
Moderator
69 Views

Hi,

Thanks for reaching out to us.

Could you please try using with icx compiler.

Meanwhile, we will look into the issue internally.


Thanks & Regards

Noorjahan.


fatvlad1744
Beginner
42 Views

Hi Noorjahan,

No such problem with icpx compiler, thanks for workaround!

Reply