49
49
from easybuild .framework .easyblock import EasyBlock
50
50
from easybuild .framework .easyconfig import CUSTOM
51
51
from easybuild .tools .build_log import EasyBuildError
52
- from easybuild .tools .filetools import copy , mkdir , write_file
52
+ from easybuild .tools .config import ERROR
53
+ from easybuild .tools .filetools import apply_regex_substitutions , copy , mkdir , which , write_file
53
54
from easybuild .tools .modules import get_software_root , get_software_version
54
55
from easybuild .tools .run import run_cmd
55
56
from easybuild .tools .systemtools import AARCH64 , POWER , UNKNOWN
@@ -78,7 +79,9 @@ def extra_options():
78
79
extra_vars = {
79
80
'boost_mpi' : [False , "Build mpi boost module" , CUSTOM ],
80
81
'boost_multi_thread' : [False , "Build boost with multi-thread option" , CUSTOM ],
81
- 'toolset' : [None , "Toolset to use for Boost configuration ('--with-toolset for bootstrap.sh')" , CUSTOM ],
82
+ 'toolset' : [None , "Toolset to use for Boost configuration ('--with-toolset' for bootstrap.sh)" , CUSTOM ],
83
+ 'build_toolset' : [None , "Toolset to use for Boost compilation "
84
+ "('toolset' for b2, default calculated from toolset)" , CUSTOM ],
82
85
'mpi_launcher' : [None , "Launcher to use when running MPI regression tests" , CUSTOM ],
83
86
'only_python_bindings' : [False , "Only install Boost.Python library providing Python bindings" , CUSTOM ],
84
87
'use_glibcxx11_abi' : [None , "Use the GLIBCXX11 ABI" , CUSTOM ],
@@ -139,20 +142,38 @@ def configure_step(self):
139
142
tup = (self .cfg ['preconfigopts' ], toolset , self .objdir , self .cfg ['configopts' ])
140
143
run_cmd (cmd % tup , log_all = True , simple = True )
141
144
145
+ # Use build_toolset if specified or the bootstrap toolset without the OS suffix
146
+ self .toolset = self .cfg ['build_toolset' ] or re .sub ('-linux$' , '' , toolset )
147
+
148
+ user_config = []
149
+
150
+ # Explicitely set the compiler path to avoid B2 checking some standard paths like /opt
151
+ cxx = os .getenv ('CXX' )
152
+ if cxx :
153
+ cxx = which (cxx , on_error = ERROR )
154
+ # Remove default toolset config which may lead to duplicate toolsets (e.g. for intel-linux)
155
+ apply_regex_substitutions ('project-config.jam' , [('using %s ;' % toolset , '' )])
156
+ # Add our toolset config with no version and full path to compiler
157
+ user_config .append ("using %s : : %s ;" % (self .toolset , cxx ))
158
+
142
159
if self .cfg ['boost_mpi' ]:
143
160
144
161
self .toolchain .options ['usempi' ] = True
145
162
# configure the boost mpi module
146
163
# http://www.boost.org/doc/libs/1_47_0/doc/html/mpi/getting_started.html
147
164
# let Boost.Build know to look here for the config file
148
165
149
- txt = ''
150
166
# Check if using a Cray toolchain and configure MPI accordingly
151
167
if self .toolchain .toolchain_family () == toolchain .CRAYPE :
152
168
if self .toolchain .PRGENV_MODULE_NAME_SUFFIX == 'gnu' :
153
169
craympichdir = os .getenv ('CRAY_MPICH2_DIR' )
154
170
craygccversion = os .getenv ('GCC_VERSION' )
155
- txt = '\n ' .join ([
171
+ # We configure the gcc toolchain below, so make sure the EC doesn't use another toolset
172
+ if self .toolset != 'gcc' :
173
+ raise EasyBuildError ("For the cray toolchain the 'gcc' toolset must be used." )
174
+ # Remove the previous "using gcc" line add above (via self.toolset) if present
175
+ user_config = [x for x in user_config if not x .startswith ('using gcc :' )]
176
+ user_config .extend ([
156
177
'local CRAY_MPICH2_DIR = %s ;' % craympichdir ,
157
178
'using gcc ' ,
158
179
': %s' % craygccversion ,
@@ -170,9 +191,9 @@ def configure_step(self):
170
191
else :
171
192
raise EasyBuildError ("Bailing out: only PrgEnv-gnu supported for now" )
172
193
else :
173
- txt = "using mpi : %s ;" % os .getenv ("MPICXX" )
194
+ user_config . append ( "using mpi : %s ;" % os .getenv ("MPICXX" ) )
174
195
175
- write_file ('user-config.jam' , txt , append = True )
196
+ write_file ('user-config.jam' , ' \n ' . join ( user_config ) , append = True )
176
197
177
198
def build_boost_variant (self , bjamoptions , paracmd ):
178
199
"""Build Boost library with specified options for bjam."""
@@ -184,12 +205,14 @@ def build_boost_variant(self, bjamoptions, paracmd):
184
205
self .cfg ['preinstallopts' ], self .bjamcmd , bjamoptions , paracmd , self .cfg ['installopts' ])
185
206
run_cmd (cmd , log_all = True , simple = True )
186
207
# clean up before proceeding with next build
187
- run_cmd ("./%s --clean-all" % self .bjamcmd , log_all = True , simple = True )
208
+ run_cmd ("./%s %s --clean-all" % ( self .bjamcmd , bjamoptions ) , log_all = True , simple = True )
188
209
189
210
def build_step (self ):
190
211
"""Build Boost with bjam tool."""
191
212
192
- bjamoptions = " --prefix=%s" % self .objdir
213
+ bjamoptions = " --prefix=%s --user-config=user-config.jam" % self .objdir
214
+ if 'toolset=' not in self .cfg ['buildopts' ]:
215
+ bjamoptions += " toolset=" + self .toolset
193
216
194
217
cxxflags = os .getenv ('CXXFLAGS' )
195
218
# only disable -D_GLIBCXX_USE_CXX11_ABI if use_glibcxx11_abi was explicitly set to False
@@ -224,7 +247,7 @@ def build_step(self):
224
247
225
248
if self .cfg ['boost_mpi' ]:
226
249
self .log .info ("Building boost_mpi library" )
227
- self .build_boost_variant (bjamoptions + " --user-config=user-config.jam -- with-mpi" , paracmd )
250
+ self .build_boost_variant (bjamoptions + " --with-mpi" , paracmd )
228
251
229
252
if self .cfg ['boost_multi_thread' ]:
230
253
self .log .info ("Building boost with multi threading" )
@@ -233,7 +256,7 @@ def build_step(self):
233
256
# if both boost_mpi and boost_multi_thread are enabled, build boost mpi with multi-thread support
234
257
if self .cfg ['boost_multi_thread' ] and self .cfg ['boost_mpi' ]:
235
258
self .log .info ("Building boost_mpi with multi threading" )
236
- extra_bjamoptions = " --user-config=user-config.jam -- with-mpi threading=multi --layout=tagged"
259
+ extra_bjamoptions = " --with-mpi threading=multi --layout=tagged"
237
260
self .build_boost_variant (bjamoptions + extra_bjamoptions , paracmd )
238
261
239
262
# install remainder of boost libraries
0 commit comments