Boost logo

Boost-Build :

Subject: Re: [Boost-build] Auto-select the 'best' gcc available?
From: Vladimir Prus (ghost_at_[hidden])
Date: 2008-11-09 02:15:11

On Friday 07 November 2008 19:57:48 alexrichardson_at_[hidden] wrote:
> I am attempting to replace a home-grown build system with I
> have just a couple days of experience with, so I am very new.
> One of the features of the previous system was that it would auto-select
> the version of gcc to use on a machine by using the first version that
> showed up on a list. (Most of the build machines have mutliple versions of
> gcc installed.) So, the build system would have a list such as:
> gcc-4.3
> gcc-4.1
> gcc-3.4
> The build system would first attempt to use gcc-4.3, if it was not
> available on the machine, it would try 4.1, etc... I would like to get
> similar functionality from My naive approach was to create a
> site-config.jam file with something along the lines of:
> using gcc : 4.3 : gcc-4.3 ;
> using gcc : 4.2 : gcc-4.2 ;
> using gcc : 4.1 : gcc-4.1 ;
> This seemed to result in the system trying to build the project 3 times,
> once for each gcc version.

This is not supposed to happen. Do you have some magic in your project?

> Also, the 'list' of gcc versions needs to be
> specified on a per-project basis. Ie for some projects, gcc-3.x is
> the 'best' compiler, because gcc 4.x will not work.
> So in summary: Is there a way to specify something along the lines of:
> if gcc-4.3 exists, use it
> else if gcc-4.2 exists, use it,
> else if gcc-4.1 exists, use it, etc.....

I think the the closes you can get is indirect conditional requirements,
see here:

Your Jamroot might look like this:

  import feature ;
  rule select-gcc-version ( properties * )
    local result ;
    if <toolset>gcc in $(properties)
        local versions = [ feature.values <toolset-gcc:version> ] ;
        ECHO "All versions: " $(versions) ;
        # Smart logic
        result += <toolset-gcc:version>$(versions[0]) ;
    return $(result) ;

  exe hello : hello.cpp : <conditional>@select-gcc-version ;

This is not ideal solution, in particular this function will be called for each
target built. A better solution might be available when we implement the configuration
framework -- so that the choice of compiler version can be done once, at configure

- Volodya

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at