From 42b01c02b14aa609e6b0ffdde31a10389fc9cf53 Mon Sep 17 00:00:00 2001 From: "Nichols A. Romero" Date: Thu, 2 May 2019 21:13:19 -0500 Subject: QMCPACK: compiler flags and mpi wrapper updates (#11326) * Set mpi compiler wrappers using CC/etc. variables as recommended at https://spack.readthedocs.io/en/latest/packaging_guide.html#compiler-wrappers rather than setting CMake variables like -DCMAKE_C_COMPILER * Use convenience functionality provided by inherited CMakePackage to export all compiler flags as CMake options --- .../repos/builtin/packages/qmcpack/package.py | 39 ++++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/qmcpack/package.py b/var/spack/repos/builtin/packages/qmcpack/package.py index fdf3ab1539..2a9f30cc23 100644 --- a/var/spack/repos/builtin/packages/qmcpack/package.py +++ b/var/spack/repos/builtin/packages/qmcpack/package.py @@ -169,6 +169,8 @@ class Qmcpack(CMakePackage, CudaPackage): patch_checksum = 'c066c79901a612cf8848135e0d544efb114534cca70b90bfccc8ed989d3d9dde' patch(patch_url, sha256=patch_checksum, when='@3.1.0:3.3.0') + flag_handler = CMakePackage.build_system_flags + def patch(self): # FindLibxml2QMC.cmake doesn't check the environment by default # for libxml2, so we fix that. @@ -180,16 +182,6 @@ class Qmcpack(CMakePackage, CudaPackage): spec = self.spec args = [] - # This bit of code is needed in order to pass compiler.yaml flags - # into the QMCPACK's CMake. Probably the CMake base class in - # the code of Spack should be doing this instead. Otherwise, it - # it would need to be done on a per package basis which is - # problematic. - cflags = spec.compiler_flags['cflags'] - cxxflags = spec.compiler_flags['cxxflags'] - args.append('-DCMAKE_C_FLAGS=%s' % ' '.join(cflags)) - args.append('-DCMAKE_CXX_FLAGS=%s' % ' '.join(cxxflags)) - # This issue appears specifically with the the Intel compiler, # but may be an issue with other compilers as well. The final fix # probably needs to go into QMCPACK's CMake instead of in Spack. @@ -200,12 +192,6 @@ class Qmcpack(CMakePackage, CudaPackage): if '%intel' in spec: args.append('-DQMC_EXTRA_LIBS=-lifcore') - if '+mpi' in spec: - mpi = spec['mpi'] - args.append('-DCMAKE_C_COMPILER={0}'.format(mpi.mpicc)) - args.append('-DCMAKE_CXX_COMPILER={0}'.format(mpi.mpicxx)) - args.append('-DMPI_BASE_DIR:PATH={0}'.format(mpi.prefix)) - # Currently FFTW_HOME and LIBXML2_HOME are used by CMake. # Any CMake warnings about other variables are benign. xml2_prefix = spec['libxml2'].prefix @@ -318,10 +304,27 @@ class Qmcpack(CMakePackage, CudaPackage): # QMCPACK 3.6.0 release and later has a functional 'make install', # the Spack 'def install' is retained for backwards compatiblity. # Note that the two install methods differ in their directory - # structure. + # structure. Additionally, we follow the recommendation on the Spack + # website for defining the compilers to be the MPI compiler wrappers. + # https://spack.readthedocs.io/en/latest/packaging_guide.html#compiler-wrappers + @when('@3.6.0:') + def install(self, spec, prefix): + if '+mpi' in spec: + env['CC'] = spec['mpi'].mpicc + env['CXX'] = spec['mpi'].mpicxx + env['F77'] = spec['mpi'].mpif77 + env['FC'] = spec['mpi'].mpifc + + with working_dir(self.build_directory): + make('install') + @when('@:3.5.0') def install(self, spec, prefix): - """Make the install targets""" + if '+mpi' in spec: + env['CC'] = spec['mpi'].mpicc + env['CXX'] = spec['mpi'].mpicxx + env['F77'] = spec['mpi'].mpif77 + env['FC'] = spec['mpi'].mpifc # QMCPACK 'make install' does nothing, which causes # Spack to throw an error. -- cgit v1.2.3-70-g09d2