xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <George.Dunlap@citrix.com>
To: Ian Jackson <Ian.Jackson@citrix.com>
Cc: Nick Rosbrook <rosbrookn@ainfosec.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Wei Liu <wl@xen.org>
Subject: Re: [PATCH 3/5] libxl: Generate golang bindings in libxl Makefile
Date: Tue, 26 May 2020 14:56:48 +0000	[thread overview]
Message-ID: <B1814837-4E4B-4795-887E-769E3D25608A@citrix.com> (raw)
In-Reply-To: <24269.8019.97048.52370@mariner.uk.xensource.com>



> On May 26, 2020, at 2:53 PM, Ian Jackson <ian.jackson@citrix.com> wrote:
> 
> George Dunlap writes ("[PATCH 3/5] libxl: Generate golang bindings in libxl Makefile"):
>> +.PHONY: idl-external
>> +idl-external:
>> +	$(MAKE) -C $(XEN_ROOT)/tools/golang/xenlight idl-gen
> 
> Unfortunately this kind of thing is forbidden.  At least, without a
> rigorous proof that this isn't a concurrency hazard.
> 
> The problem is that with parallel make, the concurrency correctness
> principles are as follows:
> (1) different targets use nonoverlapping temporary and output files
>    (makefile authors' responsibiliy)
> (2) one invocation of make won't make the same target twice at the
>    same time (fundamental principle of operation for make)
> (3) the same makefile (or different makefiles with overlapping
>    targets) may not be entered multiple times in parallel
>    (build system authors' responsibility; preclucdes most use of
>    make -C to sibling directories rather than to children)
> 
> A correctness proof to make an exception would involve demonstrating
> that the tools/golang directories never touch this file when invoked
> as part of a recursive build.  NB, consider the clean targets too.

tools/golang/xenlight/Makefile:*.gen.go target will be triggered by xenlight/Makefile:idl-gen and xenlight/Makefile:build.

xenlight/Makefile:build is called from tools/golang/Makfile:subdirs-all, which is called from tools/Makefile:subdirs-all.

xenlight/Makefile:idl-gen is called from tools/libxl/Makefile:idl-external, which is called from tools/libxl/Makefile:all, which is called from tools/Makefile:subdirs-all.

tools/Makefile:subdirs-all is implemented as a non-parallel for loop executing over SUBDIRS-y; tools/golang comes after tools/libxl in that list, and so tools/golang:all will never be called until after tools/libxl:all has completed.  This invariant — that tools/golang/Makefile:all must not be called until tools/libxl/Makefile:all has completed must be kept regardless of this patch, since xenlight/Makefile:build depends on other output from tools/libxl/Makefile:all.

So as long as nothing else calls tools/libxl:all or tools/libxl:idl-external, this should be safe.  We could add a comments near xenlight/Makefile:idl-gen saying it must only be called from libxl/Makefile:idl-external; and to libxl/Makefile:idl-external saying it must not be called recursively from another Makefile.

> Alternatively, move the generated golang files to tools/libxl maybe,
> and perhaps leave symlinks behind.

Would that result in the files being accessible to the golang build tools at https://xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight ?  If not, it defeats the purpose of having the files checked into the tree.

> Or convert the whole (of tools/, maybe) to nonrecursive make using eg
> subdirmk :-).  https://diziet.dreamwidth.org/5763.html

This isn’t really a practical suggestion: I don’t have time to refactor the entire libxl Makefile tree, and certainly don’t have time by Friday.

 -George

  reply	other threads:[~2020-05-26 14:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22 16:12 [PATCH 0/5] Golang build fixes George Dunlap
2020-05-22 16:12 ` [PATCH 1/5] golang: Add a minimum go version to go.mod George Dunlap
2020-05-23 16:29   ` Nick Rosbrook
2020-05-22 16:12 ` [PATCH 2/5] golang: Add a variable for the libxl source directory George Dunlap
2020-05-23 16:32   ` Nick Rosbrook
2020-05-26 13:41   ` Ian Jackson
2020-05-22 16:12 ` [PATCH 3/5] libxl: Generate golang bindings in libxl Makefile George Dunlap
2020-05-23 17:00   ` Nick Rosbrook
2020-05-26 13:53   ` Ian Jackson
2020-05-26 14:56     ` George Dunlap [this message]
2020-05-26 16:57       ` Ian Jackson
2020-05-22 16:12 ` [PATCH 4/5] golang/xenlight: Use XEN_PKG_DIR variable rather than open-coding George Dunlap
2020-05-23 16:40   ` Nick Rosbrook
2020-05-23 16:48     ` Nick Rosbrook
2020-05-26  9:31       ` George Dunlap
2020-05-26 15:19         ` Nick Rosbrook
2020-05-26 13:58   ` Ian Jackson
2020-05-22 16:12 ` [PATCH 5/5] gitignore: Ignore golang package directory George Dunlap
2020-05-23 17:03   ` Nick Rosbrook
2020-05-26 13:54   ` Ian Jackson
2020-05-26 15:30     ` George Dunlap
2020-05-26 16:21       ` Nick Rosbrook
2020-05-26 16:33         ` George Dunlap
2020-05-26 16:59       ` Ian Jackson
2020-05-26 17:07         ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B1814837-4E4B-4795-887E-769E3D25608A@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=rosbrookn@ainfosec.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).