Skip to contentSkip to conversation

ld-version: fix it on Fedora

PATCH In review Michael S. Tsirkin 8 participants 10 messages Jan 7, 2016 – Feb 11, 2016 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ld-version: fix it on Fedora

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)
scripts/ld-version.sh +2 -0
index 198580d..25d23c8 100755
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
 	{
 	gsub(".*)", "");
+	gsub(".*version ", "");
+	gsub("-.*", "");
 	split($1,a, ".");
 	print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
 	exit
Signature · 1 line
MST
#1 lore raw
Quoted 6 lines · Michael S. Tsirkin

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

Quoted 6 lines

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

MIPS is the sole user of ld-ifversion at this time and taking this through the MIPS tree will avoid possible merge conflicts with James Hogan's pending d5ece1cb074b2c7082c9a2948ac598dd0ad40657 fix ("Fix ld-version.sh to handle large 3rd version part"). So I think I should take this through the MIPS tree.

Thanks!

Ralf

#2 lore raw
Quoted 10 lines · Ralf Baechle
Quoted 10 lines

GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Quoted 7 lines
Quoted 1 line

Which tree should this be merged through? Mine? MIPS?

MIPS is the sole user of ld-ifversion at this time and taking this through the MIPS tree will avoid possible merge conflicts with James Hogan's pending d5ece1cb074b2c7082c9a2948ac598dd0ad40657 fix ("Fix ld-version.sh to handle large 3rd version part"). So I think I should take this through the MIPS tree.

FYI, I'm still getting a failure here, with:

$ mips64el-linux-ld --version
GNU ld (GNU Binutils) 2.20.1.20100303
[...]
$

-- so this is a plain upstream development snapshot as these have their date appended. Can we just get rid of the subversion components beyond the third, as I already suggested? I.e. stop on the third point and in any case on a non-point-non-digit.

I'll post a minimal fix shortly, feel free to enhance it if needed.

Maciej

#3 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this

On gnewsense 3, ld --version outputs:

GNU ld (GNU Binutils for Debian) 2.20.1-system.20100303 Copyright [...]

The date at the end severely confuses the version parser.

Furthermore, awk is mawk, whose gsub takes ')' as grouping, so it complains about the missing '('.

Also, once a[1] is multiplied by 1e7, mawk's print spits out the number in exponential notation, which confuses the -lt test. In order to avoid that falling back to floating-point numbers, I've used smaller multipliers and concatenated (truncated) integers. Yuck.

I've modified the script so that it takes the - as a separator too, and so that it works on both gawk and mawk. Here's the ld-version.sh that worked for me. I guess this will have to be combined with your patch somehow.

#!/usr/bin/awk -f

# extract linker version number from stdin and turn into single number
        {
        gsub(".*[)]", "");
        split($1,a, "[-.]");
        printf "%i%04i\n", a[1]*10000 + a[2]*100 + a[3], (a[4]*100 + a[5])%10000;
        exit
        }
Signature · 4 lines
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
#4 lore raw
In reply to Michael S. Tsirkin

Cc'ing Daniel, who has hit further breakage due to unusual version numbers.

Quoted 32 lines · Michael S. Tsirkin

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)
scripts/ld-version.sh +2 -1
index 198580d..25d23c8 100755
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
        {
        gsub(".*)", "");
+       gsub(".*version ", "");
+       gsub("-.*", "");
        split($1,a, ".");
        print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
        exit
--

MST

#5 lore raw

Hi,

The version number that's giving me problems is 2.24.51.20140217 which ld-version.sh converts to 2036931700 (20000000+2400000+510000+2014021700).

At the moment, I'm wondering whether we really need to handle more than three version number components. Another thought is that the comparison could be inside ld-version.sh (or a replacement) so that it can compare the array of version components directly instead of using a constructed integer as a proxy.

Quoted 44 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of James Hogan
Sent: 13 January 2016 17:06
To: Michael S. Tsirkin
Cc: LKML; Michal Marek; [email protected]; Linux MIPS Mailing List; Ralf Baechle; Daniel Sanders
Subject: Re: [PATCH] ld-version: fix it on Fedora

Cc'ing Daniel, who has hit further breakage due to unusual version numbers.

Quoted 32 lines · Michael S. Tsirkin

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)
scripts/ld-version.sh +2 -1
index 198580d..25d23c8 100755
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
        {
        gsub(".*)", "");
+       gsub(".*version ", "");
+       gsub("-.*", "");
        split($1,a, ".");
        print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
        exit
--

MST

A message that is not in the archive (sent off-list or not yet received): CAJ1xhMWth4kNuEkuVEUiUEz=d_9dmKxh0+Z_GrRcKB+F72W91w@mail.gmail.com

#7 lore raw
Quoted 76 lines

From: Alexander Kapshuk [[email protected]]
Sent: 23 January 2016 14:41
To: Daniel Sanders
Cc: James Hogan; Michael S. Tsirkin; LKML; Michal Marek; [email protected]; Linux MIPS Mailing List; Ralf Baechle
Subject: Re: [PATCH] ld-version: fix it on Fedora

On Wed, Jan 13, 2016 at 7:30 PM, Daniel Sanders <[email protected]<mailto:[email protected]>> wrote:
Hi,

The version number that's giving me problems is 2.24.51.20140217 which ld-version.sh converts to 2036931700 (20000000+2400000+510000+2014021700).

At the moment, I'm wondering whether we really need to handle more than three version number components. Another thought is that the comparison could be inside ld-version.sh (or a replacement) so that it can compare the array of version components directly instead of using a constructed integer as a proxy.

Quoted 28 lines

-----Original Message-----
From: [email protected]<mailto:[email protected]> [mailto:[email protected]<mailto:[email protected]>] On Behalf Of James Hogan
Sent: 13 January 2016 17:06
To: Michael S. Tsirkin
Cc: LKML; Michal Marek; [email protected]<mailto:[email protected]>; Linux MIPS Mailing List; Ralf Baechle; Daniel Sanders
Subject: Re: [PATCH] ld-version: fix it on Fedora

Cc'ing Daniel, who has hit further breakage due to unusual version numbers.

Quoted 16 lines · On 7 January 2016 at 17:55, Michael S. Tsirkin…

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 14 lines
scripts/ld-version.sh +2 -1
index 198580d..25d23c8 100755
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
        {
        gsub(".*)", "");
+       gsub(".*version ", "");
+       gsub("-.*", "");
        split($1,a, ".");
        print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
        exit
--
Quoted 2 lines

MST

Is this the output you're looking for?

% echo 'GNU ld version 2.25-15.fc23' |

Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22500000

% echo 2.25.1.20140217 |

Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22510000

Quoted 9 lines

awk parsing code taken from ver_linux:
/usr/src/linux/scripts/ver_linux:28,33
ld -v 2>&1 |

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
    match($0, /[0-9]+([.]?[0-9]+)+/)
    printf("Binutils\t\t%s\n",
    substr($0,RSTART,RLENGTH))
}'

It's close. That code doesn't quite work for my version number because the third component has two digits and overflows into the second component in the proxy integer:

$ echo 2.24.51.20140217 |
Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22910000

but adding a zero to the first two scale factors, or removing one from the third works for me.

$ echo 2.24.51.20140217 | awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
Quoted 4 lines

match($0, /[0-9]+([.]?[0-9]+)+/) bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*100000000 + a[2]*1000000 + a[3]*10000}'

