Does g++ work without gcc?

大城市里の小女人 提交于 2019-12-20 07:55:14

问题


Does G++ compile without GCC or G++ is just translator // Including old g++ version.

when i was trying to install g++ from source i saw file

gcc.c

/* Default prefixes to attach to command names.  */

#ifndef STANDARD_EXEC_PREFIX
#define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc-"
#endif /* !defined STANDARD_EXEC_PREFIX */

//from g++1.4*

Well i know that c++ is c with classes i just wanted to know if the g++ can compile c++ without gcc .


回答1:


With a recent GCC, gcc (actually cc1 which is run by gcc) and g++ (actually cc1plus) -and so on for other GCC compilers, e.g. gfortran or even gdc ....- share a lot of (source) code together: the middle-end (where most optimizations happen) and the back-end. The difference is only the front-end layer of the compiler (the only layer being source language specific) which is less than 30% of the compiler.

You could customize the GCC compiler with plugins or with MELT. Your extensions would work on GCC internal representations (Gimple-s) and would work when compiling C, C++, Ada, Fortran, etc... Remember that GCC means Gnu Compiler Collection today

Actually the gcc program is able to compile C++ source code (and likewise g++ can compile C or Fortran code). However, they are not linking the same libraries.

Pass the -v flag to the gcc or g++ command to understand what they are running.


Here are two (mine) [CC-BY-SA] pictures -explaing GCC & MELT- illustrating this.

The three layers -front-end, middle-end, back-end- of the compiler:

with your plugin, or the MELT meta-plugin

with a simplification: cc1 or cc1plus are generating assembler files, which is then translated by as started by gcc or g++

and

another view of the internals of cc1 or cc1plus,

which generates some assembler code



来源:https://stackoverflow.com/questions/26167291/does-g-work-without-gcc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!