You are not logged in.

#1 2021-06-07 05:19:16

cscphy
Member
Registered: 2017-05-06
Posts: 17

multiple gcc versions

Is there a possibility to install multiple versions of the gcc toolchain, and "enable" them via a script, much like the gcc-config script of Gentoo Linux?

I am of course aware that one could manually install different versions of gcc under a separate directory (say, /opt) and export the various variables CXX, etc... But I am looking for an easier solution, like the gcc-config that simply "enables" a given compiler version.

Offline

#2 2021-06-07 06:54:14

seth
Member
Registered: 2012-09-03
Posts: 25,016

Re: multiple gcc versions

gcc10 is in the repos, older versions in the AUR.
You should™ be able to install them all in parallel.

Then you configure or export the desired binary to the build system (eg $CC and $CXX should™ do)
https://www.gnu.org/software/make/manua … ables.html

That approach also doesn't root permissions to juggle around files on your disk.

Edit: I assume this is an xy-problem, what's the cause of your inquiry?

Last edited by seth (2021-06-07 06:54:38)

Online

#3 2021-06-07 07:18:53

cscphy
Member
Registered: 2017-05-06
Posts: 17

Re: multiple gcc versions

Thanks.
Regarding exporting variables: as I mentioned in the post, I am aware that one can export CC, CXX etc to point to the desired compiler version. This can require some effort, especially in conjunction with other programs of the toolchain; e.g., when compiling a library with -flto, ar may need full path of the lto plugin-in. Or when using an MPI wrapper, etc.

It would be much easier to have a script that takes care of the whole job, such that one could simply "switch" to the desired version, then invoke gcc without additional requirements.

Offline

#4 2021-06-07 07:31:48

seth
Member
Registered: 2012-09-03
Posts: 25,016

Re: multiple gcc versions

"AR=/usr/bin/gcc-ar-10" ?
I've not tested, but would expect eg. openmpi to respect those variables?

If you do this a lot, it of course makes sense to use a  script or shell include that exports those variables.

Online

#5 2021-06-07 13:05:19

cscphy
Member
Registered: 2017-05-06
Posts: 17

Re: multiple gcc versions

seth wrote:

"AR=/usr/bin/gcc-ar-10" ?

Ops, you are right. I was not exporting AR, and so using a version of ar not matching that of gcc; hence the need for an additional --plugin option.

seth wrote:

I've not tested, but would expect eg. openmpi to respect those variables?

Not really. At least with openMPI, you need to additionally export OMPI_MPICC and OMPI_MPICXX for instance.

seth wrote:

If you do this a lot, it of course makes sense to use a  script or shell include that exports those variables.

I was sort-of hoping that somebody had already programmed that...

Offline

Board footer

Powered by FluxBB