[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH v2 4/5] build: evaluate XEN_BUILD_* and XEN_DOMAIN on first use


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 27 Jul 2023 11:31:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xLpJFLAgX5XwxIGAjxrlSA+u5Xi6+nr7t2qpdXlKHyA=; b=fRUByzQzOJjXVUhqd/5oAbB9mbVIN+Q7YskiBXYi1dcfkWlvPrbdNiDyIVbkfGGx8od+eOIvbw0Itd1HyxLMT4+3UhSp/0LYuJri6PjTe9wUlfxRr65gMjHy/wLtj7ouEXyg5zRdQwQz9ZBzM3Ua5jyWXRCMthCMhjxTR6xz5iRYBYckmZjlk/mEvFuSJKfwbaq5aoPiPMvaW66TwWWWzxP3kgLKqbVMTe0xmW+J4SQDcvHzWQhXSfqdzLi4K5IK6GVUQj3gkNFK2cUnBx02VjK62RvuDlEXc4+9XdNZtZue+vKA/TfD/tRAf5ln/Z2YL4Er/PZAIeDZFWvCVfLaKw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6TBHZgiXLOvHuKoWpFQnAdBTaoP7F22FT6o83HrA3GgKv/FVNt9SEnJVpNi3CXvgPfXfQTetepJeyMcG51yRYWKzujrPpiQuk4hdghJQF4RQXFRMNq6wprBtNVHmu7ynrB69XagC5QvYymVbqXyBmDS1QkhxI2qhcfjOSE2KLDnKkqtyVkNFesTl50T3YXFSJczbFVnHd30GMLC170nFEjpYGebq7AvAdB3c9tKcm83Z4XfVUn2Gl3TGnhz2WygX/q1xfaGYG5www0jeBwePf8MlOQIlROTv37imvW3QnDwYFW2zuLfL2AKu54e9cYi4m8r2fC47iMvp0rIR4gCqw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Jason Andryuk <jandryuk@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 27 Jul 2023 09:31:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.07.2023 11:15, Anthony PERARD wrote:
> On Fri, Jun 23, 2023 at 10:07:02AM +0200, Jan Beulich wrote:
>> On 22.06.2023 17:30, Anthony PERARD wrote:
>>> --- a/xen/Makefile
>>> +++ b/xen/Makefile
>>> @@ -11,10 +11,10 @@ export XEN_FULLVERSION   = 
>>> $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
>>>  -include xen-version
>>>  
>>>  export XEN_WHOAMI  ?= $(USER)
>>> -export XEN_DOMAIN  ?= $(shell ([ -x /bin/dnsdomainname ] && 
>>> /bin/dnsdomainname) || ([ -x /bin/domainname ] && /bin/domainname || echo 
>>> [unknown]))
>>> -export XEN_BUILD_DATE      ?= $(shell LC_ALL=C date)
>>> -export XEN_BUILD_TIME      ?= $(shell LC_ALL=C date +%T)
>>> -export XEN_BUILD_HOST      ?= $(shell hostname)
>>> +export XEN_DOMAIN  ?= $(eval XEN_DOMAIN := $(shell ([ -x 
>>> /bin/dnsdomainname ] && /bin/dnsdomainname) || ([ -x /bin/domainname ] && 
>>> /bin/domainname || echo [unknown])))$(XEN_DOMAIN)
>>> +export XEN_BUILD_DATE      ?= $(eval XEN_BUILD_DATE := $(shell LC_ALL=C 
>>> date))$(XEN_BUILD_DATE)
>>> +export XEN_BUILD_TIME      ?= $(eval XEN_BUILD_TIME := $(shell LC_ALL=C 
>>> date +%T))$(XEN_BUILD_TIME)
>>> +export XEN_BUILD_HOST      ?= $(eval XEN_BUILD_HOST := $(shell 
>>> hostname))$(XEN_BUILD_HOST)
>>
>> Interesting approach. It looks like it should be independent of make's
>> internal workings, but I still wonder: Is this documented somewhere,
>> so we won't be caught by surprise of it not working anymore because of
>> some change to make's internals?
> 
> So, this is a makefile trick that I've seen on someone's blog post.
> 
> But I tried to find evidence in the GNU make manual if variable expansion is
> expected to work like that, and I can't. So I can imagine one day make
> doing expansion of variable in parallel, or were the result of the eval
> would happen only on the next line. So I don't know if this approach is
> always going to work.
> 
> Maybe we could go for a safer alternative:
> 
> Simply replacing ?= by something actually documented in the manual, and
> then replacing = by := .
> 
>     ifeq ($(origin XEN_BUILD_DATE), undefined)
>     export XEN_BUILD_DATE := $(shell LC_ALL=C date)
>     endif
> 
> An alternative, with a macro could be:
> 
>     set-shell-if-undef = $(if $(filter undefined,$(origin $(1))),$(eval $(1) 
> := $(shell $(2))))
> 
>     $(call set-shell-if-undef,XEN_BUILD_DATE,LC_ALL=C date)
>     export XEN_BUILD_DATE
> 
> But this kind of hide that a shell command is been called. But having
> $(shell) as parameter of call $(call) mean the shell command is always
> called even when unneeded.
> 
> But then, with the macro, I'm not sure where to put it, to be able to
> use it here and in Config.mk for the next patch, another file in
> xen.git/config/*.mk ?
> 
> Should I replace all the eval with "ifeq (); endif" ?

I think that would be best (and I prefer that form anyway for being more
clear as to what it does).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.