Packaging of netlib-lapack for windows (#24993)

MSVC's internal CMake and Ninja now detected by spack external find and added to packages.yaml

Saving progress on packaging zlib for Windows

Fixing the shared CMake flag

* Loading Intel's ifx Fortran compiler into MSVC; if there are multiple
versions of MSVC installed and detected, ifx will only be placed into
the first block written in compilers.yaml. The version number of ifx can
be detected using MSVC's version flag (instead of /QV) by using
ignore_version_errors. This commit also provides support for detection
of Intel compilers in their own compiler block by adding ifx.exe to the
fc/f77_name blocks inside intel.py

* Giving CMake a Fortran compiler argument

* Adding patch file for removing duplicated mangling header for versions 3.9.1 and older; static and shared now successfully building on Windows

* Have netlib-lapack depend  on ninja@1.10

Co-authored-by: John R. Cary <cary@txcorp.com>
Co-authored-by: Jared Popelar <jpopelar@txcorp.com>

Making a default config.yaml for Windows

Small path length for build_stage

Provide more prerequisite details, mention default config.yaml

Killing an unnecessary setvars call

Replacing some lost changes, proofreading, updating windows-supported package list

Co-authored-by: John Parent <john.parent@kitware.com>
This commit is contained in:
Jared Popelar
2021-05-17 14:56:42 -06:00
committed by Peter Scheibel
parent 012758c179
commit 15ef85e161
11 changed files with 295 additions and 121 deletions

View File

@@ -71,6 +71,7 @@ class NetlibLapack(CMakePackage):
depends_on('blas', when='+external-blas')
depends_on('netlib-xblas+fortran+plain_blas', when='+xblas')
depends_on('python@2.7:', type='test')
depends_on('ninja@1.10.0:', when='platform=windows')
# We need to run every phase twice in order to get static and shared
# versions of the libraries. When ~shared, we run the default
@@ -92,6 +93,11 @@ def patch(self):
'${CMAKE_CURRENT_SOURCE_DIR}/cmake/',
'CBLAS/CMakeLists.txt', string=True)
# Remove duplicate header file that gets generated during CMake shared
# builds: https://github.com/Reference-LAPACK/lapack/issues/583
if self.spec.satisfies('platform=windows @0:3.9.1'):
force_remove('LAPACKE/include/lapacke_mangling.h')
@property
def blas_libs(self):
shared = True if '+shared' in self.spec else False

View File

@@ -89,6 +89,8 @@ class Openssl(Package): # Uses Fake Autotools, should subclass Package
description=('Use certificates from the ca-certificates-mozilla '
'package, symlink system certificates, or none'))
variant('docs', default=False, description='Install docs and manpages')
variant('shared', default=False, description="Build shared library version")
variant('dynamic', default=False, description="Link with MSVC's dynamic runtime library")
depends_on('zlib')
depends_on('perl@5.14.0:', type=('build', 'test'))
@@ -134,26 +136,65 @@ def install(self, spec, prefix):
if self.spec.satisfies('%nvhpc os=centos7'):
options.append('-D__STDC_NO_ATOMICS__')
config = Executable('./config')
config('--prefix=%s' % prefix,
'--openssldir=%s' % join_path(prefix, 'etc', 'openssl'),
'-I{0}'.format(self.spec['zlib'].prefix.include),
'-L{0}'.format(self.spec['zlib'].prefix.lib),
*options)
# Make a flag for shared library builds
shared_flag = ''
if spec.satisfies('~shared'):
shared_flag = 'no-shared'
# On Windows, we use perl for configuration and build through MSVC
# nmake.
if spec.satisfies('platform=windows'):
config = Executable('perl')
config('Configure',
'--prefix=%s' % prefix,
'--openssldir=%s' % join_path(prefix, 'etc', 'openssl'),
'CC=\"%s\"' % os.environ.get('SPACK_CC'),
'CXX=\"%s\"' % os.environ.get('SPACK_CXX'),
'%s' % shared_flag,
'VC-WIN64A')
else:
config = Executable('./config')
config('--prefix=%s' % prefix,
'--openssldir=%s' % join_path(prefix, 'etc', 'openssl'),
'-I{0}'.format(self.spec['zlib'].prefix.include),
'-L{0}'.format(self.spec['zlib'].prefix.lib),
*options)
# Remove non-standard compiler options if present. These options are
# present e.g. on Darwin. They are non-standard, i.e. most compilers
# (e.g. gcc) will not accept them.
filter_file(r'-arch x86_64', '', 'Makefile')
make()
if spec.satisfies('+dynamic'):
# This variant only makes sense for Windows
if spec.satisfies('platform=windows'):
filter_file(r'MT', 'MD', 'makefile')
else:
tty.warn("Dynamic runtime builds are only available for "
"Windows operating systems. Please disable "
"+dynamic to suppress this warning.")
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake()
else:
make()
if self.run_tests:
make('test', parallel=False) # 'VERBOSE=1'
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake('test', parallel=False)
else:
make('test', parallel=False) # 'VERBOSE=1'
install_tgt = 'install' if self.spec.satisfies('+docs') else 'install_sw'
# See https://github.com/openssl/openssl/issues/7466#issuecomment-432148137
make(install_tgt, parallel=False)
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake(install_tgt, parallel=False)
else:
make(install_tgt, parallel=False)
@run_after('install')
def link_system_certs(self):

View File

@@ -6,7 +6,7 @@
# Although zlib comes with a configure script, it does not use Autotools
# The AutotoolsPackage causes zlib to fail to build with PGI
class Zlib(Package):
class Zlib(CMakePackage):
"""A free, general-purpose, legally unencumbered lossless
data-compression library.
"""
@@ -37,19 +37,54 @@ def libs(self):
['libz'], root=self.prefix, recursive=True, shared=shared
)
def cmake_args(self):
args = ['-DBUILD_SHARED_LIBS:BOOL=' +
('ON' if self._building_shared else 'OFF')]
return args
@property
def build_directory(self):
return join_path(self.stage.source_path,
'spack-build-shared' if self._building_shared
else 'spack-build-static')
def setup_build_environment(self, env):
if '+pic' in self.spec:
env.append_flags('CFLAGS', self.compiler.cc_pic_flag)
if '+optimize' in self.spec:
env.append_flags('CFLAGS', '-O2')
env.append_flags('CFLAGS', '-O2')
# Build, install, and check both static and shared versions of the
# libraries when +shared
@when('+shared platform=windows')
def cmake(self, spec, prefix):
for self._building_shared in (False, True):
super(Zlib, self).cmake(spec, prefix)
@when('+shared platform=windows')
def build(self, spec, prefix):
for self._building_shared in (False, True):
super(Zlib, self).build(spec, prefix)
@when('+shared platform=windows')
def check(self):
for self._building_shared in (False, True):
super(Zlib, self).check()
def install(self, spec, prefix):
config_args = []
if '~shared' in spec:
config_args.append('--static')
configure('--prefix={0}'.format(prefix), *config_args)
if 'platform=windows' in self.spec and '+shared' in self.spec:
for self._building_shared in (False, True):
super(Zlib, self).install(spec, prefix)
else:
config_args = []
if '~shared' in spec:
config_args.append('--static')
configure('--prefix={0}'.format(prefix), *config_args)
make()
if self.run_tests:
make('check')
make('install')
make()
if self.run_tests:
make('check')
make('install')