[build2] Trigger compile of sources when their header dependencies change

Moldmann Max (DC-MA/ENG52-NA) Max.Moldmann at boschrexroth-us.com
Thu Apr 13 14:10:40 UTC 2017


Hi Boris,

In this little attached test using the MingW gcc compiler it looks like the compiler option -MMD seems to be the culprit. Unfortunately the way many projects are using the include directive they depend on the -MMD option to compile correctly.
Without -MMD build2 correctly adds the header as dependencies.   
The pathnames in the resulting .o.d file are absolute using Windows style backslashes. By the way can build2 work with relative path names here - this e.g. makes compare jobs easier? 

A modules c file in the test environment is located in a _src folder like here: 
Reverse\_src\reverse.c

Containing an include of its header located in an _inc folder parallel to _src:
#include "../_inc/reverse.h"

When I use the -MMD option then I get a reverse.exe.d file containing:
Reverse\_src\reverse.exe.o: Reverse\_src\reverse.c \
 Reverse\_src\../_inc/reverse.h

Interestingly the MingW compiler also generates a second reverse.d file in the main dir containing absolute path names and all the system headers.

By the way if the include is just an 
#include "reverse.h" 
with an appropriate -I Include folder the .o.d file still doesn't contain the header file as an additional dependency.

Max

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Wednesday, April 12, 2017 10:39 AM
To: Moldmann Max (DC-MA/ENG52-NA) <Max.Moldmann at boschrexroth-us.com>
Cc: users at build2.org
Subject: Re: [build2] Trigger compile of sources when their header dependencies change

Hi Max,

Moldmann Max (DC-MA/ENG52-NA) <Max.Moldmann at boschrexroth-us.com> writes:

> file-a.o.d contains:
> 
> 1
> c.compile 1
> hash1
> hash2
> file-a.c
> 
> but does not contain "file-a.h". 
> But the file-a.d contains the header file:
> 
> module-a\_src\file-a.o: module-a\_src\file-a.c \
>   module-a\_src\/../_inc/file-a.h

Ok, I assume file-a.d is produced by your make-based build system.

Can you create a test project that reproduces this problem and send it to me? I think this has something to do with the way things are included (that 'src\/..' part looks bizarre).

Thanks,
Boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: C-Test.tgz
Type: application/x-compressed
Size: 1518 bytes
Desc: C-Test.tgz
URL: <https://lists.build2.org/archives/users/attachments/20170413/30dd2203/attachment.bin>


More information about the users mailing list