Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2161 Discussions

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

fatvlad1744
Beginner
2,040 Views

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
1 Solution
Viet_H_Intel
Moderator
1,823 Views

We have released oneAPI 2021.3. Please let us know if your issue still persists.

Thanks,


View solution in original post

0 Kudos
8 Replies
NoorjahanSk_Intel
Moderator
2,000 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.


0 Kudos
fatvlad1744
Beginner
1,973 Views

Hi Noorjahan,

No such problem with icpx compiler, thanks for workaround!

0 Kudos
Viet_H_Intel
Moderator
1,905 Views

I think this issue occurs on a "not yet" supported OS.

I tried the same compiler on Fedora 31 and didn't see an "undefined reference" message.

Please check systems requirements at https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-hpc-toolkit-system-requirements.html

If you have a Fedora 31, can you see if the issue still persists?


$ uname -a

Linux box 5.8.18-100.fc31.x86_64 #1 SMP Mon Nov 2 20:32:55 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) 9.2.1 20190827 (Red Hat 9.2.1-1)

Copyright (C) 2019 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.32-33.fc31

Copyright (C) 2019 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.

$ rm a.out && icpc -std=c++20 test.cpp  && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -g && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -g2 && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -ggdb && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -g2 -O2 && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -g -O2 && ./a.out

$ rm a.out && icpc -std=c++20 test.cpp -ggdb -O2 && ./a.out

$ cat test.cpp

#include <iostream>

#include <memory>


int main() {

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

}


$


0 Kudos
fatvlad1744
Beginner
1,891 Views

I think the reason here is not "unsupported OS" but "unsupported compiler version". You need to install GCC 10.2 in order to reproduce the issue.

0 Kudos
Viet_H_Intel
Moderator
1,862 Views

Let's wait for the next compiler release.

Thanks,


0 Kudos
Viet_H_Intel
Moderator
1,824 Views

We have released oneAPI 2021.3. Please let us know if your issue still persists.

Thanks,


0 Kudos
fatvlad1744
Beginner
1,812 Views
0 Kudos
Viet_H_Intel
Moderator
1,810 Views

Thank for your confirmation. We are going to close this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


0 Kudos
Reply