Boost logo

Boost-Build :

Subject: Re: [Boost-build] Building OpenMP targets
From: Pascal Germroth (pascal_at_[hidden])
Date: 2013-09-23 16:44:36


Hi,

sorry for the lag, missed the mail.

> Try this:
>
> import feature ;
> feature.feature openmp : yes : optional composite propagated ;
>
> feature.compose <openmp>yes :
> <toolset>gcc:<cxxflags>-fopenmp
> <toolset>gcc:<linkflags>-fopenmp
> <toolset>intel:<cxxflags>-openmp
> <toolset>intel:<linkflags>-openmp
> <toolset>clang:<build>no
> <toolset>msvc: ...
> ...
> ;
>
> project : requirements ... ;
> exe example : example.cpp : <openmp>yes ;

This doesn't seem to work, here is what I tried:

    import feature : * ;
    feature openmp : yes : optional composite propagated ;

Simple case: adds the flag for all compilers, causing an error for
clang, but at least it as an effect:

    compose <openmp>yes : <cxxflags>-fopenmp ;

Then I tried adding the dependency on the <toolset> but no permutation
works. From what I can tell from the code "compose" parses its argument
as a string and doesn't support ":", setting <toolset> to
"gcc:<cxxflags>" which down the way causes an "unknown toolset" error.

    compose <openmp>yes : <toolset>gcc:<cxxflags>-fopenmp ;

 This doesn't work because toolset is no composite feature (?)

    compose <toolset>gcc:<openmp>yes : ... ;

This one doesn't cause an error but is just ignored

    compose <openmp>yes:<toolset>gcc : ... ;

I also tried copying the implementation for <optimization>, where the
compiler definitions use toolset.flags to set compiler options based on
the value, basically what I want, but while "toolset.flags
gcc.compile ..." works in the gcc.jam file, it can't be used across
modules, giving the error "Module openmp attempted to set flags for
module gcc".

What I have arrived at is this rule which returns the options, using
<build>no as default and overriding it with <build>yes on supported
compilers.

    rule openmp return
      <build>no
      <toolset>gcc:<cxxflags>-fopenmp
      <toolset>gcc:<linkflags>-fopenmp
      <toolset>gcc:<build>yes
      <toolset>intel:<cxxflags>-openmp
      <toolset>intel:<linkflags>-openmp
      <toolset>intel:<build>yes
    ;

    exe openmp_test : openmp_test.cpp : [ openmp ] ;

Not quite sure about that, but if the alternative is changing bjams tool
definitions...

Cheers,

-- 
pascal germroth

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk