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

Link time optimization issue when using ICX

fatvlad1744
Beginner
448 Views

Hi,

 

My original post was marked as spam, so I'm reposting.

 

I'm trying to have two-stage compilation where I create static library first and link it afterwards.

 

 

// main.cpp
void foo();

int main() {
    foo();
}

// foo.cpp
#include <iostream>

void foo() {
    std::cout << "Hi foo!" << std::endl;
}

 

 

 

I'm following the guide from Intel documentation: https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/optimization-and-programming-guide/interprocedural-optimization-ipo/creating-a-library-from-ipo-objects.html

 

 

$ icpx -fast -c -o foo.o foo.cpp
$ xiar rcs libfoo.a foo.o
xiar: executing 'ar'
$ icpx -fast main.cpp -L. -lfoo
/usr/bin/ld: skipping incompatible ./libfoo.a when searching for -lfoo
/usr/bin/ld: cannot find -lfoo
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

 

 

Seems like it fails to parse static library format when IPO is enabled. When IPO is disabled, everything is fine. Also, classic ICC compiler works fine.

However, when using direct linkage with object file, everything seems to work fine:

 

 

$ icpx -fast main.cpp foo.o
$ ./a.out 
Hi foo!

 

 

Can you please clarify how to fix that? I'm using CentOS 7:

 

 

  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1127.8.2.el7.x86_64
      Architecture: x86-64

 

 

LD output:

 

 

GNU ld version 2.27-44.base.el7
ld: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
ld: supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om

 

 

 

 

P.S. When I try to check libfoo.a symbols with nm, I'm getting "foo.o: File format not recognized" error. NM version output:

 

 

GNU nm version 2.27-44.base.el7
nm: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex

 

 

0 Kudos
0 Replies
Reply