All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <amc96@srcf.net>
To: Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Juergen Gross <jgross@suse.com>, Wei Liu <wl@xen.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] tools/libs: Don't recursively expand MAJOR ?= $(shell ...)
Date: Tue, 14 Dec 2021 12:52:03 +0000	[thread overview]
Message-ID: <4210cadd-a717-2a8b-1cba-044f2bede588@srcf.net> (raw)
In-Reply-To: <76367980-c0ff-13c6-4a86-24be90f28f8d@suse.com>

On 14/12/2021 08:17, Jan Beulich wrote:
> On 13.12.2021 20:04, Andrew Cooper wrote:
>> --- a/tools/libs/libs.mk
>> +++ b/tools/libs/libs.mk
>> @@ -6,7 +6,10 @@
>>  #   MINOR:   minor version of lib (0 if empty)
>>  
>>  LIBNAME := $(notdir $(CURDIR))
>> -MAJOR ?= $(shell $(XEN_ROOT)/version.sh $(XEN_ROOT)/xen/Makefile)
>> +
>> +ifeq ($(origin MAJOR), undefined)
>> +MAJOR := $(shell $(XEN_ROOT)/version.sh $(XEN_ROOT)/xen/Makefile)
>> +endif
>>  MINOR ?= 0
>>  
>>  SHLIB_LDFLAGS += -Wl,--version-script=libxen$(LIBNAME).map
> Wouldn't it be better to move the "endif" past the setting of MINOR
> (which then could use := as well)? Libraries with their own versioning
> would imo better specify both rather than relying on getting 0 from
> here (which at present none of them does). Would require an
> adjustment to the comment at the top of libs.mk, though.

I considered that, but decided against it.

Absolutely nothing good can come of having a mix/match of whether MAJOR
and MINOR are set, and the whole point of this logic is to provide a
safe default when things are unspecified.

>
> And further, since you're switching to $(origin ...), wouldn't this
> be an opportunity to avoid stray inheriting of values from the
> environment, by switching to "ifneq ($(origin MAJOR), file)"?

No.  Not because I think setting MAJOR on the command line is sensible,
but because it fails the principle of lease surprise.

Basically all variables are editable on the command line and the
environment.  Prohibiting this one alone is bizarre, unnecessary, and
fragile in the case where if it is encountered, it's probably someone
who knows exactly what they're doing, trying to debug the build system.

~Andrew


  reply	other threads:[~2021-12-14 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 19:04 [PATCH] tools/libs: Don't recursively expand MAJOR ?= $(shell ...) Andrew Cooper
2021-12-14  8:17 ` Jan Beulich
2021-12-14 12:52   ` Andrew Cooper [this message]
2021-12-14 13:57     ` Jan Beulich
2021-12-14 11:28 ` Anthony PERARD
2021-12-14 14:36 ` Anthony PERARD

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=4210cadd-a717-2a8b-1cba-044f2bede588@srcf.net \
    --to=amc96@srcf.net \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.