[cfe-dev] Why clang needs to fork into itself?
Benjamin Kramer
benny.kra at gmail.com
Mon Jan 27 14:24:47 PST 2014
On 27.01.2014, at 22:56, Dimitry Andric <dimitry at andric.com> wrote:
> Unfortunately, it is also incredibly wasteful. And lib/Support/Unix/Program.inc does not even use vfork(), which is at least a little lighter on system resources.
It uses posix_spawn if available, that avoids the potential slowdown when
spawning from heavyweight processes. In fact glibc implements posix_spawn by
just calling vfork+exec. The BSDs (including OS X) have a direct implementation
of posix_spawn.
- Ben
>
> If I recall correctly, this point has already come up way in the past, but I cannot find the thread right now. I do recall that some fixes were proposed, but got shot down due to various problems... :-/
>
> -Dimitry
>
> On 27 Jan 2014, at 22:41, Tomasz Mikolajczyk <tmmikolajczyk at gmail.com> wrote:
>
>> I haven't see the code but potentially the purpose of forking is to
>> handle internal compiler errors, especially the case when the child
>> process crashes when processing an input code. That may be easily
>> detected and handled properly by the parent process, by collecting the
>> trace, logs and by encouraging user to fill an issue in the bug DB,
>> etc.
>>
>> On Mon, Jan 27, 2014 at 9:02 PM, Yuri <yuri at rawbw.com> wrote:
>>> I noticed that even the simple command 'clang -c -emit-llvm c.cpp' calls
>>> fork, and forks into itself.
>>> Why does it need to do this? This would potentially complicate profiling,
>>> debugging, etc. All tools should be fork-aware.
>>> Also unnecessary operation must cause some performance hit.
>>>
>>> It is understandable when compiler would, for example, fork into an external
>>> macro preprocessor, or assembler, or linker, but why into itself?
>>>
>>> Yuri
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list