[jamming] Jam bug regarding cyclic header files

Hubert Mackenberg hubert.mackenberg at sagem-orga.com
Thu Jan 3 00:21:05 PST 2008


Hi,

it seems there is a bug in Jam regarding cyclic header files:
If have have cyclic header files then a .c file depending
on any of these header file is not recompiled under certain
conditions. A simple example is given below.

The problem seems to be present in all Jam versions.
Does anyone have an idea how to fix it?

Thanks a lot,
Hubert

---

Eaxmple:

In this example a.c includes a.h, a.h includes b.h and
b.h includes c.h. But a.c is not recompiled if c.h is updated.

To get the example running you need 5 files a.c, b.c, a.h,
b.h and c.h. You may create them using:

   echo "this is a.c" > a.c
   echo "this is b.c" > b.c
   echo "this is a.h" > a.h
   echo "this is b.h" > b.h
   echo "this is c.h" > c.h

Then use the 'test.jam' file added below and run

   jam -f test.jam

once to create a first version of a.obj and b.obj.

If you now touch c.h then only b.obj is recompiled,
a.obj is missing. You can do this directly

   touch c.h
   jam -f test.jam

or by using Jam's -t option:

   jam -f test.jam -t c.h



test.jam:

#
# Jam has problems with cyclic includes.
# Here is an example.
#
# Both a.c and b.c include c.h either dircetly or indirectly.
# Thus touching c.h should recompile both a.c and b.c.
#
# Now
#
#    jam -f test.jam -t a.h
#
# works fine: both a.obj and b.obj are recompiled.
#
# But
#
#    jam -f test.jam -t c.h
#
# fails: only b.obj is recompiled.
#

#
# We have two .obj files depending on the corresponding .c files
#
NotFile all ;

Depends all : b.obj a.obj ;

Depends a.obj : a.c ;
Depends b.obj : b.c ;

#
# Use a very simple compile rule for bug demonstration
#
actions compile
{
    Echo Hello $(1) > $(1)
}

compile b.obj ;
compile a.obj ;

#
# Use standard include dependencies
#
Includes a.c : a.h ;
Includes b.c : b.h ;

#
# Use cyclic include file dependencies:
#
#    a.h -> b.h -> c.h -> a.h
#
Includes a.h : b.h ;
Includes b.h : c.h ;
Includes c.h : a.h ;





More information about the jamming mailing list