Hybrid Builds in Xcode* - using both gcc AND icc

Introduction:

Intel® users are accustomed to being able to compile just the performance-critical sources of their application with the Intel C++. The problem is that Xcode* does not have direct support for file level compilation with gcc or icc.  You can use the following methods to direct Xcode to compile key source files in your application with the Intel® C++ Compiler:

 

Method 1:

  • Open the project
  • Control-click (or right click) the .cpp source in the Groups & Files window, select RENAME. Change the file extension to ".icc"
  • "Get Info" on the Target (Control-click the Target and select "Get Info"), and open the "Rules" dialog box.
  • Create a new rule by selecting the "+" button at the bottom left of the dialog box.
  • Change "Choose file type..." to "Source files with names matching:" and specify "*.icc" for the file name.
  • Change "Choose compiler" to "Intel® C++ Compiler XXX" (where XXX is the compiler version)
  • The file will retain its file type of "sourcecode.cpp.cpp" - to verify, Control-click the source file, select "Get Info", and navigate to the File's General dialog.

 

To create a new file with the ".icc" extension, create a new file and set its extension to ".icc".

Override the Xcode project "File Type" for this file:

"Get Info" the source file (control-click the source and select "Get Info")

Navigate to the "General" dialog. Verify that "File Type" is either "sourcecode.c.c" or "sourcecode.cpp.cpp"

sourcecode.c.c -- C source

sourcecode.cpp.cpp -- C++ source

 

The above method is helpful when you have all or most of the project built with gcc but you want to build some of the files with icc. You can use the same method if all or most of the project is built with icc but you want to build some of the files with gcc. For this latter case there is another method; see method 2 below.

 

Method 2:

If all or most of the project files are built with icc but you would like to build some files with gcc:

If the file is a .c file:

 

- Select the file and click "Get Info"

- Change the file type to "sourcecode.c.objc

 

If the file is a .cpp file:

- Select the file and click "Get Info"

- Change the file type to "sourcecode.cpp.objcpp

 

The above change tells Xcode that the above files are ObjectiveC/ObjectiveC++. Since icc does not currently support ObjectiveC/ObjectiveC++, Xcode will use the gcc compiler to build those files.

 

 

Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.