224510000

$ echo 2.24.51.20140217 | awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
Quoted 4 lines

match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*1000}'

22451000

#8 lore raw
Quoted 103 lines · Daniel Sanders
Quoted 77 lines

From: Alexander Kapshuk [[email protected]]
Sent: 23 January 2016 14:41
To: Daniel Sanders
Cc: James Hogan; Michael S. Tsirkin; LKML; Michal Marek; [email protected]; Linux MIPS Mailing List; Ralf Baechle
Subject: Re: [PATCH] ld-version: fix it on Fedora

On Wed, Jan 13, 2016 at 7:30 PM, Daniel Sanders <[email protected]<mailto:[email protected]>> wrote:
Hi,

The version number that's giving me problems is 2.24.51.20140217 which ld-version.sh converts to 2036931700 (20000000+2400000+510000+2014021700).

At the moment, I'm wondering whether we really need to handle more than three version number components. Another thought is that the comparison could be inside ld-version.sh (or a replacement) so that it can compare the array of version components directly instead of using a constructed integer as a proxy.

Quoted 28 lines

-----Original Message-----
From: [email protected]<mailto:[email protected]> [mailto:[email protected]<mailto:[email protected]>] On Behalf Of James Hogan
Sent: 13 January 2016 17:06
To: Michael S. Tsirkin
Cc: LKML; Michal Marek; [email protected]<mailto:[email protected]>; Linux MIPS Mailing List; Ralf Baechle; Daniel Sanders
Subject: Re: [PATCH] ld-version: fix it on Fedora

Cc'ing Daniel, who has hit further breakage due to unusual version numbers.

Quoted 16 lines · On 7 January 2016 at 17:55, Michael S. Tsirkin…

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g. mips build fails to enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

---

Which tree should this be merged through? Mine? MIPS?

 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 14 lines
scripts/ld-version.sh +2 -1
index 198580d..25d23c8 100755
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
        {
        gsub(".*)", "");
+       gsub(".*version ", "");
+       gsub("-.*", "");
        split($1,a, ".");
        print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
        exit
--
Quoted 2 lines

MST

Is this the output you're looking for?

% echo 'GNU ld version 2.25-15.fc23' |

Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22500000

% echo 2.25.1.20140217 |

Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22510000

Quoted 9 lines

awk parsing code taken from ver_linux:
/usr/src/linux/scripts/ver_linux:28,33
ld -v 2>&1 |

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
    match($0, /[0-9]+([.]?[0-9]+)+/)
    printf("Binutils\t\t%s\n",
    substr($0,RSTART,RLENGTH))
}'

