Is it possible to have a header file passed through VC instead of ICC?

Is it possible to have a header file passed through VC instead of ICC?

Portrait de Alex K.

Since ICC can't correctly process a .h file, is it possible to have said header file passed through VC? Using string manipulation, I can see how to have a single .cpp file compiled by VC (as shown here) but this won't work for the header files associated.

The header file:

http://mxr.mozilla.org/mozilla-release/source/xpcom/base/ErrorList.h

The errors that are produced:

c:\Development\Source\objdir\dist\include\ErrorList.h(10): error: expression must have arithmetic, enum, or pointer type

ERROR(NS_ERROR_NOT_INITIALIZED, NS_ERROR_BASE + 1),

^

c:\Development\Source\objdir\dist\include\ErrorList.h(12): error: expression must have arithmetic, enum, or pointer type

ERROR(NS_ERROR_ALREADY_INITIALIZED, NS_ERROR_BASE + 2),

^

c:\Development\Source\objdir\dist\include\ErrorList.h(42): error: expression must have arithmetic, enum, or pointer type

ERROR(NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT, NS_ERROR_BASE + 0x101),

^

c:\Development\Source\objdir\dist\include\ErrorList.h(44): error: expression must have arithmetic, enum, or pointer type ERROR(NS_ERROR_FACTORY_EXISTS, NS_ERROR_BASE + 0x100),

^

