Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking libraries built with ICC with application built with GCC

Tags:

gcc

linker

icc

I have a set of static libraries, say lib1.a, lib2.a and lib3.a which have been compiled using ICC (Intel C/C++ Compiler). I used ICC with -ipo -c for compilation to create .o files and then XIAR (Intel Archiver) for creating .a libraries.

I want to give these three libraries to a client who does not have ICC and hence will be using GCC to compile and link her application with these libraries. Will the speed-gain (expected from cross-file optimizations due to libs built with -ipo option) not be achieved at all if she links these libraries using GCC?

This page from Intel Website on "GCC Compatibility and Interoperability" states:

Link-time optimization using the -ffat-lto-objects compiler option is provided for gcc compatibility. This implies that ld and ar can be used to link and archive object files, but by doing so you will lose cross-file optimizations.

I am using icc version 13.1.0 (gcc version 4.6.0 compatibility) with gcc version 4.6.3 on Ubuntu 12.04.2.

Any help will be appreciated.

like image 515
MediocreMyna Avatar asked Apr 01 '15 05:04

MediocreMyna


People also ask

Does GCC include a linker?

GCC uses a separate linker program (called ld.exe ) to perform the linking.

What is static library GCC?

A static library is basically a set of object files that were copied into a single file. This single file is the static library. The static file is created with the archiver (ar). First, calc_mean.c is turned into an object file: gcc -c calc_mean.c -o calc_mean.o.


1 Answers

If you using -ipo the optimization will actually happen at the link stage.

During compilation (icc -c -ipo) the Intel compiler only stores additional information in the object files. This additional information is used at link stage to do the actual interprocedural optimization (ipo).

So in order to benefit from IPO you need to use the Intel compiler at compile and link stage.

like image 184
Alexander Weggerle Avatar answered Sep 21 '22 12:09

Alexander Weggerle