It's close. That code doesn't quite work for my version number because the third component has two digits and overflows into the second component in the proxy integer:

$ echo 2.24.51.20140217 |
Quoted 5 lines

awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*10000}'

22910000

but adding a zero to the first two scale factors, or removing one from the third works for me.

$ echo 2.24.51.20140217 | awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
Quoted 4 lines

match($0, /[0-9]+([.]?[0-9]+)+/) bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*100000000 + a[2]*1000000 + a[3]*10000}'

Quoted 7 lines

224510000

$ echo 2.24.51.20140217 | awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
Quoted 4 lines

match($0, /[0-9]+([.]?[0-9]+)+/)
bin=substr($0,RSTART,RLENGTH)
split(bin, a, ".")
print a[1]*10000000 + a[2]*100000 + a[3]*1000}'

22451000

I put the latter of the two methods that worked for you it into a script, shown below:

#!/usr/bin/awk -f

# extract linker version number from stdin and turn into single number
/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
    match($0, /[0-9]+([.]?[0-9]+)+/)
    ver=substr($0,RSTART,RLENGTH)
    split(ver, a, ".")
    print a[1]*10000000 + a[2]*100000 + a[3]*1000
    exit
}

And tried it out on the following input:

% echo 2.24.51.20140217 | ld-version.sh 22451000
% echo 'GNU ld version 2.25-15.fc23' | ld-version.sh 22500000

#9 lore raw
Quoted 5 lines · Alexander Kapshuk
Quoted 5 lines
Quoted 5 lines

At the moment, I'm wondering whether we really need to handle more than three version number components. Another thought is that the comparison could be inside ld-version.sh (or a replacement) so that it can compare the array of version components directly instead of using a constructed integer as a proxy.

I don't think going beyond three version number components makes sense,
to be honest. Any such numbers will be non-standard third-party releases. Upstream binutils use a three-component versioning scheme. Even the third component only makes sense because sometime we may actually rely on a bug fix first available with a maintenance release; these reach single-digit numbers only and hardly ever above 1 actually as another base release is usually made quickly enough (the usual schedule was annual, although as from 2.26, out last Monday, it has been switched to a semi-annual cycle).

Quoted 14 lines

I put the latter of the two methods that worked for you it into a script, shown below:

#!/usr/bin/awk -f

# extract linker version number from stdin and turn into single number
/[0-9]+([.]?[0-9]+)+/ && !/not found$/{
    match($0, /[0-9]+([.]?[0-9]+)+/)
    ver=substr($0,RSTART,RLENGTH)
    split(ver, a, ".")
    print a[1]*10000000 + a[2]*100000 + a[3]*1000
    exit
}
Quoted 4 lines

And tried it out on the following input:

% echo 2.24.51.20140217 | ld-version.sh
22451000

So the above version is a non-release snapshot from the development tree
as the repository trunk is switched to x.y+1.51 once a release branch for x.y has been made. Then the release branch is switched to x.y-1.90 for prereleases, before settling on x.y or x.y.0 (this hasn't been consistent) for the actual base release. Any subsequent maintenance releases will then have their version set to x.y.1, x.y.2, and so on. We shouldn't ever rely on versions that are not proper releases.

Quoted 2 lines

% echo 'GNU ld version 2.25-15.fc23' | ld-version.sh 22500000

So this is a base 2.25 release (obviously with vendor patches, hopefully
not breaking what we might rely on).

FWIW,

Maciej

#10 lore raw
Quoted 10 lines · Maciej W. Rozycki
Quoted 2 lines

% echo 2.24.51.20140217 | ld-version.sh
22451000

So the above version is a non-release snapshot from the development tree
as the repository trunk is switched to x.y+1.51 once a release branch for x.y has been made. Then the release branch is switched to x.y-1.90 for prereleases, before settling on x.y or x.y.0 (this hasn't been consistent) for the actual base release. Any subsequent maintenance releases will then have their version set to x.y.1, x.y.2, and so on. We shouldn't ever rely on versions that are not proper releases.

I need to correct myself here for unclear notation or off-by-one errors,
the flow is of course as follows:

trunk
x.y-1.51

      |
      |
      |
release branchpoint
      |      \
    x.y.51 x.y-1.90
      |   prerelease
      |       |
      |       |
      v    x.y-1.91
      .   prerelease
      .       |
      .       |
              |
           x.y-1.92
          prerelease
              .
              .
              .
            x.y.0
         base release
              |
              |
              |
            x.y.1
      maintenance release
              |
              |
              |
            x.y.2
      maintenance release
              |
              v
              .
              .
              .

The revision number is sometimes bumped up on trunk as well, to 52, 53,
etc., though the criteria are not completely clear to me; perhaps to make a trunk snapshot "release".

And last but not least for non-release builds the snapshot date is
automatically appended to the version number reported, as seen above.

Maciej