Why does GCC-Windows depend on cygwin?

后端 未结 11 1682
陌清茗
陌清茗 2020-12-24 11:21

I\'m not a C++ developer, but I\'ve always been interested in compilers, and I\'m interested in tinkering with some of the GCC stuff (particularly LLVM).

On Windows,

相关标签:
11条回答
  • 2020-12-24 11:49

    I try to make my programs under Windows behave like a good Windows citizen, and under Linux like a good Linux citizen.

    0 讨论(0)
  • 2020-12-24 11:51

    I'm not a C++ developer, but I've always been interested in compilers, and I'm interested in tinkering with some of the GCC stuff (particularly LLVM)

    Note that LLVM and GCC are not related. LLVM is largely the result of the research done by Chris Lattner (http://llvm.org/developers.cgi) about modern optimization. His papers are available on http://llvm.org. Nowadays, it is heavily sponsored by Apple. GCC's C/C++/Obj-C frontend is used for llvm-gcc, which emits LLVM machine code (and after a ton of optimizations in llvm, a final executable comes out); llvm-gcc is a kind of hack to couple some ready C/C++/Obj-C-frontend to LLVM.

    Note anyways that the LLVM crew also builds an own, complete C/C++/Obj-C compiler, called clang. It's C implementation is near complete, C++ support is getting better and better, dunno about Obj-C though.

    So, if someone says "compiler llvm", he really either means llvm-gcc, or clang. LLVM itself is just the Low Level Virtual Machine, with only a handful of instructions in Static Single Assignment form (approx. 32 instructions, afair), but a megaton of optimization passes upon thy syntax tree.

    0 讨论(0)
  • 2020-12-24 11:54

    Because the people behing GCC hate Windows with a passion (read Stallman some day). So when porting GCC to Windows, they do their best to pretend it's just another Unix.

    That, and they probably don't want to spend time on removing POSIX dependencies from the code.

    0 讨论(0)
  • 2020-12-24 11:55

    Actually, the question premise is wrong: MinGW GCC does NOT require Cygwin.

    You will see you don't need Cygwin at all. It runs natively on Windows (32-bit, at least). Both the toolchain and the produced binaries are independent of Cygwin.

    The MinGW compilers available in Cygwin are different: they are built on the Cygwin platform, to generate code which does not depend on the Cygwin runtime. The compilers themselves do depend on Cygwin in that case. But that's because you installed them from Cygwin.

    0 讨论(0)
  • 2020-12-24 11:56

    The Cygwin version of GCC requires Cygwin to be installed, for programs it compiles.

    The MinGW version does not require anything after compiling, other than a working copy of Windows.

    You can't really mix the Cygwin environment, and the MinGW compilers together, because Cygwin changes the paths of the precompiled libraries.

    If you need a bash style shell, but don't want to use Cygwin, I would recommend MSYS.

    Cygwin in contrast to MinGW

    copied from MinGW Wiki

    Cygwin applications by principle are not considered a "Native Win32 application" because it relies on the Cygwin® POSIX Emulation DLL or cygwin1.dll for Posix functions and does not use win32 functions directly. MinGW on the other hand, provides functions supplied by the Win32 API. While porting applications under MinGW, functions not native to Win32 such as fork(), mmap() or ioctl() will need to be reimplemented into Win32 equivalents for the application to function properly.

    0 讨论(0)
  • 2020-12-24 12:02

    Windows does not offer a standard POSIX library so cygwin provides one (cygwin1.dll). The gcc packages that comes with cygwin uses it.

    mingw, on the other hand, does not necessarely provide a POSIX layer. The mingw installation that I use, for example, does not even have a pthread library.

    Should I need it I would have to install it. Mingw-gcc produces Win32 native code (and in fact relies on MSVCRT.DLL).

    EDIT: reading your edit I'm no longer sure if you're asking why gcc itself needs mingw/cygwin libraries or if the programs compiled with gcc on Win require those libraries

    0 讨论(0)
提交回复
热议问题