|
|
Message-ID: <20260928123454.GE23438@brightrain.aerifal.cx> Date: Mon, 28 Sep 2026 08:34:55 -0400 From: Rich Felker <dalias@...c.org> To: Khem Raj <raj.khem@...il.com> Cc: musl@...ts.openwall.com, Khem Raj <khem.raj@....qualcomm.com> Subject: Re: [PATCH] tools/version.sh: fall back to VERSION when git describe finds nothing On Sun, Sep 27, 2026 at 05:25:00PM -0700, Khem Raj wrote: > When building from a git checkout, version.sh uses "git describe" and > only falls back to the VERSION file when git itself is missing. In a > clone that has no tags, such as the one a build system fetches at a > fixed revision, git describe prints nothing and libc is built with an > empty VERSION, so the dynamic linker reports just "Version ". Tools > that identify musl by that string, e.g. Python's packaging (musllinux > platform tags), then no longer recognise the system as musl. > > Use VERSION, suffixed with -git as before, whenever git describe gives > no result. > --- > tools/version.sh | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/tools/version.sh b/tools/version.sh > index f1cc5948..578ff466 100644 > --- a/tools/version.sh > +++ b/tools/version.sh > @@ -2,8 +2,13 @@ > > if test -d .git ; then > if type git >/dev/null 2>&1 ; then > -git describe --tags --match 'v[0-9]*' 2>/dev/null \ > -| sed -e 's/^v//' -e 's/-/-git-/' > +v=$(git describe --tags --match 'v[0-9]*' 2>/dev/null \ > +| sed -e 's/^v//' -e 's/-/-git-/') > +fi > +# git describe finds nothing in a clone without tags (e.g. a build > +# system checkout); fall back to the VERSION file then too. > +if test -n "$v" ; then > +echo "$v" > else > sed 's/$/-git/' < VERSION > fi This loses the knowledge of the specific commit in the absence of tags. It would probably be better to use --always to get a fallback hash, but this omits the version. I think we could do this and if the version is missing prepend the contents of VERSION plus "-git-g" so we'd end up with the same thing as git-describe but without the number of commits since the tag. As an independent change, I might also consider adding --dirty=+ to the git-describe. If nothing else for my own dev purposes since it's useful to know this was built with changes not yet committed. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.