public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: g++ running async???
@ 2014-04-30  8:24 moze
  2014-04-30 13:11 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: moze @ 2014-04-30  8:24 UTC (permalink / raw)
  To: 'moze'; +Cc: gcc-help

Hi,

I tried the suggestion below. And sync() does the trick. So seems not to be
a problem of gcc but rather of the kernel. I consider this only a
workaround, because flushing a system-wide cache in such a standard
situation seems a littel over-kill. But that belongs in a another list. 
Or might it be that g++ takes control of the flushing-behaviour but forgets
in the end that it cannot rely on the standard flush-on-process-end?

Moritz



-----

Hi.

Have you tried to call sync(2)/sync(8) between g++ and ar calls? To make
sure that this is not a file system buffer in kernel.

Marcin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: g++ running async???
  2014-04-30  8:24 g++ running async??? moze
@ 2014-04-30 13:11 ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2014-04-30 13:11 UTC (permalink / raw)
  To: moze; +Cc: gcc-help

On 04/30/2014 10:23 AM, moze wrote:

> I tried the suggestion below. And sync() does the trick. So seems not to be
> a problem of gcc but rather of the kernel. I consider this only a
> workaround, because flushing a system-wide cache in such a standard
> situation seems a littel over-kill. But that belongs in a another list.
> Or might it be that g++ takes control of the flushing-behaviour but forgets
> in the end that it cannot rely on the standard flush-on-process-end?

If calling sync() makes a difference, your system is severely broken. 
sync() should have no observable effect (beyond timing differences) 
while the system is running.

-- 
Florian Weimer / Red Hat Product Security Team

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: g++ running async???
  2014-04-29 17:50 moze
@ 2014-05-11 18:58 ` Ángel González
  0 siblings, 0 replies; 4+ messages in thread
From: Ángel González @ 2014-05-11 18:58 UTC (permalink / raw)
  To: moze; +Cc: gcc-help

moze wrote:
> Hi,
>
> I have a weired phenomena, I want to discuss before filing a bug report.
> Sorry, source+data is too big for posting.
>
> I have a Programm(in C++) that calls "g++" to compile a number of cpp-files
> and afterwards calls "ar" to build a static lib.
> Both "g++" and "ar" are executed using posix_spawnp()+waitpid() (fork() has
> same behaviour)
>
> The Problem is that "ar" somtimes fails because the object-file I compiled
> just before doesn't exist!
>
> It seems like if waitpid() returnns before g++ is actually finished. A
> simple sleep of 0.5sec avoids the problem.
> The waitpid() seems to behave as expected:
> 1. wait longer for bigger cpp-files
> 2. wait-time matches output of -time
> 3. I get correct exit-code
> But the output-file appears later, and output of -time and -v also continue
> after waitpid() and even after my application has terminated...
>
> Am I missing something obvoius???
Maybe your g++ is spawning another process and returning without waiting 
it? Seems
an odd behavior (many makefiles would break, just as your program) but 
that's what the
behavior suggests.
I would strace your g++ looking for file and process creation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* g++ running async???
@ 2014-04-29 17:50 moze
  2014-05-11 18:58 ` Ángel González
  0 siblings, 1 reply; 4+ messages in thread
From: moze @ 2014-04-29 17:50 UTC (permalink / raw)
  To: gcc-help

Hi,

I have a weired phenomena, I want to discuss before filing a bug report.
Sorry, source+data is too big for posting. 

I have a Programm(in C++) that calls "g++" to compile a number of cpp-files
and afterwards calls "ar" to build a static lib. 
Both "g++" and "ar" are executed using posix_spawnp()+waitpid() (fork() has
same behaviour)

The Problem is that "ar" somtimes fails because the object-file I compiled
just before doesn't exist!

It seems like if waitpid() returnns before g++ is actually finished. A
simple sleep of 0.5sec avoids the problem. 
The waitpid() seems to behave as expected:
1. wait longer for bigger cpp-files
2. wait-time matches output of -time
3. I get correct exit-code
But the output-file appears later, and output of -time and -v also continue
after waitpid() and even after my application has terminated...

Am I missing something obvoius??? 

g++ -version: g++ (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3

Output of run:
execute step(build)...
  CC /home/programming/dlibs/DObj/dobj_object.cpp...
  g++ -fPIC -Wno-trigraphs -D_REENTRANT -time -O0 -g -DDEBUG -I . -I
../delivery/include/ -c /home/programming/dlibs/DObj/dobj_object.cpp -o
objects/dobj_object.o
exec..
waited 69ms..
  LNK DObj.a...
  ar rcs DObj.a objects/dobj_object.o
exec..
ar: objects/dobj_object.o: No such file or directory
waited 3ms..
Exception --> link failed in (null)
moze@eddie /home/programming/dlibs $ # cc1plus 0.04 0.00
# as 0.01 0.00

Analysis of run:
exex.. + waited.. mark the time my app waits fort he execution of the line
before. That is always a little more than the sum of -time output of cc1plus
and as
Exception ist he apps reaction to the exit-code of ar
The output fort he -time option comes after the promt after the app has
finished.

Thanks in advance
Moritz


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-11 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30  8:24 g++ running async??? moze
2014-04-30 13:11 ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2014-04-29 17:50 moze
2014-05-11 18:58 ` Ángel González

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).