I know I reported this error before, but I didn't report on it very thoroughly, so that's my own fault. The only work around I can see if to have VC compile this file as opposed to ICC or have ICC ignore the error (which I don't think is possible).

Any ideas?

20 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Melanie Blower (Intel)

It would be best if we could get to the bottom of the error diagnostic that you see. Attach a preprocessed filed, and also include the compiler invocation where the error diagnostic is seen.  To generate the preprocessed file, use the -E switch e.g. icl -E > preprocess.txt ...

it would also be helpful to know which version of visual studio you're using, and which version of the Intel compiler. Building for ia32 or intel64?

Portrait de Melanie Blower (Intel)

p.s. i checked the link that you referred to. There's probably a firefox/mozilla configuration problem that's causing the problem that you see, not a compiler bug. For example, if the macro ERROR is not defined for Intel compilations. You could compare the preprocessed output from cl and icl, e.g.: cl -E ... > cl-preprocess and icl -E ... > icl-preprocess

Portrait de Anoop Madhusoodhanan Prabha (Intel)

I think macro ERROR is defined for Intel Compiler considering since I found this block in nsError.h:

 142 #elif defined(__cplusplus) 
 143   /*
 144    * We're C++ in an old compiler lacking enum classes *and* typed enums (likely
 145    * gcc < 4.5.1 as clang/MSVC have long supported one or both), or compiler
 146    * support is unknown.  Yet nsresult must have unsigned 32-bit representation.
 147    * So just make it a typedef, and implement the constants with global consts.
 148    */
 149   typedef uint32_t nsresult;
 150  
 151   const nsresult
 152   #undef ERROR
 153   #define ERROR(key, val) key = val
 154   #include "ErrorList.h"
 155   #undef ERROR
 156     ;  

So macro gets substituted as key = value; expression. The other common macro which I find in all the above error is NS_ERROR_BASE. I wasn't able to spot the location where this macro is defined to see if this is enabled for Intel C++ Compiler.

The value for NS_ERROR_BASE is assigned at ErrorList.h:

8   ERROR(NS_ERROR_BASE,                          0xC1F30000),
and this expression should evaluate to

NS_ERROR_BASE = 0xC1F30000;

But no where I could spot if NS_ERROR_BASE is a data type or a macro. The only occurences of NS_ERROR_BASE are http://mxr.mozilla.org/mozilla-release/ident?i=NS_ERROR_BASE

But like Melanie Blower said this is to do with macros not being enabled with icl. Generating the preprocessed file will surely help in narrowing down the problem.

Thanks and Regards
Anoop

Portrait de Sergey Kostrov

Please use the following two macros to verify if a macro is defined and if it has some value:
...
#define _VALUE2( value ) #value
#define _VALUE( value ) _VALUE2( value )
...

[ Example ]
...
#pragma message ( "# Diagnostics: " _VALUE( NS_ERROR_BASE ) )
...

If the macro is Not defined then an output will be as follows ( or something like that ):

[ Output 1 ]
...
# Diagnostics: NS_ERROR_BASE
...

If the macro is defined then an output will be as follows ( or something like that ):

[ Output 2 - let's assume that it is initialized to 1000 ]
...
# Diagnostics: 1000
...

Portrait de Alex K.

I've attached a file with all the relevant source files and them being preprocessed with CL and ICL.

Sergey, I'll get on that.

Fichiers joints: 

Fichier attachéTaille
Téléchargement preprocessor.zip38.01 Ko
Portrait de Melanie Blower (Intel)

The preprocessed files don't have the expected content. Can you do it again?

Find the compilation command which fails by looking in the build log. It will have many switches. Copy this line exactly, then modify to add "-E > outfile".  You also need to know what directory the compilation is invoked from. cd into that directory, and issue the modified compilation line.

Portrait de Alex K.

Hi Melanie, I've used the complete command line, but the output doesn't seem to be different. I've done the file that accesses all the headers. Would you like the headers preprocessed too?

Fichiers joints: 

Fichier attachéTaille
Téléchargement icl-preprocess.txt1.8 Ko
Portrait de Sergey Kostrov

Let me go back to your original question:

>>...Since ICC can't correctly process a .h file, is it possible to have said header file passed through VC?

Yes, it is possible. However, you have a project configuration issue and this is why Intel C++ compiler can not compile the sources.

What you're trying to achive is a workaround and this is Not going to solve the problem completely. What we're trying to convince you is that you need to find and fix a root cause of the project configuration problem.

I think some #ifdef-#else-#endif statements are missing for some macro declarations and that is why Microsoft C++ compiler can compile and Intel C++ compiler can not.

Portrait de Alex K.

I think I might have found why ICC hasn't been given a definition:

http://dxr.mozilla.org/mozilla-central/source/mfbt/TypedEnum.h

In this file we see this piece of code:

#elif defined(_MSC_VER)

# if _MSC_VER >= 1400

# define MOZ_HAVE_CXX11_ENUM_TYPE

# endif

# if _MSC_VER >= 1700

# define MOZ_HAVE_CXX11_STRONG_ENUMS

# endif

#endif

Which made me remember, the Mozilla source code doesn't support < MSVC 15 SP1 and since Mozilla treats ICC build number as MSVC (the latest version of ICC being 14, therefore an unsupported MSVC build number) that there won't be any definition for it.

So hopefully if I modify all the _MSC_VER definitions to match the ICC build number we won't have any issues! Can anyone tell me if this piece of code will overwrite the ICC build number, or will it still be recognised as 14? I know I'll have to define it in multiple configure files.

set CC=icl
set CXX=icl
set CC_VERSION=17.0.0.000
set CXX_VERSION=17.0.0.000
set LD=xilink
set AR=xilib -NOLOGO -OUT:"$@"

Quote:

Sergey Kostrov wrote:

Let me go back to your original question:

>>...Since ICC can't correctly process a .h file, is it possible to have said header file passed through VC?

Yes, it is possible. However, you have a project configuration issue and this is why Intel C++ compiler can not compile the sources.

What you're trying to achive is a workaround and this is Not going to solve the problem completely. What we're trying to convince you is that you need to find and fix a root cause of the project configuration problem.

I think some #ifdef-#else-#endif statements are missing for some macro declarations and that is why Microsoft C++ compiler can compile and Intel C++ compiler can not.

Very true, I was just curious if it was possible to at least have something to work on.

Portrait de Casey

Why not just fix the header file you found to explicitly handle the intel compiler and do the right thing?  That way you could also contribute a patch back to mozilla.  The intel compiler defines some macros you could use to build #ifdef statements to define the proper macros for building with intel.

I'm not on windows so I cannot check the exact define flags the compiler emotes, but on linux icpc (13.x update 5) defines

-D__ICC=1310 -D__INTEL_COMPILER=1310

so at least on linux, you could add to that header file 

#if defined( __ICC)
  #if __ICC >= 1310
      # define MOZ_HAVE_CXX11_ENUM_TYPE
      # define MOZ_HAVE_CXX11_STRONG_ENUMS
   #endif
#endif

Note that I don't know what versions of icpc are required for those features and just included the current version as an example.  You would put this in the header file after the checks for _MSC_VER but first verify the name of the macro the intel compiler defines on windows ( __ICC).

Portrait de Alex K.

Thanks, I'll probably end up doing that. But it doesn't seem to have worked so I'll see what else I need to modify and if the version being 14 is even the issue.

Portrait de Sergey Kostrov

>>Which made me remember, the Mozilla source code doesn't support < MSVC 15 SP1 and since Mozilla treats ICC build
>>number as MSVC (the latest version of ICC being 14, therefore an unsupported MSVC build number) that
>>there won't be any definition for it...

I consider that as an internal problem of the Mozilla project and it is not related directly to how Intel C++ compiler compiles sources. There are several Intel C++ compiler macros which need to be used ( __ICC-like ) and you shouldn't mix MSC and ICC together. It means, there are have to be different definitions for both compilers. Here is a fragment of codes how I do it ( demonstrates support for 14 different versions if C++ compilers ):

...
#if _COMPILER_ID < 1200
#define _IDE_ID "5.0"
#define _IDE_CODE "VC50"
#pragma message ( "*** Message: Compiling with Visual C++ v5.0 is NOT supported ***" )
#endif

#if _COMPILER_ID == 1200
#define _IDE_ID "6.0"
#define _IDE_CODE "VS98"
#pragma message ( "*** Message: Compiling with Visual Studio 98 ***" )
#endif

#if _COMPILER_ID == 1300
#define _IDE_ID "7.0"
#define _IDE_CODE "VS2002"
#pragma message ( "*** Message: Compiling with Visual Studio 2002 is NOT supported ***" )
#endif

#if _COMPILER_ID == 1310
#define _IDE_ID "7.1"
#define _IDE_CODE "VS2003"
#pragma message ( "*** Message: Compiling with Visual Studio 2003 is NOT supported ***" )
#endif

#if _COMPILER_ID == 1400
#define _IDE_ID "8.0"
#define _IDE_CODE "VS2005"
#pragma message ( "*** Message: Compiling with Visual Studio 2005 ***" )
#endif

#if _COMPILER_ID == 1500
#define _IDE_ID "9.0"
#define _IDE_CODE "VS2008"
#pragma message ( "*** Message: Compiling with Visual Studio 2008 ***" )
#endif

#if _COMPILER_ID == 1600
#define _IDE_ID "10.0"
#define _IDE_CODE "VS2010"
#pragma message ( "*** Message: Compiling with Visual Studio 2010 ***" )
#endif

#if _COMPILER_ID == 1700
#define _IDE_ID "11.0"
#define _IDE_CODE "VS2012"
#pragma message ( "*** Message: Compiling with Visual Studio 2012 ***" )
#endif

#if _COMPILER_ID == ( 0342 + _COMPILER_ID_BASE )
#define _IDE_ID "3.4.2"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with MinGW v3.4.2 ***" )
#endif

#if _COMPILER_ID == ( 0551 + _COMPILER_ID_BASE )
#define _IDE_ID "5.5.1"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Borland C++ v5.5.1 ***" )
#endif

#if _COMPILER_ID == ( 0300 + _COMPILER_ID_BASE )
#define _IDE_ID "3.0.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Turbo C++ v3.0.0 ***" )
#endif

#if _COMPILER_ID == ( 10000 + _COMPILER_ID_BASE )

#if __INTEL_COMPILER == 710
#define __INTEL_COMPILER_BUILD_DATE 20040309
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20040309
#define _IDE_ID "6.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v7.1.029 ***" )
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20060606
#define _IDE_ID "6.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v8.1.038 ***" )
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20120130
#define _IDE_ID "8.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v12.1.3 ***" )
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20120928
#define _IDE_ID "8.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v12.1.7 ***" )
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20120731
#define _IDE_ID "9.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v13.1.0 ***" )
#endif

#if __INTEL_COMPILER_BUILD_DATE == 20130118
#define _IDE_ID "9.0"
#define _IDE_CODE "Default"
#pragma message ( "*** Message: Compiling with Intel C++ v13.1.2 ***" )
#endif

#endif
...

Portrait de Sergey Kostrov

Take into account that in source codes I do not use any Intel or Microsoft specific version-like macros and project specific _IDE-like macros used instead. It provides a complete isolation of source codes and portability is around 99.99% ( there are always some small problems and portability can not be 100% ).

Portrait de Alex K.

Yeah I would submit a patch, but even when having the source code recognize the version of ICC the error still occurs. I thought that would solve it but it hasn't, looks like I've hit a wall again.

Portrait de Sergey Kostrov

I will try to reproduce that error in a standalone test-case and let you know as soon as it is completed. Could you verify why the web-page
http://mxr.mozilla.org/mozilla-release/source/xpcom/base/ErrorList.h

is Not available any longer?

Portrait de Casey

That website loads for me, but does take 30 seconds to return content.

Portrait de Sergey Kostrov

I reviewed sources and I see that there are three different declarations of ERROR enumeration. In a very small test case I did not see any problems and what I'd like to see is a complete set of command line options for Intel C++ compiler.

Portrait de Alex K.

Quote:

Sergey Kostrov wrote:

I reviewed sources and I see that there are three different declarations of ERROR enumeration. In a very small test case I did not see any problems and what I'd like to see is a complete set of command line options for Intel C++ compiler.

What do you mean by a list of command line options? And I've tried declaring the ERROR type directly in the file and the error still occurs.

Portrait de Sergey Kostrov

>>... I've tried declaring the ERROR type directly in the file and the error still occurs...

1. How did you declare it? Please post codes.

2. For command line options of Intel C++ compiler take a look at a makefile.

Connectez-vous pour laisser un commentaire.