On 12/19/2019 01:47 PM, Neal Gompa wrote:
On Thu, Dec 19, 2019 at 3:44 PM Ben Cotton <bcotton(a)redhat.com>
wrote:
>
>
https://fedoraproject.org/wiki/Changes/Use-Update-Alternatives-For-usr-bi...
>
> == Summary ==
> Modify the gcc package so that the /usr/bin/cc and /usr/bin/c++
> symlinks are managed by update-alternatives.
>
> == Owner ==
> * Name: [[User:tstellar| Tom Stellard]]
> * Email: <tstellar(a)redhat.com>
>
> == Detailed Description ==
> The gcc package currently installs symlinks to /usr/bin/cc and
> /usr/bin/c++ which point to /usr/bin/gcc and /usr/bin/g++
> respectively. For this change, the gcc package will be modified so
> that update-alternatives creates and manages these symlinks.
>
> In addition to modifying the gcc package, the clang package will be
> modified so that /usr/bin/clang and /usr/bin/clang++ can be used as
> alternatives for /usr/bin/cc and /usr/bin/c++. The clang alternatives
> will have a lower priority than the gcc alternatives, so that by
> default, gcc will provide the /usr/bin/cc and /usr/bin/c++
> implementations.
>
> The clang package currently has a run-time dependency on gcc, so this
> ensures that gcc will always provide the default implementation,
> because it's impossible to install clang without gcc.
>
> The only way users will be able to change the /usr/bin/cc or
> /usr/bin/c++ implementations will be by explicitly using the
> update-alternatives tool.
>
> == Benefit to Fedora ==
> Many build systems default to using /usr/bin/cc and /usr/bin/c++ as
> the default C/C++ compilers. Being able to easily swap out these
> implementation will provide a lot of flexibility within Fedora for
> doing things like:
>
> * Setting up alternative buildroots for testing.
> * Installing a gcc wrapper script to /usr/bin/cc to help migrate
> packages to new compiler flags or to capture statistics about compiler
> usage.
> * Letting users experiment easily with alternate compilers.
> * Easily switch between system gcc and a development version of gcc.
>
> == Scope ==
> * Proposal owners: The proposal owner will implement the necessary
> changes in the gcc and clang packages.
>
> * Other developers: The gcc maintainers will be responsible for
> reviewing and approving changes to the gcc package.
>
> * Release engineering: (a check of an impact with Release Engineering is needed)
> * Policies and guidelines: No policies or guidelines will need to be
> updated as a result of this change.
> * Trademark approval: N/A (not needed for this Change)
>
>
> == Upgrade/compatibility impact ==
> This change should not impact upgradeability.
>
> == How To Test ==
> CI tests will be added to the gcc package to ensure that /usr/bin/cc
> and /usr/bin/c++ still point to /usr/bin/gcc and /usr/bin/g++ when
> installed. There will also be a CI test added to the clang package to
> ensure that /usr/bin/gcc and /usr/bin/g++ remain the default when
> clang is installed.
>
> == User Experience ==
> This change will give users a much better way to experiment using
> other compilers for their own development. They will be able to
> easily switch between different compilers without having to modify
> their projects build system or make non-standard changes to their
> Fedora system.
>
> == Dependencies ==
> This change has no other dependencies besides the changes to the gcc
> and clang packages.
>
> == Contingency Plan ==
> * Contingency mechanism: (What to do? Who will do it?) Proposal Owner
> will revert changes made to gcc and clang packages and rebuild.
> * Contingency deadline: If the changes are not complete by 2 weeks
> before the mass rebuild, then we will consider postponing to the next
> Fedora release and back out any changes that were made.
> * Blocks release? No
> * Blocks product? None
>
> == Documentation ==
> Release notes will be added for this change.
>
> == Release Notes ==
> The user /usr/bin/cc and /usr/bin/c++ symlinks are now managed by
> update-alternatives. If you would like to change these symlinks to
> point to another compiler, like clang, for example, you can use these
> commands:
>
> `update-alternatives --set cc /usr/bin/clang`
>
> `update-alternatives --set c++ /usr/bin/clang++`
>
I don't know if I want *more* alternatives usage in Fedora. I like the
fact that a basic buildroot is generally supposed to work without
scriptlets... On the other hand, I think we're already using
alternatives for ld...
Aside from making it possible to swap the system compiler with
alternatives, what benefit do we get? Are there other, less script-y
approaches that we could use?
The only benefit here is being able to swap out the system compiler.
For a typical user, I'm not sure there is a good alternative to this
for changing the default compiler. However, there are other options
we have in the Fedora buildroots, to switch the default compiler, like
using the __cc and __cxx macros and making sure the %cmake and %autoconf
macros learn to respect this. But macro based solutions don't really
help if project hard code /usr/bin/gcc or /usr/bin/cc in their makefiles
or build systems.
-Tom