Current best practice to select GCC compiler in Portfile

David Strubbe dstrubbe at macports.org
Thu Feb 26 08:05:25 PST 2015


Hi Rainer,

Sean did indeed add the default_variants to the compilers portgroup in the
last month or two. Perhaps you were trying before then.

David

On Thu, Feb 26, 2015 at 9:30 AM, Rainer Müller <raimue at macports.org> wrote:

> On 2015-02-26 14:22, Artur Szostak wrote:
> > Let me rephrase: Assuming I have to use gcc rather than clang. What
> > is the standard/best way to do that in a Portfile?
> >
> > I have a numerical code that gives inferior results with clang
> > compared to gcc. Thus, I need to make sure the port uses GCC. Also,
> > the code is C99, so that should mitigate any ABI issues.
>
> Starting with Xcode 6, there are only clang and macports-clang-* in the
> default list of usable compilers. To use gcc you explicitly need to
> whitelist it.
>
> The simplest and least flexible would be to just use a specific version
> of gcc:
>
>   configure.compiler macports-gcc-4.9
>
>
> To be more flexible, you can also create variants that allow to choose
> the version of gcc with +gcc49, +gcc48, etc:
>
>   variant gcc47 description {Build with MacPorts gcc 4.7 compiler}
> conflicts gcc48 gcc49 {
>       configure.compiler macports-gcc-4.7
>   }
>
>   variant gcc48 description {Build with MacPorts gcc 4.8 compiler}
> conflicts gcc47 gcc49 {
>       configure.compiler macports-gcc-4.8
>   }
>
>   variant gcc49 description {Build with MacPorts gcc 4.9 compiler}
> conflicts gcc47 gcc48 {
>       configure.compiler macports-gcc-4.9
>   }
>
>   if {![variant_isset gcc47] && ![variant_isset gcc48] && ![variant_isset
> gcc49]} {
>       default_variants +gcc49
>   }
>
>
> Recently, there was also a new compilers port group added to the ports
> tree which is supposed to generate these variants automatically.
> However, as far as I was able to test it, it does not automatically
> handle the selection of a default compiler yet as shown in the example
> above using the variant_isset conditionals, so you still need to add
> that. Manually adding this would make the construct a bit fragile as
> new versions will be added to the port group in the future.
>
>   compilers.choose    cc cpp
>   compilers.setup     -clang -llvm -dragonegg
>   default_variants    +gcc49
>
> @Sean, David: did I do something wrong or is automatic selection just
> not supported yet by the compilers port group?
>
> Rainer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-dev/attachments/20150226/893b2e76/attachment.html>


More information about the macports-dev mailing list