Unix Shell - need help on make -j option

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2006 > need help on make -j option





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author need help on make -j option
kumar

2006-10-24, 1:17 pm

Hi

I an new to Unix. I ran into a problem while using the -j option with
make command. The code complies fine when I do not use the -j option.
However, when I use -j6 option, the compilation breaks. I surfed the
net but could not find sufficient info on the usage of -j flag.

Any pointers/references to the usage/limitations of -j flag on make
will be highly appreciated.

Regards
Kumar
sunilbadiger@yahoo.com

Bill Marcum

2006-10-24, 1:17 pm

On 24 Oct 2006 06:09:04 -0700, kumar
<sunilbadiger@yahoo.com> wrote:
> Hi
>
> I an new to Unix. I ran into a problem while using the -j option with
> make command. The code complies fine when I do not use the -j option.
> However, when I use -j6 option, the compilation breaks.


Then don't use -j6. Does it work with -j5?


--
Short people get rained on last.
Icarus Sparry

2006-10-24, 1:17 pm

On Tue, 24 Oct 2006 06:09:04 -0700, kumar wrote:

> Hi
>
> I an new to Unix. I ran into a problem while using the -j option with
> make command. The code complies fine when I do not use the -j option.
> However, when I use -j6 option, the compilation breaks. I surfed the
> net but could not find sufficient info on the usage of -j flag.
>
> Any pointers/references to the usage/limitations of -j flag on make
> will be highly appreciated.
>
> Regards
> Kumar
> sunilbadiger@yahoo.com


Usually this reflects poorly written makefiles which do not have enough
dependency information. A typical example is the following

all: library command
library: lib1.o lib2.o
: Some CC stuff to build library
command: cmd1.o cmd2.o
: Some CC stuff to build command, using library.

If it is run without "-j", then Make does "OK, I need to build 'all', in
order to do this I need to build 'library', so I will do that. OK what
else do I need to do to build 'all' - Ah yes I need to build 'command', so
I will do that. OK I am finished".

If you run it with "-j" then Make does "OK, I need to build 'all', in
order to do this I need to build 'library', so let me get that started. Do
I still have spare slots for doing other things - Yes, so what else do I
need to do? Ah yes I need to build 'command', so let me get that started.
OK, nothing else to do, I will just wait for the two things I started to
complete and then I am done".

The problem is in the second case that 'command' could be built before
'library' is built, and this will lead to compilation failures.

The correct way to write this makefile is

all: command
library: lib1.o lib2.o
: Some CC stuff to build library
command: cmd1.o cmd2.o library
: Some CC stuff to build command, using library.

as the 'command' depends on 'library' being there. Make will handle this
fine, with or without "-j".

I don't know how big the system is that you are building, but you may wish
to look at the paper "Recursive Make considered harmful", which is a very
good read. You may also wish to consider looking at "nmake" from AT&T
(nothing to do with the Microsoft product of the same name). This is part
of the "ast" suite of opensource programs from
http://www.research.att.com/sw and in general does a much better job than
"Make", using many fewer lines in the files.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com