怀疑编译器 - 处理器之间的关系 [英] Doubt on compiler-processor relationship

查看:85
本文介绍了怀疑编译器 - 处理器之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我们正在使用gcc编译器和Pentium 4.还说有另一台机器运行相同的gcc编译器,但是不同的处理器,比如Sunsparc。因此,现在,即使只有处理器不同,但是将为相同的代码生成不同的机器代码。 (我认为是这样的,请小心纠正我错了..)


现在编译器如何知道要生成什么机器代码。 (我认为它必须用编译器调整它的参数做一些事情,在启动时间,但我不确定...... PLZ帮助..)


展望未来回复。


Ajay Garg

Let''s say we are using the gcc compiler, and a Pentium 4. Also say there is another machine running same gcc compiler, but a different processor, say Sunsparc. So, now, even though only the processor differs, yet different machine codes will be generated for the same code. (I assume it to be the case, kindly correct me I am wrong..)

Now how does the compiler know that what machine code to generate. (I presume it has got to do something with compiler "Adjusting" its parameters, during boot up time, BUT I AM NOT SURE... PLZ help..)

Looking forward to a reply.

Ajay Garg

推荐答案


让''我们说我们正在使用gcc编译器和Pentium 4.还说有另一台机器运行相同的gcc编译器,但是不同的处理器,比如Sunsparc。因此,现在,即使只有处理器不同,但是将为相同的代码生成不同的机器代码。 (我认为是这样的,请小心纠正我错了..)


现在编译器如何知道要生成什么机器代码。 (我认为它必须用编译器调整它的参数做一些事情,在启动时间,但我不确定...... PLZ帮助..)


展望未来回复。


Ajay Garg
Let''s say we are using the gcc compiler, and a Pentium 4. Also say there is another machine running same gcc compiler, but a different processor, say Sunsparc. So, now, even though only the processor differs, yet different machine codes will be generated for the same code. (I assume it to be the case, kindly correct me I am wrong..)

Now how does the compiler know that what machine code to generate. (I presume it has got to do something with compiler "Adjusting" its parameters, during boot up time, BUT I AM NOT SURE... PLZ help..)

Looking forward to a reply.

Ajay Garg



Gcc很好地区分编译前端(词法分析,解析,
来自后端的
抽象代码生成。后端''知道'它为生成代码所需的
处理器。 Gcc甚至可以进行交叉编译,

即只需用另一个编译器替换编译器的后端。


亲切的问候,


Jos

Gcc nicely separates the compilation frontend (lexical analysis, parsing,
abstract code generation) from the backend. The backend ''knows'' for what
processor it has to generate its code. Gcc can even do cross compilation,
i.e. simply replace the backend of the compiler by another one.

kind regards,

Jos



Gcc很好地分离了编译前端(词法分析,解析,

抽象代码一代)来自后端。后端''知道'它为生成代码所需的
处理器。 Gcc甚至可以进行交叉编译,

即只需用另一个编译器替换编译器的后端。
Gcc nicely separates the compilation frontend (lexical analysis, parsing,
abstract code generation) from the backend. The backend ''knows'' for what
processor it has to generate its code. Gcc can even do cross compilation,
i.e. simply replace the backend of the compiler by another one.



这意味着,从源代码到目标代码的编译是一个两步过程::一个在前端,另一个在后端,对吗?

That means, that compilation from source code to object code is a two step process :: one at the front end side, other at the back end side, right ?



编译器本身是(已编译的)二进制文件。你不能用奔腾的gcc来运行Sparc,反之亦然。看到你的另一个帖子我也解释了一些东西

多一点。编译器不会知道有关其他处理器的任何信息。它是生成编译器的代码的代码,它知道所有关于单个处理器的信息。
The compiler itself is a (compiled) binary. You can''t run a gcc for a Sparc on
a pentium, nor vice versa. See your other thread where I also explained things
a bit more. The compiler doesn''t ''know'' anything about other processors. It''s
the code generating part of the compiler that knows all about one single processor.



好​​的JosAh,我把它搬到了这里,所以我们可以继续在同一个线程中......


好​​吧..这意味着,在Linux的安装光盘中,我们有不同的gcc二进制文件,每个可能的处理器都有一个吗?

Well JosAh, I moved this here, so we can continue in the same thread ...

Ok.. so that means, that in the installation CDs of Linux, we have different binaries of gcc, one each for all the processors possible?


这篇关于怀疑编译器 - 处理器之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