Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: Manoj Gupta <manojgupta@××××××.com>
Cc: gentoo-dev@l.g.o, Mike Frysinger <vapier@g.o>, toolchain@g.o
Subject: [gentoo-dev] Re: [PATCH] gcc-config: Add option to not install cc/f77 wrappers.
Date: Tue, 26 May 2020 22:38:23
Message-Id: 20200526233815.435ea592@sf
In Reply to: [gentoo-dev] Re: [PATCH] gcc-config: Add option to not install cc/f77 wrappers. by Manoj Gupta
1 On Tue, 26 May 2020 15:13:47 -0700
2 Manoj Gupta <manojgupta@××××××.com> wrote:
3
4 > I noticed that gcc-config recently gained --enable-native-links /
5 > --disable-native-links knobs that are . Will this patch with a renamed
6 > option name
7 > e.g. --disable-default-cc-vars and support for a USE flag work?
8
9 That can work. Let's try and see how the end result looks like.
10
11 > Thanks,
12 > Manoj
13 >
14 > On Wed, Mar 11, 2020 at 9:07 AM Manoj Gupta <manojgupta@××××××.com> wrote:
15 >
16 > >
17 > >
18 > > On Wed, Mar 11, 2020 at 12:49 AM Sergei Trofimovich <slyfox@g.o>
19 > > wrote:
20 > >
21 > >> On Tue, 10 Mar 2020 20:54:12 -0700
22 > >> Manoj Gupta <manojgupta@××××××.com> wrote:
23 > >>
24 > >> > On Tue, Mar 3, 2020 at 1:17 AM Sergei Trofimovich <slyfox@g.o>
25 > >> wrote:
26 > >> >
27 > >> > > On Mon, 2 Mar 2020 19:03:48 -0800
28 > >> > > Manoj Gupta <manojgupta@××××××.com> wrote:
29 > >> > >
30 > >> > > > On Thu, Feb 27, 2020 at 11:20 PM Sergei Trofimovich <
31 > >> slyich@×××××.com>
32 > >> > > > wrote:
33 > >> > > >
34 > >> > > > > On Thu, 27 Feb 2020 at 22:41, Manoj Gupta <manojgupta@××××××.com>
35 > >>
36 > >> > > wrote:
37 > >> > > > > >
38 > >> > > > > >
39 > >> > > > > >
40 > >> > > > > > On Thu, Feb 27, 2020 at 11:22 AM Manoj Gupta <
41 > >> manojgupta@××××××.com>
42 > >> > >
43 > >> > > > > wrote:
44 > >> > > > > >>
45 > >> > > > > >> gcc-config installs cc/f77 by default. This may be undesired on
46 > >> > > > > >> systems that want to set their own versions of cc/f77.
47 > >> > > > > >>
48 > >> > > > > >> Add option "-n"/"--no-default-vars" to not install the cc/f77
49 > >> > > > > >> wrappers.
50 > >> > > > > >>
51 > >> > > > > >> Signed-off-by: Manoj Gupta <manojgupta@××××××.com>
52 > >> > > > > >> ---
53 > >> > > > > >> gcc-config | 6 +++++-
54 > >> > > > > >> 1 file changed, 5 insertions(+), 1 deletion(-)
55 > >> > > > > >>
56 > >> > > > > >> diff --git a/gcc-config b/gcc-config
57 > >> > > > > >> index f03a46a..6f306db 100755
58 > >> > > > > >> --- a/gcc-config
59 > >> > > > > >> +++ b/gcc-config
60 > >> > > > > >> @@ -262,7 +262,7 @@ update_wrappers() {
61 > >> > > > > >> # For all toolchains, we want to create the fully
62 > >> qualified
63 > >> > > > > >> # `tuple-foo`. Only native ones do we want the
64 > >> simple
65 > >> > > `foo`.
66 > >> > > > > >> local all_wrappers=( ${new_wrappers[@]/#/${CTARGET}-} )
67 > >> > > > > >> - if ! is_cross_compiler ; then
68 > >> > > > > >> + if ! is_cross_compiler && [[ "${DEFAULT_PROGS}" ==
69 > >> "yes"
70 > >> > > ]];
71 > >> > > > > then
72 > >> > > > > >> all_wrappers+=( "${new_wrappers[@]}" )
73 > >> > > > > >> # There are a few fun extra progs which we
74 > >> have to
75 > >> > > > > handle #412319
76 > >> > > > > >> all_wrappers+=( cc:gcc f77:g77 )
77 > >> > > > > >> @@ -951,6 +951,7 @@ FORCE="no"
78 > >> > > > > >> CC_COMP=
79 > >> > > > > >> ENV_D="${EROOT}etc/env.d"
80 > >> > > > > >> GCC_ENV_D="${ENV_D}/gcc"
81 > >> > > > > >> +DEFAULT_PROGS="yes"
82 > >> > > > > >>
83 > >> > > > > >> for x in "$@" ; do
84 > >> > > > > >> case "${x}" in
85 > >> > > > > >> @@ -972,6 +973,9 @@ for x in "$@" ; do
86 > >> > > > > >> -l|--list-profiles)
87 > >> > > > > >> set_doit list_profiles
88 > >> > > > > >> ;;
89 > >> > > > > >> + -n|--no-default-vars)
90 > >> > > > > >> + DEFAULT_PROGS="no"
91 > >> > > > > >> + ;;
92 > >> > > > > >> -S|--split-profile)
93 > >> > > > > >> if [[ ( $1 != "-S" && $1 !=
94 > >> > > "--split-profile" )
95 > >> > > > > || $# -eq 1 ]] ; then
96 > >> > > > > >> usage 1
97 > >> > > > > >> --
98 > >> > > > > >>
99 > >> > > > > >
100 > >> > > > > > Not sure of the correct mailing list for patches to gcc-config
101 > >> so
102 > >> > > also
103 > >> > > > > adding toolchain@gentoo .
104 > >> > > > > >
105 > >> > > > >
106 > >> > > > > toolchain@g.o should generally be fine.
107 > >> > > > >
108 > >> > > > > Today cc->gcc and gcc->${CHOST}-gcc symlinks are effectively
109 > >> owned by
110 > >> > > > > a single sys-devel/gcc-config package.
111 > >> > > > > gcc-config is calld to update symlinks every time sys-devel/gcc is
112 > >> > > > > installed/updated. That way we never get cc/gcc
113 > >> > > > > out of sync.
114 > >> > > > >
115 > >> > > > > Your change makes /usr/bin/cc an orphan symlink. I think we need
116 > >> to
117 > >> > > > > still keep a 'cc'/'f77' ownership somewhere
118 > >> > > > > (say, a separate package).
119 > >> > > > >
120 > >> > > > > I suggest making a decision to handle or not handle 'cc'/'f77' and
121 > >> > > > > gcc-config build-time, not gcc-config call-time.
122 > >> > > > > That way sys-devel/gcc updates will behave the same as manual
123 > >> > > > > 'gcc-config-' calls.
124 > >> > > > >
125 > >> > > > > Mechanically that could be a Makefile variable that switches the
126 > >> > > > > behaviour on/off at
127 > >> > > > > https://gitweb.gentoo.org/proj/gcc-config.git/tree/Makefile
128 > >> > > > > and exposed as an USE flag on sys-devel/gcc-config ebuild.
129 > >> > > > >
130 > >> > > > > Later we can create a separate ebuild to manage /usr/bin/cc. For
131 > >> gcc
132 > >> > > > > it's not hard, as gcc-config always provides /usr/bin/gcc and
133 > >> > > > > /usr/bin/${CHOST}-gcc.
134 > >> > > > > These can be static symlinks that don't require maintenance
135 > >> updates.
136 > >> > > > >
137 > >> > > > > Thanks for the suggestion. I will look into adding a Makefile
138 > >> > > variable
139 > >> > > > exposed via an USE flag.
140 > >> > >
141 > >> > > You might also need to look in the detail at 'c++', 'cpp' and
142 > >> ${CHOST}-*
143 > >> > > equivalents
144 > >> > > as those also get linked by gcc-config:
145 > >> > >
146 > >> > > $ LANG=C ls -l /usr/bin/ | fgrep 10.0.1 | fgrep -v -- '-10.0.1 ->'
147 > >> > > lrwxrwxrwx 1 root root 43 Feb 4 10:45 c++ ->
148 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/c++
149 > >> > > lrwxrwxrwx 1 root root 43 Feb 4 10:45 cc ->
150 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcc
151 > >> > > lrwxrwxrwx 1 root root 43 Feb 4 10:45 cpp ->
152 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/cpp
153 > >> > > lrwxrwxrwx 1 root root 43 Feb 4 10:45 g++ ->
154 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/g++
155 > >> > > lrwxrwxrwx 1 root root 43 Feb 4 10:45 gcc ->
156 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcc
157 > >> > > lrwxrwxrwx 1 root root 46 Feb 4 10:45 gcc-ar ->
158 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcc-ar
159 > >> > > lrwxrwxrwx 1 root root 46 Feb 4 10:45 gcc-nm ->
160 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcc-nm
161 > >> > > lrwxrwxrwx 1 root root 50 Feb 4 10:45 gcc-ranlib ->
162 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcc-ranlib
163 > >> > > lrwxrwxrwx 1 root root 45 Feb 4 10:45 gccgo ->
164 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gccgo
165 > >> > > lrwxrwxrwx 1 root root 44 Feb 4 10:45 gcov ->
166 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcov
167 > >> > > lrwxrwxrwx 1 root root 49 Feb 4 10:45 gcov-dump ->
168 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcov-dump
169 > >> > > lrwxrwxrwx 1 root root 49 Feb 4 10:45 gcov-tool ->
170 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcov-tool
171 > >> > > lrwxrwxrwx 1 root root 48 Feb 4 10:45 gfortran ->
172 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gfortran
173 > >> > > lrwxrwxrwx 1 root root 45 Feb 4 10:45 go-10 ->
174 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/go-10
175 > >> > > lrwxrwxrwx 1 root root 48 Feb 4 10:45 gofmt-10 ->
176 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gofmt-10
177 > >> > > lrwxrwxrwx 1 root root 48 Feb 4 10:45 lto-dump ->
178 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/lto-dump
179 > >> > > lrwxrwxrwx 1 root root 63 Feb 4 10:45
180 > >> x86_64-pc-linux-gnu-c++
181 > >> > > -> /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-c++
182 > >> > > lrwxrwxrwx 1 root root 63 Feb 4 10:45
183 > >> x86_64-pc-linux-gnu-cpp
184 > >> > > -> /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-cpp
185 > >> > > lrwxrwxrwx 1 root root 63 Feb 4 10:45
186 > >> x86_64-pc-linux-gnu-g++
187 > >> > > -> /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-g++
188 > >> > > lrwxrwxrwx 1 root root 63 Feb 4 10:45
189 > >> x86_64-pc-linux-gnu-gcc
190 > >> > > -> /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gcc
191 > >> > > lrwxrwxrwx 1 root root 66 Feb 4 10:45
192 > >> > > x86_64-pc-linux-gnu-gcc-ar ->
193 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gcc-ar
194 > >> > > lrwxrwxrwx 1 root root 66 Feb 4 10:45
195 > >> > > x86_64-pc-linux-gnu-gcc-nm ->
196 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gcc-nm
197 > >> > > lrwxrwxrwx 1 root root 70 Feb 4 10:45
198 > >> > > x86_64-pc-linux-gnu-gcc-ranlib ->
199 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gcc-ranlib
200 > >> > > lrwxrwxrwx 1 root root 65 Feb 4 10:45
201 > >> > > x86_64-pc-linux-gnu-gccgo ->
202 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gccgo
203 > >> > > lrwxrwxrwx 1 root root 64 Feb 4 10:45
204 > >> > > x86_64-pc-linux-gnu-gcov ->
205 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gcov
206 > >> > > lrwxrwxrwx 1 root root 49 Feb 4 10:45
207 > >> > > x86_64-pc-linux-gnu-gcov-dump ->
208 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcov-dump
209 > >> > > lrwxrwxrwx 1 root root 49 Feb 4 10:45
210 > >> > > x86_64-pc-linux-gnu-gcov-tool ->
211 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gcov-tool
212 > >> > > lrwxrwxrwx 1 root root 68 Feb 4 10:45
213 > >> > > x86_64-pc-linux-gnu-gfortran ->
214 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/x86_64-pc-linux-gnu-gfortran
215 > >> > > lrwxrwxrwx 1 root root 45 Feb 4 10:45
216 > >> > > x86_64-pc-linux-gnu-go-10 ->
217 > >> /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/go-10
218 > >> > > lrwxrwxrwx 1 root root 48 Feb 4 10:45
219 > >> > > x86_64-pc-linux-gnu-gofmt-10 ->
220 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/gofmt-10
221 > >> > > lrwxrwxrwx 1 root root 48 Feb 4 10:45
222 > >> > > x86_64-pc-linux-gnu-lto-dump ->
223 > >> > > /usr/x86_64-pc-linux-gnu/gcc-bin/10.0.1/lto-dump
224 > >> > >
225 > >> > > > Regarding the separate ebuild, I hope someone more knowledgeable
226 > >> > > > than me regarding ebuilds can handle that.
227 > >> > >
228 > >> > > How do you plan to manage those symlinks meanwhile?
229 > >> > >
230 > >> > > I guess there is a confusion in the scope of change I want to do.
231 > >> >
232 > >> > GCC package does not provide cc and f77 binaries or symlinks. These are
233 > >> > provided by the gcc-config
234 > >> > which adds /usr/bin/cc and /usr/bin/f77.
235 > >> > These are not needed for building packages via portage but were added
236 > >> > in https://bugs.gentoo.org/412319 just because it is nice to ensure
237 > >> that
238 > >> > invocations like
239 > >> > $ make
240 > >> > work as is without setting CC explicitly e.g.
241 > >> > $ CC=gcc make
242 > >>
243 > >> I'm afraid "not needed" is desired but not strictly true. I keep seeing
244 > >> packages that use 'cc' accidentally (dev-util/radare2) or explicitly.
245 > >> Don't know if most of them can safely fall back to 'gcc' at ./configure
246 > >> time. I suspect many don't.
247 > >>
248 > >> > I only want to change gcc-config to NOT create /usr/bin/cc and
249 > >> /usr/bin/f77
250 > >> > via an option.
251 > >> > Everything else stays unchanged.
252 > >>
253 > >> I see. Initially you said you want to set your own 'cc' and 'f77'
254 > >> wrapper.
255 > >> Can you clarify what is the motivation to change only a subset of
256 > >> programs?
257 > >> Maybe describe whole intended setup?
258 > >>
259 > >> This is only for Chrome OS setup where I want to switch "cc" to point to
260 > > clang or a different compiler (Switching will be done using a
261 > > different ebuild not used in Gentoo).
262 > > I do not want to disturb Gentoo's current setup in any way other than
263 > > adding an option to "gcc-config"
264 > > that will serve our needs.
265 > >
266 > > It feels very dangerous to have 'cc' point to one compiler (manually set)
267 > >> and 'c99' to another ('gcc').
268 > >> We will start producing more inconsistent environments than we do today.
269 > >>
270 > >> Not installing 'cc'/'f77' at all might be less bad.
271 > >>
272 > >
273 > > Yes, this is exactly what I'd like but some internal teams want '$ make'
274 > > to work
275 > > as is. This option to "not install" these links will be a good first step
276 > > to find out
277 > > if there are any packages relying on 'cc' being present in Chrome OS
278 > > builds.
279 > >
280 > > Thanks,
281 > > Manoj
282 > >
283 > >
284 > >> --
285 > >>
286 > >> Sergei
287 > >>
288 > >
289
290
291 --
292
293 Sergei