[Question] How can i stop build immediately in build fail?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Question] How can i stop build immediately in build fail?

jungsoo.son

Hello,

I always run ‘make’ with –j8. In this case, when there are a fail it is too hard to check the fail.

I want to kill the all sub-make process immediately when the error occurred.

How can i stop build immediately in build fail?

 

Best regards

Jungsoo Son


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

Oleksandr Gavenko (aka gavenkoa)
On 2013-01-10, jungsoo.son wrote:

> I always run 'make' with -j8. In this case, when there are a fail it is too
> hard to check the fail.
>
> I want to kill the all sub-make process immediately when the error occurred.
>
> How can i stop build immediately in build fail?
>

I make such example:

.PHONY: job
job: job1 job2

.PHONY: job1
job1:
        sleep 3
        exit 1

.PHONY: job2
job2:
        while echo ok; do sleep 1; done

Ir you run like:

  $ make -j2

you get:

  sleep 3
  while echo ok; do sleep 1; done
  ok
  ok
  ok
  exit 1
  make: *** [job1] Error 1
  make: *** Waiting for unfinished jobs....
  ok
  ok
  ...

Seems to be reasonable have an option to kill jobs after some timeout if one
job fail (or make receive signal) and enabling .DELETE_ON_ERROR in this
case...

--
Best regards!


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

David Boyce
It may be a reasonable feature request but it also may not be that
hard to implement with existing functionality. Here's one approach:

% cat makefile
SHELL := $(abspath shx)

.PHONY: job
job: job1 job2

.PHONY: job1
job1:
        sleep 3
        exit 1

.PHONY: job2
job2:
        while echo ok; do sleep 1; done

% cat shx
#!/usr/bin/env python

import optparse
import os
import subprocess
import sys

if '__main__' == __name__:
    parser = optparse.OptionParser()
    parser.add_option('-c', '--command', type='string',
                      help='Command to execute')
    (opts, args) = parser.parse_args(sys.argv[1:])

    rc = subprocess.call(opts.command, shell=True)
    if rc != 0:
        print 'stopping make!'
        os.killpg(0, 15)
    sys.exit(rc)

% make -j2
sleep 3
while echo ok; do sleep 1; done
ok
ok
ok
ok
exit 1
stopping make!
make: *** [job2] Terminated
make: *** [job1] Terminated
Terminated

I implemented the replacement shell in Python but it could use any
language. You just need to kill the process group once the first
recipe fails.

-David Boyce

On Fri, Jan 11, 2013 at 9:38 AM, Oleksandr Gavenko <[hidden email]> wrote:

> On 2013-01-10, jungsoo.son wrote:
>
>> I always run 'make' with -j8. In this case, when there are a fail it is too
>> hard to check the fail.
>>
>> I want to kill the all sub-make process immediately when the error occurred.
>>
>> How can i stop build immediately in build fail?
>>
>
> I make such example:
>
> .PHONY: job
> job: job1 job2
>
> .PHONY: job1
> job1:
>         sleep 3
>         exit 1
>
> .PHONY: job2
> job2:
>         while echo ok; do sleep 1; done
>
> Ir you run like:
>
>   $ make -j2
>
> you get:
>
>   sleep 3
>   while echo ok; do sleep 1; done
>   ok
>   ok
>   ok
>   exit 1
>   make: *** [job1] Error 1
>   make: *** Waiting for unfinished jobs....
>   ok
>   ok
>   ...
>
> Seems to be reasonable have an option to kill jobs after some timeout if one
> job fail (or make receive signal) and enabling .DELETE_ON_ERROR in this
> case...
>
> --
> Best regards!
>
>
> _______________________________________________
> Help-make mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-make

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

Martin d'Anjou-5
In reply to this post by Oleksandr Gavenko (aka gavenkoa)
> On 2013-01-10, jungsoo.son wrote:
>
> How can i stop build immediately in build fail?

There is a patch already for this:
http://lists.gnu.org/archive/html/bug-make/2009-01/msg00035.html

And an example of how it works:
http://ninjaverification.wordpress.com/2009/02/03/continous-integration-system-using-parallel-make/

Used it for years, saved us several thousands of hours on the continuous
integration server.

Martin


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

Eli Zaretskii
In reply to this post by David Boyce
> Date: Fri, 11 Jan 2013 17:57:28 -0800
> From: David Boyce <[hidden email]>
> Cc: help-make <[hidden email]>, bug-make <[hidden email]>
>
> % make -j2
> sleep 3
> while echo ok; do sleep 1; done
> ok
> ok
> ok
> ok
> exit 1
> stopping make!
> make: *** [job2] Terminated
> make: *** [job1] Terminated
> Terminated

Which is dangerous, since when Make is terminated, it doesn't do the
cleanup, like deleting incomplete products, which could produce
strange effects the next time you run it.

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

Oleksandr Gavenko (aka gavenkoa)
On 2013-01-12, Eli Zaretskii wrote:

>> Date: Fri, 11 Jan 2013 17:57:28 -0800
>> From: David Boyce <[hidden email]>
>> Cc: help-make <[hidden email]>, bug-make <[hidden email]>
>>
>> % make -j2
>> sleep 3
>> while echo ok; do sleep 1; done
>> ok
>> ok
>> ok
>> ok
>> exit 1
>> stopping make!
>> make: *** [job2] Terminated
>> make: *** [job1] Terminated
>> Terminated
>
> Which is dangerous, since when Make is terminated, it doesn't do the
> cleanup, like deleting incomplete products, which could produce
> strange effects the next time you run it.

I suggest to enable .DELETE_ON_ERROR option in such case...

--
Best regards!

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: [Question] How can i stop build immediately in build fail?

Eli Zaretskii
> From: Oleksandr Gavenko <[hidden email]>
> Date: Sat, 12 Jan 2013 11:17:17 +0200
> Cc: [hidden email], [hidden email]
>
> On 2013-01-12, Eli Zaretskii wrote:
>
> >> Date: Fri, 11 Jan 2013 17:57:28 -0800
> >> From: David Boyce <[hidden email]>
> >> Cc: help-make <[hidden email]>, bug-make <[hidden email]>
> >>
> >> % make -j2
> >> sleep 3
> >> while echo ok; do sleep 1; done
> >> ok
> >> ok
> >> ok
> >> ok
> >> exit 1
> >> stopping make!
> >> make: *** [job2] Terminated
> >> make: *** [job1] Terminated
> >> Terminated
> >
> > Which is dangerous, since when Make is terminated, it doesn't do the
> > cleanup, like deleting incomplete products, which could produce
> > strange effects the next time you run it.
>
> I suggest to enable .DELETE_ON_ERROR option in such case...

How can that help, if Make itself is killed by a signal?

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make