Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gcc-config:master commit in: /, tests/multi-configs/, tests/multi-configs/etc/env.d/gcc/
Date: Sun, 12 Jan 2020 16:06:02
Message-Id: 1578845139.bc80e12ab133a00ece4059df40d672889fcf6bf0.slyfox@gentoo
1 commit: bc80e12ab133a00ece4059df40d672889fcf6bf0
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 12 15:51:47 2020 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 12 16:05:39 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=bc80e12a
7
8 gcc-config: add basic version sorting support
9
10 Before the change gcc version orderig was relying on bash sorting
11 in flob matches, like:
12 cat /etc/env.d/gcc/${CHOST}-* | fgrep LDPATH | tail -n 1
13
14 This stopped working with gcc-10, which lexicographically goes
15 before gcc-9.
16
17 The workaround for now is to normalizeversions to fixed-width
18 and order them lexicographically:
19 gcc-0009
20 gcc-0010
21
22 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
23
24 gcc-config | 26 +++++++++++++++++++---
25 .../etc/env.d/gcc/x86_64-pc-linux-gnu-10.0.0 | 9 ++++++++
26 .../env.d/gcc/x86_64-pc-linux-gnu-11.0.0-pre9999 | 8 +++++++
27 tests/multi-configs/test.list.exp | 2 ++
28 4 files changed, 42 insertions(+), 3 deletions(-)
29
30 diff --git a/gcc-config b/gcc-config
31 index dd11c71..1ab646b 100755
32 --- a/gcc-config
33 +++ b/gcc-config
34 @@ -68,6 +68,25 @@ usage() {
35 }
36 [[ $# -lt 1 ]] && usage 1
37
38 +# Usage: version_sorted_paths <CHOST>
39 +# Returns paths ordered by version from olders to newest.
40 +# We use the following hack: assume the input containst digits only in places of versions
41 +# Normalizer:
42 +# echo "hello-world-1.2.3.444.56778" | ${SED} -e 's/[0-9]\+/0000&/g' | ${SED} -e 's/0*\([0-9]\{4\}\)/\1/g'
43 +# hello-world-0001.0002.0003.0444.56778
44 +# That way we can have 9.0 < 10.0 roder.
45 +version_sorted_paths() {
46 + local p mangled_v
47 + for p in "$@"; do
48 + # TODO: avoid -r
49 + mangled_v=$(printf "%s" "${p}" |
50 + ${SED} -e 's/[0-9]\+/0000&/g' |
51 + ${SED} -e 's/0*\([0-9]\{4\}\)/\1/g'
52 + )
53 + printf "%s %s\n" "${mangled_v}" "${p}"
54 + done | LANG=C sort | $SED -e 's/^.* //g'
55 +}
56 +
57 # Usage: source_var <var> <file> [default value]
58 source_var() {
59 unset $1
60 @@ -319,7 +338,7 @@ handle_split_usr() {
61 # We use the same ordering logic as mentioned in the MY_LDPATH setup.
62 # We get the libs from the latest version available.
63 local LDPATH
64 - eval $(grep -h '^LDPATH=' "${GCC_ENV_D}"/${CHOST}-* | tail -1)
65 + eval $(grep -h '^LDPATH=' $(version_sorted_paths "${GCC_ENV_D}"/${CHOST}-*) | tail -1)
66 LDPATH=${LDPATH%%:*}
67
68 # If GCC directory is not in separate mountpoint than /lib,
69 @@ -538,6 +557,7 @@ prefix_copy_gcc_libs() {
70 rmdir "${sourcedir}"
71 }
72
73 + # We don't rely on iteration order here.
74 local GCC_PROFILES=$(LC_ALL="C" ls ${GCC_ENV_D}/${CHOST}-*)
75
76 local targetdirs= GCC_PATH= LDPATH=
77 @@ -655,7 +675,7 @@ switch_profile() {
78 local MY_LDPATH
79 MY_LDPATH=$(${SED} -n \
80 -e '/^LDPATH=/{s|LDPATH=||;s|"||g;s|:|\n|g;p}' \
81 - "${GCC_ENV_D}"/${CHOST}-* | tac
82 + $(version_sorted_paths "${GCC_ENV_D}"/${CHOST}-*) | tac
83 )
84
85 # Pass all by default
86 @@ -797,7 +817,7 @@ list_profiles() {
87 source_var CURRENT "${GCC_ENV_D}"/config-${CTARGET}
88 CURRENT_NATIVE=${CURRENT}
89 local target=
90 - for x in "${GCC_ENV_D}"/* ; do
91 + for x in $(version_sorted_paths "${GCC_ENV_D}"/*) ; do
92 [[ -f ${x} ]] || continue
93 [[ ${x} == */config* ]] && continue
94
95
96 diff --git a/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-10.0.0 b/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-10.0.0
97 new file mode 100644
98 index 0000000..c863019
99 --- /dev/null
100 +++ b/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-10.0.0
101 @@ -0,0 +1,9 @@
102 +GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/10.0.0"
103 +LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/10.0.0:/usr/lib/gcc/x86_64-pc-linux-gnu/10.0.0/32"
104 +MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/10.0.0/man"
105 +INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/10.0.0/info"
106 +STDCXX_INCDIR="g++-v10"
107 +CTARGET="x86_64-pc-linux-gnu"
108 +GCC_SPECS=""
109 +MULTIOSDIRS="../lib64:../lib"
110 +
111
112 diff --git a/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-11.0.0-pre9999 b/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-11.0.0-pre9999
113 new file mode 100644
114 index 0000000..1654050
115 --- /dev/null
116 +++ b/tests/multi-configs/etc/env.d/gcc/x86_64-pc-linux-gnu-11.0.0-pre9999
117 @@ -0,0 +1,8 @@
118 +GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/11.0.0-pre9999"
119 +LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0-pre9999:/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0-pre9999/32"
120 +MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/11.0.0-pre9999/man"
121 +INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/11.0.0-pre9999/info"
122 +STDCXX_INCDIR="g++-v10"
123 +CTARGET="x86_64-pc-linux-gnu"
124 +GCC_SPECS=""
125 +MULTIOSDIRS="../lib64:../lib"
126
127 diff --git a/tests/multi-configs/test.list.exp b/tests/multi-configs/test.list.exp
128 index 18640e1..5e8db88 100644
129 --- a/tests/multi-configs/test.list.exp
130 +++ b/tests/multi-configs/test.list.exp
131 @@ -8,3 +8,5 @@ Using gcc-config info in @ROOT@/
132 [4] x86_64-pc-linux-gnu-4.6.0
133 [5] x86_64-pc-linux-gnu-4.6.1
134 [6] x86_64-pc-linux-gnu-4.6.2 *
135 + [7] x86_64-pc-linux-gnu-10.0.0
136 + [8] x86_64-pc-linux-gnu-11.0.0-pre9999