6

Most people use gcc on Linux and MSVC compiler on Windows. I have recently installed Cygwin's GCC compiler on my Windows machine and am using that.

I am just curios if there is any performance difference between them? I mean GCC cannot be directly installed on Windows so the Cygwin package makes some Linux-like environment on Windows and then GCC is going to use that. So is there any draw back of that?

GCC on Linux and GCC with Cygwin on Windows both have any performance difference?

4
  • 3
    GCC doesn't require Cygwin. (Search for mingw.) Performance differences depend a lot on what you are coding, and how your are coding it.
    – Mat
    Nov 19, 2011 at 15:21
  • 1
    There are native versions of GCC on Windows. The most common (perhaps the only one) is mingw. There is probably not much to choose between GCC and MSVC in terms of performance. Of course there are other very good C compilers for Windows, for example the Intel C compiler. Nov 19, 2011 at 15:27
  • mingw is not for posix so no use of them.... Nov 19, 2011 at 15:28
  • Er, MSVC doesn't do POSIX either. Where does POSIX come into the question? Nov 19, 2011 at 15:35

1 Answer 1

4

i am just curios that is there any perfomance difference between them?

Sure, there are points where compilers compete:

  1. Compile speed
  2. Memory usage
  3. Generated code efficiency
  4. etc.

In my experience, the first 3 points go to MSVC. GCC on Windows (especially Cygwin distribution) is damn slow in compile speed, but I guess this is expected. GCC is cross-platform, has about 5 middle phases (transforming from one tree to another), has pluggable architecture, and many other things that could sacrifice compile speed for flexibility. I don't have enough data for MSVC architecture. Memory usage is not very significant but still MSVC does better job, I don't really have arguments why it happens, just looking at task manager values. Generated code efficiency is quite a fight. In many cases MSVC wins, but in some other GCC wins. Both are old compilers and have been improved with a LOT of optimizations. One big thing that GCC loses against MSVC is WPO (Whole Program Optimization). MSVC already has it mature for quite a long time, while AFAIK GCC is still moving toward maturity (4.X series is getting better and better, but is not yet comparable to MSVC one).

... cygwin package makes some linux like environment on windows and then gcc is going to use that so is there any draw back of that?

Actually, not really. You can use GCC without any Unix emulation environment. MinGW distribution can be used standalone without MSYS. It's still required however, if you want to compile programs with GNU style in mind (e.g. "./configure && make && make install" style).

gcc on linux and gcc with cygwin on windows both have any perfomance difference ?

Yes. GCC seems to run a lot faster on Linux than Windows, but it's not always GCC itself to blame. Process creation on Windows is a lot more complicated than on Linux (you can compare CreateProcess from WinAPI and exec from Unix) and in general it causes slower execution on Windows than Linux for ANY programs.

4
  • 1
    GCC 4.6 does have whole program optimization, it is called link time optimization, thru the -flto flag -to pass both when compiling your C or C++ source files and when linking the produced object files. Nov 19, 2011 at 15:59
  • @BasileStarynkevitch yes they have, even before 4.6 (I didn't remember the first version which has it). it's only not as mature as MSVC one.
    – LeleDumbo
    Nov 19, 2011 at 16:04
  • @LeleDumbo the first version is 4.5.0 for platforms that use ELF and 4.5.1 for platforms that use PE/COFF or Mach-O. Besides, you always could make a single big file and compile that (that's probably where #includeing *.c files makes most sense) ;)
    – user784668
    Nov 19, 2011 at 18:28
  • Comparing g++ vs. Msvc ++ execution performance is not trivial. Where restrict is applicable to support g++ autovectorization it nearly always gives best performance . Without
    – tim18
    May 21, 2016 at 23:54

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