Roger.Shimada | 4 Feb 2004 23:58
Favicon

Undesired multi pass build

I thought that I should ask the mailing list about this before getting 
lost in the jam source.  :-)

We generate .h files based on .c files.  For example, we might have 
common.c:

        int     Answer = 42;

from which we generate a common.h in an include directory:

        extern int      Answer;

Note that common.c is used to both compile and to generate the header 
file.

Now let's say there is a source.c that does #include <common.h>.

There is a library that is built from common.c and source.c.

When I update common.c and run jam, common.h gets regenerated and common.c 
is recompiled. But source.c does not get recompiled.  I run jam again, and 
source.c gets recompiled.

Any ideas on how to fix the following Jamfile so an update of common.c 
will rebuild both common.h and compile both .c files?  If not, any hints 
on fixing this in jam?

GENINC = $(GENDIR)/include ;
HDRS += $(GENINC) ;

(Continue reading)

Arnt Gulbrandsen | 5 Feb 2004 00:49
Picon
Favicon
Gravatar

Re: Undesired multi pass build

That can't be done, I'm afraid. But maybe the problem can be restated so 
that the goal is achievable.

Jam's design is (simplifying):

1. Look at the files.
2. Decide what to do.
3. Do it.

Nice and simple. But it prevents you from e.g. first generating common.h 
and then deciding whether to compile source.o.

So, what can you do? One possibility is to tell jam explicitly that 
source.o depends on common.h, so that whenever jam decides to build 
common.h, it will also build source.o.

Arnt

Diane Holt | 5 Feb 2004 05:36
Picon
Favicon

Re: Undesired multi pass build

--- Roger.Shimada <at> lawson.com wrote:
>         LawMkHdr $(GENINC)/$(var:B).h : $(var:B).c : -g ;

I suspect this is your problem. Your header-file target isn't the same as
what source.c #include's -- HdrRule puts an Includes on source.c of
common.h, not $(GENINC)/common.h, so there's no association between
common.h the target and common.h the #include'd header file, so there's
none between common.h the target and source.c, just between source.c and
the common.h it finds in $(GENINC) (via $(HDRSEARCH)) once common.h has
been built. So there's nothing saying to rebuild source.c, until after
common.h has been built (and its timestamp bumped), which is why source.c
recompiles on a second pass but not on one. If you make your target the
same as what's #include'd, you should probably be okay.

Diane

=====
(holtdl <at> yahoo.com)

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

Marco Pappalardo | 7 Feb 2004 05:10
Picon

.obj output dir

Hi everybody,
I'm new to Jam (to make a long story short I'm doing an internship in a company and they've asked me to write jamfiles for their projects) and although I find it quite nice to use the lack of documentation / tutorials / examples is really slowing me down :(
Anyway here's my question :
 
assume I'm writing a jamfile to build an exe which needs to link with several libs. I've got it working so that for example typing jam win32_debug will link to the debug libs, and jam win32_release to the release libs. I am able to build the exe in one version, do a jam clean, and rebuild in another version without any problems. So far so good ... Now the problem is when I build say the debug version, I'm left with all the .obj files, so trying to build the release version right after that (without doing a jam clean) will try to link the current debug .obj files with the release libs (instead of recompiling the sources with the release flags, since the .obj are already there), which of course is no good... Since this is a big project, doing a clean and rebuilding everything every time you switch versions is out of the question.
What I'd like to do is output all .obj files to a different dir for each version. I've tried LOCATE_TARGET and ALL_LOCATE_TARGET, and although ALL_LOCATE_TARGET does relocate the exe, the obj are still generated in the same dir as the sources. My question is what is the standard way to tell Jam to output the .obj to a certain dir ? (if there is any) Or should I just modify the c++ rule so that it /Fo's to a specific dir ? Will that raise any other path problems ? Should I add the .obj output path to SEARCH_SOURCE ? Any other suggestions on how to do this ? Thanks a lot for any help you can provide !
 
Marco Pappalardo
Paul Forgey | 7 Feb 2004 01:34

Re: .obj output dir

On Feb 6, 2004, at 8:10 PM, Marco Pappalardo wrote:

> 've tried LOCATE_TARGET and ALL_LOCATE_TARGET, and although 
> ALL_LOCATE_TARGET does relocate the exe, the obj are still generated 
> in the same dir as the sources. My question is what is the standard 
> way to tell Jam to output the .obj to a certain dir ? (if there is 
> any)

LOCATE_TARGET should do it.  How are you setting it?  For example, 
LOCATE_TARGET on whatever$(SUFEXE) = won't affect the intermediate 
files which built the exe.  If you have multiple subprojects, I posted 
a simple $(SUBDIRRULES) a while ago you can put in your Jamrules which 
gives you msdev-like behavior.  It sort of breaks the spirit of Jam 
(take any Jamfile project and send output anywhere without modifying 
the Jamfile), but it's probably what you want.

> Or should I just modify the c++ rule so that it /Fo's to a specific 
> dir ?

No.  The stock rules already did that for you.

