[Scons-users] Parallel builds sometimes fails

Matthew Marinets Matthew.Marinets at Kardium.com
Fri May 25 14:42:45 EDT 2018


I’m working on a project with a lot of code generation, and I have run into a simple and unavoidable problem that can only be solved by setting an explicit dependency on a header file.

If a generated header file includes another header file, SCons has no way of knowing. It doesn’t scan built files, because there is no guarantee that the file exists or is up to date at scan-time. Hence, imagine the simple example:

Foo.c:
#include “Foo.h”

Foo.h is generated, and when it is up to date, it includes:
                #include “Bar.h”

SCons has no way of knowing that Foo.c depends on Bar.h. The simplest solution is to set “Bar.h” as an explicit dependency.

-Matthew

From: Scons-users <scons-users-bounces at scons.org> On Behalf Of Bill Deegan
Sent: May 25, 2018 11:30
To: SCons users mailing list <scons-users at scons.org>
Subject: Re: [Scons-users] Parallel builds sometimes fails

You should not have to explicitly tell SCons that a source file depends on a header...

On Fri, May 25, 2018 at 11:47 AM, Hua Yanghao <huayanghao at gmail.com<mailto:huayanghao at gmail.com>> wrote:
I am also using generated header files, which in turn is
unconditionally included by all C files.
The way I use is to first collect the entire C objects and mark an
explicit dependency: env.Depends(obj_list, depend_list).

However you need to make the scons build aware of the generated header
files, which in my case is generated by a customer scons builder.

And my builds worked fine with parallel builds.

On Fri, May 25, 2018 at 4:48 PM, mingqian Han <mq_han at hotmail.com<mailto:mq_han at hotmail.com>> wrote:
> Hi all,
>
>      I am trying to implement a building infrastructure based on Scons.
> Currently it works nicely when doing a non-parallel build (-j1)
>      However when I run a parallel build, sometimes it fails.
>      The build is mostly C source files, and some of them include a specific
> header file, for example, #include "myheader.h"
>       But myheader.h is a generated file from some configuration files. I
> have created a custom SCons builder, put under scons_tools, and it generates
> this file when Scons runs.
>       However in parallel build, sometimes some source files get to compile
> before myheader.h is generated, which results in error: myheader.h not
> found.
>       And sometimes, when my custom SCons builder gets running, it reports
> error, saying that it is unable to access this file because other process is
> using it. In such case, myheader.h is only partially generated.
>       I know SCons reads all the SConscripts first then decides the order of
> building itself. So is there any way to make the parallel build success?
>       Thanks all.
>
> Regards,
>
> Rafael
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org<mailto:Scons-users at scons.org>
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
https://pairlist4.pair.net/mailman/listinfo/scons-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180525/6d400ce2/attachment.html>


More information about the Scons-users mailing list