How to force use gcc-5 over default gcc in a Launchpad build

Asked by Pascal Mons on 2018-11-08

When building on a specific computer we can use update-alternatives --config gcc
However this is not possible when building in Launchpad.
I have seen some PPAs which build a GCC Defaults source package using a given version of gcc then linking this PPA when building.
Is it the only way to proceed ?
How can we use gcc-5 or g++-5 instead of gcc or g++ when building with Launchpad ?

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Pascal Mons
Solved:
2018-11-08
Last query:
2018-11-08
Last reply:
2018-11-08
Colin Watson (cjwatson) said : #1

Building gcc-defaults is indeed normally overkill. The usual way to do that kind of thing is to build-depend on gcc-5 and/or g++-5 and pass CC=gcc-5 and/or CXX=g++-5 to configure in debian/rules, although depending on the specific package's build system you may need a slight variation on that.

For example, the grub2 package in Ubuntu does this in order to pin a particular GCC version, not so much because it specifically needs that version but because it often needs particular care when upgrading from one version to another. grub2 has a pretty specialised build system so you're unlikely to be able to copy and paste from its debian/rules, but it at least serves as an example.

Pascal Mons (anton+) said : #2

Thank you for your insight.
Yes I didn't know we can pass that argument in debian/rules.
Usually I pass the CFLAGS or CXXFLAGS.
I will try this out.
Many thanks.

Pascal Mons (anton+) said : #3

Thank you.