Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

Compilation failed when using Xcode

Leo_W_
Beginner
755 Views

I tried to compile my existing project with Intel C++ compiler 15 under Xcode 5.1. I installed the Xcode plugin and rebuilt my project, but I got the following error message and the compilation was failed.

In file included from <built-in>:181:
<command line>:1:10: fatal error: '-c' file not found
#include "-c"
         ^
1 error generated.
problem occurred when compiling '/Users/xxx/NSColor+RBLCGColorAdditions.m' with the clang compiler (code 1)

I checked the compilation command line:

CompileICL Build/Intermediates/xxx.build/Release/xxx.build/Objects-normal/x86_64/NSColor+RBLCGColorAdditions.o xxx/NSColor+RBLCGColorAdditions.m
    cd "/Users/xxx"
    /usr/bin/icc-15.0 -x objective-c -arch x86_64 -dev-usr-root=/Applications/Xcode.app/Contents/Developer/usr -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.7 -w1 -fpascal-strings -iquote /Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/xxx-generated-files.hmap -I/Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/xxx-own-target-headers.hmap -I/Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/xxx-all-target-headers.hmap -iquote /Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/xxx-project-headers.hmap -F/Users/xxx/Build/Products/Release -I/Users/xxx/Build/Products/Release/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/xx/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/opt/tbb/include -I/Users/jh/box/folly -I/usr/local/include -include "" -c /Users/xxx/xxx/NSColor+RBLCGColorAdditions.m -o /Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/Objects-normal/x86_64/NSColor+RBLCGColorAdditions.o -MMD -MT dependencies -MF /Users/xxx/Build/Intermediates/xxx.build/Release/xxx.build/Objects-normal/x86_64/NSColor+RBLCGColorAdditions.d

As you could see, the switch `-include ""` was interpreted as `-include` and the next switch `-c` was interpreted as its argument.

I modified the xcspec file inside the plugin, commented out the following scripts:

1055             // Precompiled Headers
1056             //
1057             //  -- location sensitive (argument hashing) --
1058             //
1059             //{   Name = ICL_PREFIX_HEADER;
1060             //    Category = PrecompiledHeaders;
1061             //    Type = path;
1062             //    DefaultValue = "$(GCC_PREFIX_HEADER)";
1063             //    CommandLineArgs = { "" = ();  "<<otherwise>>" = (-include, "$(_icl_prefix_header_$(ICL_PRECOMPILE_PREFIX_HEADER))"); };
1064             //    AdditionalBuildSettings = {
1065             //        _icl_prefix_header_YES = "$(PrecompFilesDir)/$(ICL_PREFIX_HEADER:base)$(ICL_PREFIX_HEADER:suffix)";
1066             //        _icl_prefix_header_NO  = "$(ICL_PREFIX_HEADER)";
1067             //        };
1068             //    },  

Then clang accepted the command line, but the compilation failed again when compiling a .mm file:

clang: warning: argument unused during compilation: '-MMD'
In file included from /Users/xxx/XXDocument.mm:1:
In file included from /Users/xxx/XXDocument.h:2:
/Users/xxx/config.h:33:10: fatal error: 'array' file not found
#include <array>
         ^
1 error generated.
problem occurred when compiling '/Users/xxx/XXDocument.mm' with the clang compiler (code 1)
Command /usr/bin/icc-15.0 failed with exit code 1

I added "-std=gnu++11" in "Intel C++ Compiler 15.0 Command Line" -> "Additional C++ options", but it was not included in the actual command line. I have to replace it with <tr1/array>, but for other .cpp file which required to be C++11 code, this was invalid.

I also encountered thousands of codes complaining ARC:

/Users/xxx/XXDocument.h:50:42: note: property declared here
@property (weak) IBOutlet NSOutlineView *myOutlineView;
                                         ^
/Users/xxx/XXDocument.mm:67:1: error: @synthesize of 'weak' property is only allowed in ARC or GC mode
@implementation XXDocument
^
/Users/xxx/XXDocument.h:51:42: note: property declared here
@property (weak) IBOutlet NSPopUpButton *arcPopUpButton;
                                         ^
/Users/xxx/XXDocument.mm:67:1: error: @synthesize of 'weak' property is only allowed in ARC or GC mode
@implementation XXDocument
^
/Users/xxx/XXDocument.h:53:42: note: property declared here
@property (weak) IBOutlet NSSearchField *findSearchField;

Anyway, this was an unpleasant attempt of Xcode + Intel compiler. Please let me know how to compile a serious project, not a "Hello, world!" one in the labs.

0 Kudos
1 Reply
Denis_B_Intel1
Employee
755 Views

Hello Leo,

Thanks for your report.

I was able to reproduce the issue with -include "". It will be fixed in the upcoming updates of 15.0 compiler. Meanwhile there is an easier workaround for this - explicitly set 'Precompile Prefix Header' build setting to 'No'.

As for the other issues, the Xcode integration does not fully support compilation of Objective-C source files. In Xcode projects we recommend using Intel compiler to compile C/C++ code while letting Clang compiler to process Objective-C (via creating Build Rules for C/C++). Anyways you would not see a benefit from compiling Obj-C with ICC or ICL since they transparently compiled by clang at this moment.

For further improvement of our Xcode integration I would appreciate a reproducer project.

Thanks,
Denis


 

0 Kudos
Reply