English 中文(简体)
海湾合作委员会如何管理其他方案?
原标题:How does GCC run its other programs?
  • 时间:2012-01-12 15:34:10
  •  标签:
  • gcc
  • exec

或许标题没有准确表述问题: 我知道,当我操作gcc foo.c时。 海湾合作委员会呼吁开展所有工作的其他次方案,使主要优惠方案仅成为一个接口。 但是,如何做到这一点?

使用<条码>系统或<条码>。 或者其他一些职能? 我之所以要知道这一点,是因为我希望在类似制度的基础上建立一个网络拖网机,届时将有一个接口方案和若干其他次级项目,如<条码>/条码>和<条码><<>。

如果已经问了这一问题,那么我就没有利用搜查或“有类似头衔的问题”来发现这一问题,我感到担忧。

事先感谢你。

最佳回答

虽然你的问题确实较为笼统(仅以gcc为例),但我的第一个想法是使用<代码>strace<>code>来说明它所做的事情。 关于我的系统(Ubuntu 11.10/x64),我只读了strace,如:

strace -F -o sout gcc -Wall -o test test.c

This shows system calls for the gcc process, while following forks (-F) and sending the output of the trace to sout. Doing this, I can see that gcc here calls vfork(), and then execve() in the child, though the actual program s source might just do a simple fork()/exec().

The relevant output from sout is:

26264 stat("/usr/lib/gcc/x86_64-linux-gnu/4.6.1/cc1", {st_mode=S_IFREG|0755, st_size=11248824, ...}) = 0
26264 access("/usr/lib/gcc/x86_64-linux-gnu/4.6.1/cc1", X_OK) = 0
26264 vfork()                           = 26265
26264 wait4(26265,  <unfinished ...>
26265 execve("/usr/lib/gcc/x86_64-linux-gnu/4.6.1/cc1", ["/usr/lib/gcc/x86_64-linux-gnu/4."..., "-quiet", "-imultilib", ".", "-imultiarch", "x86_64-linux-gnu", "test.c", "-quiet", "-dumpbase", "test.c", "-mtune=generic", "-march=x86-64", "-auxbase", "test", "-Wall", "-fstack-protector", ...], [/* 46 vars */]) = 0

At the begnning of each line is the pid of the process running. So the primary process calls stat() to find cc1, then forks, and the child executes it.

尽管如此,我本可以不引用你的话回答你的问题;因为k/exec是把分处理从你方案中提出去的共同办法。

问题回答

暂无回答




相关问题
gcc -fPIC seems to muck with optimization flags

Following along from this question: how-do-i-check-if-gcc-is-performing-tail-recursion-optimization, I noticed that using gcc with -fPIC seems to destroy this optimization. I am creating a shared ...

Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Getting rid of pre-compiled headers

OK, I have old Metrowerks code for Mac and Windows where the previous developer used pre-compiled headers for every project that this code base builds. How does one get rid of Pre-compiled headers, ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

How to compile for Mac OS X 10.5

I d like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I ve tried -isysroot /Developer/SDKs/...

热门标签