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
This commit is contained in:
		 Nichols A. Romero
					Nichols A. Romero
				
			
				
					committed by
					
						 Peter Scheibel
						Peter Scheibel
					
				
			
			
				
	
			
			
			 Peter Scheibel
						Peter Scheibel
					
				
			
						parent
						
							54c19ce16c
						
					
				
				
					commit
					42b01c02b1
				
			| @@ -169,6 +169,8 @@ class Qmcpack(CMakePackage, CudaPackage): | |||||||
|     patch_checksum = 'c066c79901a612cf8848135e0d544efb114534cca70b90bfccc8ed989d3d9dde' |     patch_checksum = 'c066c79901a612cf8848135e0d544efb114534cca70b90bfccc8ed989d3d9dde' | ||||||
|     patch(patch_url, sha256=patch_checksum, when='@3.1.0:3.3.0') |     patch(patch_url, sha256=patch_checksum, when='@3.1.0:3.3.0') | ||||||
|  |  | ||||||
|  |     flag_handler = CMakePackage.build_system_flags | ||||||
|  |  | ||||||
|     def patch(self): |     def patch(self): | ||||||
|         # FindLibxml2QMC.cmake doesn't check the environment by default |         # FindLibxml2QMC.cmake doesn't check the environment by default | ||||||
|         # for libxml2, so we fix that. |         # for libxml2, so we fix that. | ||||||
| @@ -180,16 +182,6 @@ def cmake_args(self): | |||||||
|         spec = self.spec |         spec = self.spec | ||||||
|         args = [] |         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, |         # This issue appears specifically with the the Intel compiler, | ||||||
|         # but may be an issue with other compilers as well. The final fix |         # 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. |         # probably needs to go into QMCPACK's CMake instead of in Spack. | ||||||
| @@ -200,12 +192,6 @@ def cmake_args(self): | |||||||
|         if '%intel' in spec: |         if '%intel' in spec: | ||||||
|             args.append('-DQMC_EXTRA_LIBS=-lifcore') |             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. |         # Currently FFTW_HOME and LIBXML2_HOME are used by CMake. | ||||||
|         # Any CMake warnings about other variables are benign. |         # Any CMake warnings about other variables are benign. | ||||||
|         xml2_prefix = spec['libxml2'].prefix |         xml2_prefix = spec['libxml2'].prefix | ||||||
| @@ -318,10 +304,27 @@ def cmake_args(self): | |||||||
|     # QMCPACK 3.6.0 release and later has a functional 'make install', |     # QMCPACK 3.6.0 release and later has a functional 'make install', | ||||||
|     # the Spack 'def install' is retained for backwards compatiblity. |     # the Spack 'def install' is retained for backwards compatiblity. | ||||||
|     # Note that the two install methods differ in their directory |     # 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') |     @when('@:3.5.0') | ||||||
|     def install(self, spec, prefix): |     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 |         # QMCPACK 'make install' does nothing, which causes | ||||||
|         # Spack to throw an error. |         # Spack to throw an error. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user