Li Yun | 11 Feb 2004 03:58

How to create a directory

Hi Folks:

 

I want to create a directory when build my project. So I added the following line into the Jamfile.

 

MkDir lib.mpc ;

 

But it does nothing, could you tell me why?

 

Best regards

----------------------------------------------------
Li Yun(
李云)
 
R&D Wireless
UTStarcom CO.LTD
16 floor, TianHuang Building,No.88 Wenhua Road, Hangzhou, China PC 310012
Tel: 86-571-88862342 ext:8364 (Office)
Mobile:13646838061
Email: yunli <at> utstar.com

 

Marco Pappalardo | 12 Feb 2004 04:26
Picon

xxx already defined in lib, ignoring second definition

Hi everybody !
First of all thanks a lot to Paul and Randy :) I managed to fix my LOCATE_TARGET problem ( in case you're curious, the project is way too big to specify every .cpp file by hand, so I was "harvesting" them from predefined dirs, and I was passing them to Library with path attached, which caused LOCATE_TARGET to not be set properly. I fixed it by stripping the paths from the source files passed to Library and using SEARCH_SOURCE instead :p )
 
Now I'm back with another question for you Jam Gurus :) I remember reading something about this in the jamming archive, but google searches didn't turn anything up and I can't find it in the archive by hand anymore, so my apologies for posting this again :
 
If for example I build mylib.lib using mysource.cpp that has a function myfunction(), then re-build mylib.lib without doing a jam clean first, I get the following warnings :
 
(roughly, I'm at home now and forgot to mail myself the exact error messages)
 
warning : myfunction() already defined in mylib.lib, ignoring second definition.
 
Am I right to assume from this message that the old code for myfunction() is not being replaced by the new code for myfunction() ? Any ideas on how to fix this ?
 
As usual any help would be highly appreciated :) Thanks :)
 
Marco Pappalardo
 
 
Paul Forgey | 12 Feb 2004 00:41

Re: xxx already defined in lib, ignoring second definition

If you build from one directory, then update one of the library's 
members and build from another directory, the object file isn't seen as 
the same object file because the paths are different.

So your updated object file is now in the library twice.  cd to where 
the library lives and jam clean.

Unlike ar, lib.exe stores the path specified on the command line of the 
object files in the resulting library.  This is a problem for us too.  
I suppose it could be solved by modifying the Library rule to be in the 
directory of the object files when updating the library, but this 
becomes a hard problem to solve when the object files are all over the 
place.

Add it to the very long list of stupid MS behaviors in their tools.  
(You should see the tricks I had to do just to get parallel builds 
working properly)

On Feb 11, 2004, at 7:26 PM, Marco Pappalardo wrote:

> warning : myfunction() already defined in mylib.lib, ignoring second 
> definition.
>  
> Am I right to assume from this message that the old code for 
> myfunction() is not being replaced by the new code for myfunction() ? 
> Any ideas on how to fix this ?

Alen Ladavac | 13 Feb 2004 09:11

Re: xxx already defined in lib, ignoring second definition

From: "Paul Forgey" <paulf <at> metainfo.com>
> Add it to the very long list of stupid MS behaviors in their tools.
> (You should see the tricks I had to do just to get parallel builds
> working properly)

Do you use the parallel build on an SMP machine, or across different
machines? I'm interested in making this work, on MS as well.

Thanks,
Alen

Paul Forgey | 17 Feb 2004 02:01

Re: xxx already defined in lib, ignoring second definition

SMP.  Currently, there's no good way to distribute builds around an NT 
environment.  Maybe with gcc, and as soon as the x86 optimizations get 
better.  Unfortunately, msvc currently produces faster code.  
Effectively, the same rules apply for either SMP or distributed builds 
since they both involve multiple processes working on the same project.

There are two basic problems with msvc's default behavior that gets in 
the way of SMP builds.  Writing debug info to a common database file, 
and automatic pre-compiled headers.

For debug builds, use -Z7 -Yd to put the debug information into the 
object files (then into the dll or exe).  A separate .pdb file still 
gets generated at link time.  So far, I haven't noticed any difference 
in debugging behavior doing things this way vs. the way dev studio 
projects want do it by default.

As for pre-compiled headers, generate them ahead of time with one 
source file that simply includes what you want in your pch (like 
stdafx.cpp for vc generated mfc projects) with -Yc and use -Yu with the 
rest of your files to use it.  Set up the dependencies properly to 
avoid race conditions between the processes.  You can use -Fp to place 
the precompiled header data in $(LOCATE_TARGET).

On Feb 13, 2004, at 12:11 AM, Alen Ladavac wrote:

> From: "Paul Forgey" <paulf <at> metainfo.com>
>> Add it to the very long list of stupid MS behaviors in their tools.
>> (You should see the tricks I had to do just to get parallel builds
>> working properly)
>
> Do you use the parallel build on an SMP machine, or across different
> machines? I'm interested in making this work, on MS as well.
>
> Thanks,
> Alen
>
> _______________________________________________
> jamming mailing list  -  jamming <at> perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming


Gmane