Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Why?

Depending on your source the Intel compiler is likely or most definitely the compiler generating the fastest executables for the x86 architecture (5 to 100 % execution time improvement).

Intel offers its compilers for Linux under a non-commercial license for free (I think I read it is free somewhere on their page: Intel - Non-Commercial Software Development). There is also a free non-commercial license for students, but this license is not applicable although tools are offered for all three major operating systems (link dropped due to reputation restriction).

Goal

I (as a non-student) would like to be able to use the Intel compilers for possible execution speed improvements under the non-commercial license to compile object files that can be linked to create executables and dynamic link libraries for Windows (and possibly OS X)

More Details:

What I inferred from this document is that the Intel compilers create object files that are compatible to the dominant compilers of the platform.

Sub-questions:

  1. What are the object file formats of gcc, g++, cl, mingw32, icc, icpc, and icl on Windows and Linux (current versions)?
  2. Could parts of the mingw32 cross-compiler toolchain be used to accomplish the goal?
  3. Am I right that the metadata in the generated object files is the main issue?

ad 2:
mingw32-objcopy seems to be able to convert the Intel compiler output on Linux (presumably ELF) to Microsoft-compatible COFF (with the possible exception of relocateable object files). Could someone confirm that this actually works (for non-trivial applications), please?

share|improve this question
1  
+1. Interesting question. –  Neil May 15 '13 at 10:40
    
Have you looked into Wine? AFAIK, Wine provides a toolchain that can build Windows executables on Linux; quite possibly you could hook icc up with that. You might also have some success running a Windows icc inside Wine and hook that up with a ming32 cross-compilation toolchain. I haven't tried it, but with enough fiddling, I think it should be possible. –  tdammers May 15 '13 at 12:06
    
@tdammers According to WineHQ the toolchain to build Windows executables on Linux is mingw32, if I am not mistaken. –  Hugo May 15 '13 at 14:19
    
From the Intel forums the answer appears to be "no": software.intel.com/en-us/forums/topic/282588 –  Vitor May 15 '13 at 14:22
    
@VitorBraga I interpreted the question like this: "Is the Intel Compiler capable to directly cross-compile?" The answer is "No" (it is missing the required options and libraries, as far as I can tell), but ... the computer architecture (IA32, AMD64) would be the same in my case and if I use only Windows libraries to compile the program in Linux I would expect to get executable code that could be executed in Windows -- if linked with the Windows libraries to create a Windows executable. –  Hugo May 15 '13 at 15:13

4 Answers 4

up vote 1 down vote accepted

It is possible to create Windows executables on a Linux build machine by using a cross-compiler. But, Intel does not provide such cross compilers.

To answer the sub-questions:

What are the object file formats of gcc, g++, cl, mingw32, icc, icpc, and icl on Windows and Linux (current versions)?

The format for the object files is effectively determined by the operating system (or rather, the compiler used to build it). For Windows, this is the Portable Executable (PE) format and for Linux the ELF format.

Could parts of the mingw32 cross-compiler toolchain be used to accomplish the goal?

No. The relevant part is the code generator, which is both the part responsible for generating the right object format and the part on the Intel compilers that gives their generated code the speed edge.

Am I right that the metadata in the generated object files is the main issue?

No. It is one issue, but there are more. A more fundamental problem is the potential difference in how parameters are passed to the kernel and/or standard library. IIRC, those conventions are different between Windows and Linux.

share|improve this answer

The answer is almost certainly yes. I know that cross-compiling Windows binaries (via mingw32) on a Linux box is easily possible using gcc - obviously you won't be able to run the program on Linux (unless it works under Wine), but I know several programs that get Windows binaries this way.

However, I don't know if the Intel compiler has the options for this, I should think it does.

The object format for Windows is PE, whereas for Linux its ELF.

share|improve this answer
    
According to msdn: "The compilers produce Common Object File Format (COFF) object (.obj) files."<br/> –  Hugo May 15 '13 at 14:29
    
OK, that did not work. According to Wikipedia PE is derived from COFF and both file formats can be used as object file format and executable file format. –  Hugo May 15 '13 at 14:50

With C code linking to nothing (directly) that uses Microsoft’s custom calling conventions, you might stand a chance using MinGW's objcopy. I have used it to convert an assembled object file, but then I didn't have to worry about calling conventions.

I would just spend the time you would trying to do this instead getting GCC or clang to do exactly what you want. If such a speed up is really that important compile a Linux binary with the Intel compiler and try to see exactly what, if anything at all, it does speeding up your code. You can patch the assembly if all else fails.

share|improve this answer

I propose the following answer:

A definite maybe (leaning towards yes) with a but regarding the context.

Explanation: Regarding the "leaning" part: It seems to not be a total waste of time to try this, but (the "put" part) taking into account this answer you likely won't get the execution time improvements compared to an Intel-only toolchain. The relevant part being linker and runtime feedback to the compiler (whole program optimization, profile-guided optimization, link-time code generation).

Additional detail:
According to the MinGW FAQ there are possible problems with using libraries and DLLs:
"Although dlls are supposed to be fairly portable across different Windows compilers, accessing dlls through a library file (.lib or .a) is not. The library file formats are specific to particular compilers and cannot be used portably with different compilers unless the compiler provides support for it."

To complete the answer:
sub-question 1:

What are the object file formats of gcc, g++, cl, mingw32, icc, icpc, and icl on Windows and Linux (current versions)?

The default object file format for any compiler on Windows is COFF (likely the PE variant). The default object file format for any compiler on Linux is ELF

sub-question 2:

Could parts of the mingw32 cross-compiler toolchain be used to accomplish the goal?

Most likely yes (for the linking part), but most likely you will not get much execution time improvement.

sub-question 3:

Am I right that the metadata in the generated object files is the main issue?

Regarding linking: yes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.