Пример #1
0
class Jq(AutotoolsPackage):
    """jq is a lightweight and flexible command-line JSON processor."""

    homepage = "https://stedolan.github.io/jq/"
    url = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz"

    version('1.6',
            sha256=
            '5de8c8e29aaa3fb9cc6b47bb27299f271354ebb72514e3accadc7d38b5bbaa72')
    version('1.5',
            sha256=
            'c4d2bfec6436341113419debf479d833692cc5cdab7eb0326b5a4d4fbe9f493c')

    depends_on('oniguruma')
    depends_on('[email protected]:', type='build')

    if sys.platform == 'darwin' and macos_version() >= Version('10.15'):
        patch('builtinc.patch', when='@1.5:')

    @run_after('install')
    @on_package_attributes(run_tests=True)
    def install_test(self):
        jq = self.spec['jq'].command
        f = os.path.join(os.path.dirname(__file__), 'input.json')

        assert jq('.bar', input=f, output=str) == '2\n'
Пример #2
0
    def install(self, spec, prefix):
        options = []
        options.extend(std_cmake_args)
        options.extend([
            '-DOCE_INSTALL_PREFIX=%s' % prefix,
            '-DOCE_BUILD_SHARED_LIB:BOOL=ON',
            '-DCMAKE_BUILD_TYPE:STRING=Release', '-DOCE_DATAEXCHANGE:BOOL=ON',
            '-DOCE_DISABLE_X11:BOOL=%s' % ('OFF' if '+X11' in spec else 'ON'),
            '-DOCE_DRAW:BOOL=OFF', '-DOCE_MODEL:BOOL=ON',
            '-DOCE_MULTITHREAD_LIBRARY:STRING=%s' %
            ('TBB' if '+tbb' in spec else 'NONE'), '-DOCE_OCAF:BOOL=ON',
            '-DOCE_USE_TCL_TEST_FRAMEWORK:BOOL=OFF',
            '-DOCE_VISUALISATION:BOOL=OFF', '-DOCE_WITH_FREEIMAGE:BOOL=OFF',
            '-DOCE_WITH_GL2PS:BOOL=OFF', '-DOCE_WITH_OPENCL:BOOL=OFF'
        ])

        if platform.system() == 'Darwin':
            options.extend([
                '-DOCE_OSX_USE_COCOA:BOOL=ON',
            ])

        if platform.system() == 'Darwin' and (macos_version() >=
                                              Version('10.12')):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)

        cmake('.', *options)
        make("install/strip")
        if self.run_tests:
            make("test")
Пример #3
0
class Bison(AutotoolsPackage):
    """Bison is a general-purpose parser generator that converts
    an annotated context-free grammar into a deterministic LR or
    generalized LR (GLR) parser employing LALR(1) parser tables."""

    homepage = "https://www.gnu.org/software/bison/"
    url = "https://ftpmirror.gnu.org/bison/bison-3.4.2.tar.gz"

    version('3.4.2',
            sha256=
            'ff3922af377d514eca302a6662d470e857bd1a591e96a2050500df5a9d59facf')
    version('3.0.5',
            sha256=
            'cd399d2bee33afa712bac4b1f4434e20379e9b4099bce47189e09a7675a2d566')
    version('3.0.4',
            sha256=
            'b67fd2daae7a64b5ba862c66c07c1addb9e6b1b05c5f2049392cfd8a2172952e')
    version('2.7',
            sha256=
            '19bbe7374fd602f7a6654c131c21a15aebdc06cc89493e8ff250cb7f9ed0a831')

    # https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00008.html
    patch('parallel.patch', when='@3.4.2')

    depends_on('diffutils', type='build')
    depends_on('m4', type=('build', 'run'))
    depends_on('perl', type='build')
    depends_on('help2man', type='build')

    patch('pgi.patch', when='@3.0.4')

    if sys.platform == 'darwin' and macos_version() >= Version('10.13'):
        patch('secure_snprintf.patch', level=0, when='@3.0.4')

    build_directory = 'spack-build'
Пример #4
0
class Bison(AutotoolsPackage, GNUMirrorPackage):
    """Bison is a general-purpose parser generator that converts
    an annotated context-free grammar into a deterministic LR or
    generalized LR (GLR) parser employing LALR(1) parser tables."""

    homepage = "https://www.gnu.org/software/bison/"
    gnu_mirror_path = "bison/bison-3.6.4.tar.gz"

    executables = ['^bison$']

    version('3.6.4', sha256='8183de64b5383f3634942c7b151bf2577f74273b2731574cdda8a8f3a0ab13e9')
    version('3.6.3', sha256='4b4c4943931e811f1073006ce3d8ee022a02b11b501e9cbf4def3613b24a3e63')
    version('3.6.2', sha256='e28ed3aad934de2d1df68be209ac0b454f7b6d3c3d6d01126e5cd2cbadba089a')
    version('3.6.1', sha256='1120f8bfe2cc13e5e1e3f671dc41b1a535ca5a75a70d5b349c19da9d4389f74d')
    version('3.6', sha256='f630645e330bde5847266cc5c8194f0135ced75cced150358d9abe572b95f81c')
    version('3.5.3', sha256='34e201d963156618a0ea5bc87220f660a1e08403dd3c7c7903d4f38db3f40039')
    version('3.5.2', sha256='b4dbb6dd080f4db7f344f16506502973ca2b15f15c7dbbd1c1c278a456d094fa')
    version('3.5.1', sha256='4cef2322d96751be1c0d04f3e57adbb30e7fea83af9c00f98efa6e7509296f25')
    version('3.5', sha256='0b36200b9868ee289b78cefd1199496b02b76899bbb7e84ff1c0733a991313d1')
    version('3.4.2', sha256='ff3922af377d514eca302a6662d470e857bd1a591e96a2050500df5a9d59facf')
    version('3.4.1', sha256='7007fc89c216fbfaff5525359b02a7e5b612694df5168c74673f67055f015095')
    version('3.3.2', sha256='0fda1d034185397430eb7b0c9e140fb37e02fbfc53b90252fa5575e382b6dbd1')
    version('3.0.5', sha256='cd399d2bee33afa712bac4b1f4434e20379e9b4099bce47189e09a7675a2d566')
    version('3.0.4', sha256='b67fd2daae7a64b5ba862c66c07c1addb9e6b1b05c5f2049392cfd8a2172952e')
    version('2.7',   sha256='19bbe7374fd602f7a6654c131c21a15aebdc06cc89493e8ff250cb7f9ed0a831')

    # https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00008.html
    patch('parallel.patch', when='@3.4.2')

    provides('yacc')

    depends_on('diffutils', type='build')
    depends_on('m4', type=('build', 'run'))
    depends_on('perl', type='build')
    depends_on('help2man', type='build')

    patch('pgi.patch', when='@3.0.4')
    patch('nvhpc.patch', when='%nvhpc')

    conflicts('%intel@:14', when='@3.4.2:',
              msg="Intel 14 has immature C11 support")

    if sys.platform == 'darwin' and macos_version() >= Version('10.13'):
        patch('secure_snprintf.patch', level=0, when='@3.0.4')

    build_directory = 'spack-build'

    @classmethod
    def determine_version(cls, exe):
        output = Executable(exe)('--version', output=str, error=str)
        match = re.search(r'bison \(GNU Bison\)\s+(\S+)', output)
        return match.group(1) if match else None
Пример #5
0
    def setup_build_environment(self, env):
        spec = self.spec

        if (spec.version <= Version('5.34.0') and spec.platform == 'darwin'
                and macos_version() >= Version('10.16')):
            # Older perl versions reject MACOSX_DEPLOYMENT_TARGET=11 or higher
            # as "unexpected"; override the environment variable set by spack's
            # platforms.darwin .
            env.set('MACOSX_DEPLOYMENT_TARGET', '10.16')

        # This is how we tell perl the locations of bzip and zlib.
        env.set('BUILD_BZIP2', 0)
        env.set('BZIP2_INCLUDE', spec['bzip2'].prefix.include)
        env.set('BZIP2_LIB', spec['bzip2'].libs.directories[0])
        env.set('BUILD_ZLIB', 0)
        env.set('ZLIB_INCLUDE', spec['zlib'].prefix.include)
        env.set('ZLIB_LIB', spec['zlib'].libs.directories[0])
Пример #6
0
class Bison(AutotoolsPackage):
    """Bison is a general-purpose parser generator that converts
    an annotated context-free grammar into a deterministic LR or
    generalized LR (GLR) parser employing LALR(1) parser tables."""

    homepage = "http://www.gnu.org/software/bison/"
    url = "http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz"

    version('3.0.4', 'a586e11cd4aff49c3ff6d3b6a4c9ccf8')
    version('2.7', 'ded660799e76fb1667d594de1f7a0da9')

    depends_on('m4', type=('build', 'run'))

    patch('pgi.patch', when='@3.0.4')

    if sys.platform == 'darwin' and macos_version() >= Version('10.13'):
        patch('secure_snprintf.patch', level=0, when='@3.0.4')

    build_directory = 'spack-build'
Пример #7
0
    def setup_build_environment(self, env):
        if is_windows:
            env.append_path('PATH', self.prefix.bin)
            return

        spec = self.spec

        if (spec.satisfies('@:5.34 platform=darwin')
                and macos_version() >= Version('10.16')):
            # Older perl versions reject MACOSX_DEPLOYMENT_TARGET=11 or higher
            # as "unexpected"; override the environment variable set by spack's
            # platforms.darwin .
            env.set('MACOSX_DEPLOYMENT_TARGET', '10.16')

        # This is how we tell perl the locations of bzip and zlib.
        env.set('BUILD_BZIP2', 0)
        env.set('BZIP2_INCLUDE', spec['bzip2'].prefix.include)
        env.set('BZIP2_LIB', spec['bzip2'].libs.directories[0])
        env.set('BUILD_ZLIB', 0)
        env.set('ZLIB_INCLUDE', spec['zlib'].prefix.include)
        env.set('ZLIB_LIB', spec['zlib'].libs.directories[0])
Пример #8
0
class Gcc(AutotoolsPackage, GNUMirrorPackage):
    """The GNU Compiler Collection includes front ends for C, C++, Objective-C,
    Fortran, Ada, and Go, as well as libraries for these languages."""

    homepage = 'https://gcc.gnu.org'
    gnu_mirror_path = 'gcc/gcc-9.2.0/gcc-9.2.0.tar.xz'
    git = 'git://gcc.gnu.org/git/gcc.git'
    list_url = 'http://ftp.gnu.org/gnu/gcc/'
    list_depth = 1

    maintainers = ['michaelkuhn']

    version('master', branch='master')

    if sys.platform == "darwin" and platform.machine() == "arm64":
        # wip branch, not for production probably ...
        version(
            '10.2.0-wip',
            '97c766eeb8b92af3a4b2e63c308c51d66390e9e37b8e39fd8eca71042c656054',
            url=
            'https://www.github.com/iains/gcc-darwin-arm64/tarball/156d060affa955f90345a44f99da68a6102dca32'
        )

    version('10.2.0',
            sha256=
            'b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c')
    version('10.1.0',
            sha256=
            'b6898a23844b656f1b68691c5c012036c2e694ac4b53a8918d4712ad876e7ea2')

    version('9.3.0',
            sha256=
            '71e197867611f6054aa1119b13a0c0abac12834765fe2d81f35ac57f84f742d1')
    version('9.2.0',
            sha256=
            'ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206')
    version('9.1.0',
            sha256=
            '79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0')

    version('8.4.0',
            sha256=
            'e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4')
    version('8.3.0',
            sha256=
            '64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c')
    version('8.2.0',
            sha256=
            '196c3c04ba2613f893283977e6011b2345d1cd1af9abeac58e916b1aab3e0080')
    version('8.1.0',
            sha256=
            '1d1866f992626e61349a1ccd0b8d5253816222cdc13390dcfaa74b093aa2b153')

    version('7.5.0',
            sha256=
            'b81946e7f01f90528a1f7352ab08cc602b9ccc05d4e44da4bd501c5a189ee661')
    version('7.4.0',
            sha256=
            'eddde28d04f334aec1604456e536416549e9b1aa137fc69204e65eb0c009fe51')
    version('7.3.0',
            sha256=
            '832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c')
    version('7.2.0',
            sha256=
            '1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a')
    version('7.1.0',
            sha256=
            '8a8136c235f64c6fef69cac0d73a46a1a09bb250776a050aec8f9fc880bebc17')

    version('6.5.0',
            sha256=
            '7ef1796ce497e89479183702635b14bb7a46b53249209a5e0f999bebf4740945')
    version('6.4.0',
            sha256=
            '850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4')
    version('6.3.0',
            sha256=
            'f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f')
    version('6.2.0',
            sha256=
            '9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5')
    version('6.1.0',
            sha256=
            '09c4c85cabebb971b1de732a0219609f93fc0af5f86f6e437fd8d7f832f1a351')

    version('5.5.0',
            sha256=
            '530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87')
    version('5.4.0',
            sha256=
            '608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a')
    version('5.3.0',
            sha256=
            'b84f5592e9218b73dbae612b5253035a7b34a9a1f7688d2e1bfaaf7267d5c4db')
    version('5.2.0',
            sha256=
            '5f835b04b5f7dd4f4d2dc96190ec1621b8d89f2dc6f638f9f8bc1b1014ba8cad')
    version('5.1.0',
            sha256=
            'b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad')

    version('4.9.4',
            sha256=
            '6c11d292cd01b294f9f84c9a59c230d80e9e4a47e5c6355f046bb36d4f358092')
    version('4.9.3',
            sha256=
            '2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e')
    version('4.9.2',
            sha256=
            '2020c98295856aa13fda0f2f3a4794490757fc24bcca918d52cc8b4917b972dd')
    version('4.9.1',
            sha256=
            'd334781a124ada6f38e63b545e2a3b8c2183049515a1abab6d513f109f1d717e')
    version('4.8.5',
            sha256=
            '22fb1e7e0f68a63cee631d85b20461d1ea6bda162f03096350e38c8d427ecf23')
    version('4.8.4',
            sha256=
            '4a80aa23798b8e9b5793494b8c976b39b8d9aa2e53cd5ed5534aff662a7f8695')
    version('4.7.4',
            sha256=
            '92e61c6dc3a0a449e62d72a38185fda550168a86702dea07125ebd3ec3996282')
    version('4.6.4',
            sha256=
            '35af16afa0b67af9b8eb15cafb76d2bc5f568540552522f5dc2c88dd45d977e8')
    version('4.5.4',
            sha256=
            'eef3f0456db8c3d992cbb51d5d32558190bc14f3bc19383dd93acc27acc6befc')

    # We specifically do not add 'all' variant here because:
    # (i) Ada, Go, Jit, and Objective-C++ are not default languages.
    # In that respect, the name 'all' is rather misleading.
    # (ii) Languages other than c,c++,fortran are prone to configure bug in GCC
    # For example, 'java' appears to ignore custom location of zlib
    # (iii) meaning of 'all' changes with GCC version, i.e. 'java' is not part
    # of gcc7. Correctly specifying conflicts() and depends_on() in such a
    # case is a PITA.
    variant('languages',
            default='c,c++,fortran',
            values=('ada', 'brig', 'c', 'c++', 'fortran', 'go', 'java', 'jit',
                    'lto', 'objc', 'obj-c++'),
            multi=True,
            description='Compilers and runtime libraries to build')
    variant('binutils', default=False, description='Build via binutils')
    variant('piclibs',
            default=False,
            description='Build PIC versions of libgfortran.a and libstdc++.a')
    variant('strip',
            default=False,
            description='Strip executables to reduce installation size')
    variant('nvptx',
            default=False,
            description='Target nvptx offloading to NVIDIA GPUs')
    variant('bootstrap',
            default=False,
            description='add --enable-bootstrap flag for stage3 build')
    variant('graphite',
            default=False,
            description='Enable Graphite loop optimizations (requires ISL)')

    depends_on('flex', type='build', when='@master')

    # https://gcc.gnu.org/install/prerequisites.html
    depends_on('[email protected]:')
    # GCC 7.3 does not compile with newer releases on some platforms, see
    #   https://github.com/spack/spack/issues/6902#issuecomment-433030376
    depends_on('[email protected]:3.1.6', when='@:9.9')
    depends_on('[email protected]:', when='@10:')
    depends_on('[email protected]:', when='@4.5:')
    # Already released GCC versions do not support any newer version of ISL
    #   GCC 5.4 https://github.com/spack/spack/issues/6902#issuecomment-433072097
    #   GCC 7.3 https://github.com/spack/spack/issues/6902#issuecomment-433030376
    #   GCC 9+  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724
    depends_on('[email protected]', when='@5.0:5.2 +graphite')
    depends_on('[email protected]', when='@5.3:5.9 +graphite')
    depends_on('[email protected]:0.18', when='@6:8.9 +graphite')
    depends_on('[email protected]:0.20', when='@9:9.9 +graphite')
    depends_on('[email protected]:', when='@10: +graphite')
    depends_on('zlib', when='@6:')
    depends_on('zstd', when='@10:')
    depends_on('diffutils', type='build')
    depends_on('iconv', when='platform=darwin')
    depends_on('gnat', when='languages=ada')
    depends_on('binutils~libiberty',
               when='+binutils',
               type=('build', 'link', 'run'))
    depends_on('zip', type='build', when='languages=java')
    depends_on('cuda@:10', when='+nvptx')
    # The server is sometimes a bit slow to respond
    timeout = {'timeout': 60}

    resource(
        name='newlib',
        url='ftp://sourceware.org/pub/newlib/newlib-3.0.0.20180831.tar.gz',
        sha256=
        '3ad3664f227357df15ff34e954bfd9f501009a647667cd307bf0658aefd6eb5b',
        destination='newlibsource',
        when='+nvptx',
        fetch_options=timeout)

    # nvptx-tools does not seem to work as a dependency,
    # but does fine when the source is inside the gcc build directory
    # nvptx-tools doesn't have any releases, so grabbing the last commit
    resource(name='nvptx-tools',
             git='https://github.com/MentorEmbedded/nvptx-tools',
             commit='5f6f343a302d620b0868edab376c00b15741e39e',
             when='+nvptx')

    # TODO: integrate these libraries.
    # depends_on('ppl')
    # depends_on('cloog')

    # https://gcc.gnu.org/install/test.html
    depends_on('[email protected]', type='test')
    depends_on('expect', type='test')
    depends_on('tcl', type='test')
    depends_on('[email protected]:', type='test')
    depends_on('[email protected]:', type='test')

    # See https://golang.org/doc/install/gccgo#Releases
    provides('golang', when='languages=go @4.6:')
    provides('golang@:1', when='languages=go @4.7.1:')
    provides('golang@:1.1', when='languages=go @4.8:')
    provides('golang@:1.1.2', when='languages=go @4.8.2:')
    provides('golang@:1.2', when='languages=go @4.9:')
    provides('golang@:1.4', when='languages=go @5:')
    provides('golang@:1.6.1', when='languages=go @6:')
    provides('golang@:1.8', when='languages=go @7:')

    # For a list of valid languages for a specific release,
    # run the following command in the GCC source directory:
    #    $ grep ^language= gcc/*/config-lang.in
    # See https://gcc.gnu.org/install/configure.html

    # Support for processing BRIG 1.0 files was added in GCC 7
    # BRIG is a binary format for HSAIL:
    # (Heterogeneous System Architecture Intermediate Language).
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=brig', when='@:6')

    # BRIG does not seem to be supported on macOS
    conflicts('languages=brig', when='platform=darwin')

    # GCC 4.8 added a 'c' language. I'm sure C was always built,
    # but this is the first version that accepts 'c' as a valid language.
    conflicts('languages=c', when='@:4.7')

    # GCC 4.6 added support for the Go programming language.
    # See https://gcc.gnu.org/gcc-4.6/changes.html
    conflicts('languages=go', when='@:4.5')

    # Go is not supported on macOS
    conflicts('languages=go', when='platform=darwin')

    # The GCC Java frontend and associated libjava runtime library
    # have been removed from GCC as of GCC 7.
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=java', when='@7:')

    # GCC 5 added the ability to build GCC as a Just-In-Time compiler.
    # See https://gcc.gnu.org/gcc-5/changes.html
    conflicts('languages=jit', when='@:4')

    # NVPTX offloading supported in 7 and later by limited languages
    conflicts('+nvptx',
              when='@:6',
              msg='NVPTX only supported in gcc 7 and above')
    conflicts('languages=ada', when='+nvptx')
    conflicts('languages=brig', when='+nvptx')
    conflicts('languages=go', when='+nvptx')
    conflicts('languages=java', when='+nvptx')
    conflicts('languages=jit', when='+nvptx')
    conflicts('languages=objc', when='+nvptx')
    conflicts('languages=obj-c++', when='+nvptx')
    # NVPTX build disables bootstrap
    conflicts('+binutils', when='+nvptx')

    # Binutils can't build ld on macOS
    conflicts('+binutils', when='platform=darwin')

    # Newer binutils than RHEL's is required to run `as` on some instructions
    # generated by new GCC (see https://github.com/spack/spack/issues/12235)
    conflicts('~binutils',
              when='@7: os=rhel6',
              msg='New GCC cannot use system assembler on RHEL6')

    if sys.platform == 'darwin':
        # Fix parallel build on APFS filesystem
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797
        if macos_version() >= Version('10.13'):
            patch('darwin/apfs.patch', when='@5.5.0,6.1:6.4,7.1:7.3')
            # from homebrew via macports
            # https://trac.macports.org/ticket/56502#no1
            # see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83531
            patch('darwin/headers-10.13-fix.patch', when='@5.5.0')
        if macos_version() >= Version('10.14'):
            # Fix system headers for Mojave SDK:
            # https://github.com/Homebrew/homebrew-core/pull/39041
            patch(
                'https://raw.githubusercontent.com/Homebrew/formula-patches/master/gcc/8.3.0-xcode-bug-_Atomic-fix.patch',
                sha256=
                '33ee92bf678586357ee8ab9d2faddf807e671ad37b97afdd102d5d153d03ca84',
                when='@6:8')
        if macos_version() >= Version('10.15'):
            # Fix system headers for Catalina SDK
            # (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
            patch(
                'https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/9.2.0-catalina.patch',
                sha256=
                '0b8d14a7f3c6a2f0d2498526e86e088926671b5da50a554ffa6b7f73ac4f132b',
                when='@9.2.0')
        # Use -headerpad_max_install_names in the build,
        # otherwise updated load commands won't fit in the Mach-O header.
        # This is needed because `gcc` avoids the superenv shim.
        if platform.machine() != "arm64":
            patch('darwin/gcc-7.1.0-headerpad.patch', when='@5:')
        patch('darwin/gcc-6.1.0-jit.patch', when='@5:7')
        patch('darwin/gcc-4.9.patch1', when='@4.9.0:4.9.3')
        patch('darwin/gcc-4.9.patch2', when='@4.9.0:4.9.3')

    patch('piclibs.patch', when='+piclibs')
    patch('gcc-backport.patch', when='@4.7:4.9.2,5:5.3')

    # Backport libsanitizer patch for glibc >= 2.31 and 5.3.0 <= gcc <= 9.2.0
    # https://bugs.gentoo.org/708346
    patch('glibc-2.31-libsanitizer-1.patch',
          when='@7.1.0:7.5.0,8.1.0:8.3.0,9.0.0:9.2.0')
    patch('glibc-2.31-libsanitizer-1-gcc-6.patch',
          when='@5.3.0:5.5.0,6.1.0:6.5.0')
    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:8.3.0,9.0.0:9.2.0')
    patch('glibc-2.31-libsanitizer-2-gcc-6.patch',
          when='@5.3.0:5.5.0,6.1.0:6.5.0')
    patch('glibc-2.31-libsanitizer-2-gcc-7.patch', when='@7.1.0:7.5.0')
    # Older versions do not compile with newer versions of glibc
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
    patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
    patch('ucontext_t-java.patch', when='@4.9,5.1:5.4,6.1:6.4 languages=java')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066
    patch('stack_t-4.9.patch', when='@4.9')
    patch('stack_t.patch', when='@5.1:5.4,6.1:6.4,7.1')
    # https://bugs.busybox.net/show_bug.cgi?id=10061
    patch('signal.patch', when='@4.9,5.1:5.4')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85835
    patch('sys_ustat.h.patch', when='@5.0:6.4,7.0:7.3,8.1')
    patch('sys_ustat-4.9.patch', when='@4.9')

    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95005
    #if sys.platform == 'darwin' and platform.machine() != 'arm64':
    patch('zstd.patch', when='@10:')

    build_directory = 'spack-build'

    @property
    def executables(self):
        names = [r'gcc', r'[^\w]?g\+\+', r'gfortran']
        suffixes = [r'', r'-mp-\d+\.\d', r'-\d+\.\d', r'-\d+', r'\d\d']
        return [r''.join(x) for x in itertools.product(names, suffixes)]

    @classmethod
    def filter_detected_exes(cls, prefix, exes_in_prefix):
        result = []
        for exe in exes_in_prefix:
            # On systems like Ubuntu we might get multiple executables
            # with the string "gcc" in them. See:
            # https://helpmanual.io/packages/apt/gcc/
            basename = os.path.basename(exe)
            substring_to_be_filtered = [
                'c99-gcc',
                'c89-gcc',
                '-nm',
                '-ar',
                'ranlib',
                'clang'  # clang++ matches g++ -> clan[g++]
            ]
            if any(x in basename for x in substring_to_be_filtered):
                continue
            # Filter out links in favor of real executables on
            # all systems but Cray
            host_platform = str(spack.architecture.platform())
            if os.path.islink(exe) and host_platform != 'cray':
                continue

            result.append(exe)

        return result

    @classmethod
    def determine_version(cls, exe):
        try:
            output = spack.compiler.get_compiler_version_output(
                exe, '--version')
        except Exception:
            output = ''
        # Apple's gcc is actually apple clang, so skip it.
        # Users can add it manually to compilers.yaml at their own risk.
        if 'Apple' in output:
            return None

        version_regex = re.compile(r'([\d\.]+)')
        for vargs in ('-dumpfullversion', '-dumpversion'):
            try:
                output = spack.compiler.get_compiler_version_output(exe, vargs)
                match = version_regex.search(output)
                if match:
                    return match.group(1)
            except spack.util.executable.ProcessError:
                pass
            except Exception as e:
                tty.debug(e)

        return None

    @classmethod
    def determine_variants(cls, exes, version_str):
        languages, compilers = set(), {}
        for exe in exes:
            basename = os.path.basename(exe)
            if 'g++' in basename:
                languages.add('c++')
                compilers['cxx'] = exe
            elif 'gfortran' in basename:
                languages.add('fortran')
                compilers['fortran'] = exe
            elif 'gcc' in basename:
                languages.add('c')
                compilers['c'] = exe
        variant_str = 'languages={0}'.format(','.join(languages))
        return variant_str, {'compilers': compilers}

    @classmethod
    def validate_detected_spec(cls, spec, extra_attributes):
        # For GCC 'compilers' is a mandatory attribute
        msg = ('the extra attribute "compilers" must be set for '
               'the detected spec "{0}"'.format(spec))
        assert 'compilers' in extra_attributes, msg

        compilers = extra_attributes['compilers']
        for constraint, key in {
                'languages=c': 'c',
                'languages=c++': 'cxx',
                'languages=fortran': 'fortran'
        }.items():
            if spec.satisfies(constraint, strict=True):
                msg = '{0} not in {1}'
                assert key in compilers, msg.format(key, spec)

    @property
    def cc(self):
        msg = "cannot retrieve C compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('c', None)
        result = None
        if 'languages=c' in self.spec:
            result = str(self.spec.prefix.bin.gcc)
        return result

    @property
    def cxx(self):
        msg = "cannot retrieve C++ compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('cxx', None)
        result = None
        if 'languages=c++' in self.spec:
            result = os.path.join(self.spec.prefix.bin, 'g++')
        return result

    @property
    def fortran(self):
        msg = "cannot retrieve Fortran compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('fortran', None)
        result = None
        if 'languages=fortran' in self.spec:
            result = str(self.spec.prefix.bin.gfortran)
        return result

    def url_for_version(self, version):
        # This function will be called when trying to fetch from url, before
        # mirrors are tried. It takes care of modifying the suffix of gnu
        # mirror path so that Spack will also look for the correct file in
        # the mirrors
        if (version < Version('6.4.0') and version != Version('5.5.0')) \
                or version == Version('7.1.0'):
            self.gnu_mirror_path = self.gnu_mirror_path.replace('xz', 'bz2')
        return super(Gcc, self).url_for_version(version)

    def patch(self):
        spec = self.spec
        prefix = self.spec.prefix

        # Fix a standard header file for OS X Yosemite that
        # is GCC incompatible by replacing non-GCC compliant macros
        if 'yosemite' in spec.architecture:
            if os.path.isfile('/usr/include/dispatch/object.h'):
                new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
                mkdirp(new_dispatch_dir)
                new_header = join_path(new_dispatch_dir, 'object.h')
                install('/usr/include/dispatch/object.h', new_header)
                filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
                            'typedef void* dispatch_block_t', new_header)

        # Use installed libz
        if self.version >= Version('6'):
            filter_file('@zlibdir@', '-L{0}'.format(spec['zlib'].prefix.lib),
                        'gcc/Makefile.in')
            filter_file('@zlibinc@',
                        '-I{0}'.format(spec['zlib'].prefix.include),
                        'gcc/Makefile.in')

    # https://gcc.gnu.org/install/configure.html
    def configure_args(self):
        spec = self.spec

        # Generic options to compile GCC
        options = [
            # Distributor options
            '--with-pkgversion=Spack GCC',
            '--with-bugurl=https://github.com/spack/spack/issues',
            # Xcode 10 dropped 32-bit support
            '--disable-multilib',
            '--enable-languages={0}'.format(','.join(
                spec.variants['languages'].value)),
            # Drop gettext dependency
            '--disable-nls'
        ]

        # Use installed libz
        if self.version >= Version('6'):
            options.append('--with-system-zlib')

        if 'zstd' in spec:
            options.append('--with-zstd={0}'.format(spec['zstd'].prefix))

        # Enabling language "jit" requires --enable-host-shared.
        if 'languages=jit' in spec:
            options.append('--enable-host-shared')

        # Binutils
        if spec.satisfies('+binutils'):
            binutils = spec['binutils'].prefix.bin
            options.extend([
                '--with-gnu-ld',
                '--with-ld=' + binutils.ld,
                '--with-gnu-as',
                '--with-as=' + binutils.join('as'),
            ])

        # enable_bootstrap
        if spec.satisfies('+bootstrap'):
            options.extend([
                '--enable-bootstrap',
            ])

        # Configure include and lib directories explicitly for these
        # dependencies since the short GCC option assumes that libraries
        # are installed in "/lib" which might not be true on all OS
        # (see #10842)
        #
        # More info at: https://gcc.gnu.org/install/configure.html
        for dep_str in ('mpfr', 'gmp', 'mpc', 'isl'):
            if dep_str not in spec:
                options.append('--without-{0}'.format(dep_str))
                continue

            dep_spec = spec[dep_str]
            include_dir = dep_spec.headers.directories[0]
            lib_dir = dep_spec.libs.directories[0]
            options.extend([
                '--with-{0}-include={1}'.format(dep_str, include_dir),
                '--with-{0}-lib={1}'.format(dep_str, lib_dir)
            ])

        # nvptx-none offloading for host compiler
        if spec.satisfies('+nvptx'):
            options.extend([
                '--enable-offload-targets=nvptx-none',
                '--with-cuda-driver-include={0}'.format(
                    spec['cuda'].prefix.include),
                '--with-cuda-driver-lib={0}'.format(
                    spec['cuda'].libs.directories[0]), '--disable-bootstrap',
                '--disable-multilib'
            ])

        if sys.platform == 'darwin':
            options.extend([
                '--with-native-system-header-dir=/usr/include',
                '--with-sysroot={0}'.format(macos_sdk_path()),
                '--with-libiconv-prefix={0}'.format(spec['iconv'].prefix)
            ])

        # enable appropriate bootstrapping flags
        stage1_ldflags = str(self.rpath_args)
        boot_ldflags = stage1_ldflags + ' -static-libstdc++ -static-libgcc'
        options.append('--with-stage1-ldflags=' + stage1_ldflags)
        options.append('--with-boot-ldflags=' + boot_ldflags)

        return options

    # run configure/make/make(install) for the nvptx-none target
    # before running the host compiler phases
    @run_before('configure')
    def nvptx_install(self):
        spec = self.spec
        prefix = self.prefix

        if not spec.satisfies('+nvptx'):
            return

        # config.guess returns the host triple, e.g. "x86_64-pc-linux-gnu"
        guess = Executable('./config.guess')
        targetguess = guess(output=str).rstrip('\n')

        options = getattr(self, 'configure_flag_args', [])
        options += ['--prefix={0}'.format(prefix)]

        options += [
            '--with-cuda-driver-include={0}'.format(
                spec['cuda'].prefix.include),
            '--with-cuda-driver-lib={0}'.format(
                spec['cuda'].libs.directories[0]),
        ]

        with working_dir('nvptx-tools'):
            configure = Executable("./configure")
            configure(*options)
            make()
            make('install')

        pattern = join_path(self.stage.source_path, 'newlibsource', '*')
        files = glob.glob(pattern)

        if files:
            symlink(join_path(files[0], 'newlib'), 'newlib')

        # self.build_directory = 'spack-build-nvptx'
        with working_dir('spack-build-nvptx', create=True):

            options = [
                '--prefix={0}'.format(prefix),
                '--enable-languages={0}'.format(','.join(
                    spec.variants['languages'].value)),
                '--with-mpfr={0}'.format(spec['mpfr'].prefix),
                '--with-gmp={0}'.format(spec['gmp'].prefix),
                '--target=nvptx-none',
                '--with-build-time-tools={0}'.format(
                    join_path(prefix, 'nvptx-none', 'bin')),
                '--enable-as-accelerator-for={0}'.format(targetguess),
                '--disable-sjlj-exceptions',
                '--enable-newlib-io-long-long',
            ]

            configure = Executable("../configure")
            configure(*options)
            make()
            make('install')

    @property
    def install_targets(self):
        if '+strip' in self.spec:
            return ['install-strip']
        return ['install']

    @property
    def spec_dir(self):
        # e.g. lib/gcc/x86_64-unknown-linux-gnu/4.9.2
        spec_dir = glob.glob('{0}/gcc/*/*'.format(self.prefix.lib))
        return spec_dir[0] if spec_dir else None

    @run_after('install')
    def write_rpath_specs(self):
        """Generate a spec file so the linker adds a rpath to the libs
           the compiler used to build the executable."""
        if not self.spec_dir:
            tty.warn('Could not install specs for {0}.'.format(
                self.spec.format('{name}{@version}')))
            return

        gcc = self.spec['gcc'].command
        lines = gcc('-dumpspecs', output=str).strip().split('\n')
        specs_file = join_path(self.spec_dir, 'specs')
        with open(specs_file, 'w') as out:
            for line in lines:
                out.write(line + '\n')
                if line.startswith('*link:'):
                    out.write('-rpath {0}:{1} '.format(self.prefix.lib,
                                                       self.prefix.lib64))
        set_install_permissions(specs_file)

    def setup_run_environment(self, env):
        # Search prefix directory for possibly modified compiler names
        from spack.compilers.gcc import Gcc as Compiler

        # Get the contents of the installed binary directory
        bin_path = self.spec.prefix.bin

        if not os.path.isdir(bin_path):
            return

        bin_contents = os.listdir(bin_path)

        # Find the first non-symlink compiler binary present for each language
        for lang in ['cc', 'cxx', 'fc', 'f77']:
            for filename, regexp in itertools.product(
                    bin_contents, Compiler.search_regexps(lang)):
                if not regexp.match(filename):
                    continue

                abspath = os.path.join(bin_path, filename)
                if os.path.islink(abspath):
                    continue

                # Set the proper environment variable
                env.set(lang.upper(), abspath)
                # Stop searching filename/regex combos for this language
                break
Пример #9
0
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import itertools
import os
import sys

import llnl.util.tty as tty

from spack import *
from spack.operating_systems.mac_os import macos_version

MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None


class Qt(Package):
    """Qt is a comprehensive cross-platform C++ application framework."""
    homepage = 'https://qt.io'

    # Supported releases: 'https://download.qt.io/official_releases/qt/'
    # Older archives: 'https://download.qt.io/new_archive/qt/'
    url = 'https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz'
    list_url = 'https://download.qt.io/archive/qt/'
    list_depth = 3
    maintainers = ['sethrj']

    phases = ['configure', 'build', 'install']

    version('5.15.2',
            sha256=
Пример #10
0
    def cmake_args(self):
        spec = self.spec
        define = CMakePackage.define
        define_from_variant = self.define_from_variant

        def define_trilinos_enable(cmake_var, spec_var=None):
            if spec_var is None:
                spec_var = cmake_var.lower()
            return define_from_variant('Trilinos_ENABLE_' + cmake_var, spec_var)

        def define_tpl_enable(cmake_var, spec_var=None):
            if spec_var is None:
                spec_var = cmake_var.lower()
            return define_from_variant('TPL_ENABLE_' + cmake_var, spec_var)

        cxx_flags = []
        options = []

        # #################### Base Settings #######################

        options.extend([
            define('Trilinos_VERBOSE_CONFIGURE', False),
            define('Trilinos_ENABLE_TESTS', False),
            define('Trilinos_ENABLE_EXAMPLES', False),
            define('Trilinos_ENABLE_CXX11', True),
            define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
            define_from_variant('BUILD_SHARED_LIBS', 'shared'),
            define_trilinos_enable('DEBUG', 'debug'),
            # The following can cause problems on systems that don't have
            # static libraries available for things like dl and pthreads
            # for example when trying to build static libs
            # define_from_variant('TPL_FIND_SHARED_LIBS', 'shared')
            # define('Trilinos_LINK_SEARCH_START_STATIC', '+shared' not in spec)
        ])

        # MPI settings
        options.append(define_tpl_enable('MPI'))
        if '+mpi' in spec:
            # Force Trilinos to use the MPI wrappers instead of raw compilers
            # this is needed on Apple systems that require full resolution of
            # all symbols when linking shared libraries
            options.extend([
                define('CMAKE_C_COMPILER', spec['mpi'].mpicc),
                define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx),
                define('CMAKE_Fortran_COMPILER', spec['mpi'].mpifc),
                define('MPI_BASE_DIR', spec['mpi'].prefix),
            ])

        # ################## Trilinos Packages #####################

        options.extend([
            define_trilinos_enable('Amesos'),
            define_trilinos_enable('Amesos2'),
            define_trilinos_enable('Anasazi'),
            define_trilinos_enable('AztecOO', 'aztec'),
            define_trilinos_enable('Belos'),
            define_trilinos_enable('Epetra'),
            define_trilinos_enable('EpetraExt'),
            define_trilinos_enable('Ifpack'),
            define_trilinos_enable('Ifpack2'),
            define_trilinos_enable('Intrepid'),
            define_trilinos_enable('Intrepid2'),
            define_trilinos_enable('Isorropia'),
            define_trilinos_enable('Kokkos'),
            define_trilinos_enable('MiniTensor'),
            define_trilinos_enable('Mesquite'),
            define_trilinos_enable('ML'),
            define_trilinos_enable('MueLu'),
            define_trilinos_enable('NOX'),
            define_trilinos_enable('Piro'),
            define_trilinos_enable('Phalanx'),
            define_trilinos_enable('PyTrilinos', 'python'),
            define_trilinos_enable('ROL'),
            define_trilinos_enable('Rythmos'),
            define_trilinos_enable('Sacado'),
            define_trilinos_enable('SCOREC'),
            define_trilinos_enable('Shards'),
            define_trilinos_enable('ShyLU'),
            define_trilinos_enable('STK'),
            define_trilinos_enable('Stokhos'),
            define_trilinos_enable('Stratimikos'),
            define_trilinos_enable('Teko'),
            define_trilinos_enable('Tempus'),
            define_trilinos_enable('Tpetra'),
            define_trilinos_enable('TrilinosCouplings'),
            define_trilinos_enable('Zoltan'),
            define_trilinos_enable('Zoltan2'),
            define_from_variant('EpetraExt_BUILD_BTF', 'epetraextbtf'),
            define_from_variant('EpetraExt_BUILD_EXPERIMENTAL',
                                'epetraextexperimental'),
            define_from_variant('EpetraExt_BUILD_GRAPH_REORDERINGS',
                                'epetraextgraphreorderings'),
            define_from_variant('Amesos2_ENABLE_Basker', 'basker'),
        ])

        if '+dtk' in spec:
            options.extend([
                define('Trilinos_EXTRA_REPOSITORIES', 'DataTransferKit'),
                define('Trilinos_ENABLE_DataTransferKit', True),
            ])

        if '+exodus' in spec:
            options.extend([
                define('Trilinos_ENABLE_SEACAS', True),
                define('Trilinos_ENABLE_SEACASExodus', True),
                define('Trilinos_ENABLE_SEACASIoss', True),
                define('Trilinos_ENABLE_SEACASEpu', True),
                define('Trilinos_ENABLE_SEACASExodiff', True),
                define('Trilinos_ENABLE_SEACASNemspread', True),
                define('Trilinos_ENABLE_SEACASNemslice', True),
            ])
        else:
            options.extend([
                define('Trilinos_ENABLE_SEACASExodus', False),
                define('Trilinos_ENABLE_SEACASIoss', False),
            ])

        if '+chaco' in spec:
            options.extend([
                define('Trilinos_ENABLE_SEACAS', True),
                define('Trilinos_ENABLE_SEACASChaco', True),
            ])
        else:
            # don't disable SEACAS, could be needed elsewhere
            options.extend([
                define('Trilinos_ENABLE_SEACASChaco', False),
                define('Trilinos_ENABLE_SEACASNemslice', False)
            ])

        if '+stratimikos' in spec:
            # Explicitly enable Thyra (ThyraCore is required). If you don't do
            # this, then you get "NOT setting ${pkg}_ENABLE_Thyra=ON since
            # Thyra is NOT enabled at this point!" leading to eventual build
            # errors if using MueLu because `Xpetra_ENABLE_Thyra` is set to
            # off.
            options.append(define('Trilinos_ENABLE_Thyra', True))

            # Add thyra adapters based on package enables
            options.extend(
                define_trilinos_enable('Thyra' + pkg + 'Adapters', pkg.lower())
                for pkg in ['Epetra', 'EpetraExt', 'Tpetra'])

        # ######################### TPLs #############################

        # Enable TPLs based on whether they're in our spec, not whether they're
        # variant names: packages/features should disable availability
        tpl_dep_map = [
            ('ADIOS2', 'adios2'),
            ('BLAS', 'blas'),
            ('Boost', 'boost'),
            ('CGNS', 'cgns'),
            ('HDF5', 'hdf5'),
            ('HYPRE', 'hypre'),
            ('LAPACK', 'lapack'),
            ('Matio', 'matio'),
            ('METIS', 'metis'),
            ('Netcdf', 'netcdf-c'),
            ('STRUMPACK', 'strumpack'),
            ('SuperLU', 'superlu'),
            ('X11', 'libx11'),
            ('Zlib', 'zlib'),
        ]
        if spec.satisfies('@13:'):
            tpl_dep_map.append(('HWLOC', 'hwloc'))
        for tpl_name, dep_name in tpl_dep_map:
            have_dep = (dep_name in spec)
            options.append(define('TPL_ENABLE_' + tpl_name, have_dep))
            if not have_dep:
                continue
            depspec = spec[dep_name]
            options.extend([
                define('TPL_' + tpl_name + '_INCLUDE_DIRS', depspec.prefix.include),
                define(tpl_name + '_ROOT', depspec.prefix),
                define(tpl_name + '_LIBRARY_NAMES', depspec.libs.names),
                define(tpl_name + '_LIBRARY_DIRS', depspec.libs.directories),
            ])

        if '+suite-sparse' in spec:
            options.extend([
                # FIXME: Trilinos seems to be looking for static libs only,
                # patch CMake TPL file?
                define('TPL_ENABLE_Cholmod', False),
                # define('TPL_ENABLE_Cholmod', True),
                # define('Cholmod_LIBRARY_DIRS', (
                #    spec['suite-sparse'].prefix.lib)
                # define('Cholmod_INCLUDE_DIRS', (
                #    spec['suite-sparse'].prefix.include)
                define('TPL_ENABLE_UMFPACK', True),
                define('UMFPACK_LIBRARY_DIRS',
                       spec['suite-sparse'].prefix.lib),
                define('UMFPACK_INCLUDE_DIRS',
                       spec['suite-sparse'].prefix.include),
                define('UMFPACK_LIBRARY_NAMES', [
                    'umfpack', 'amd', 'colamd', 'cholmod', 'suitesparseconfig'
                ]),
            ])
        else:
            options.extend([
                define('TPL_ENABLE_Cholmod', False),
                define('TPL_ENABLE_UMFPACK', False),
            ])

        # METIS and ParMETIS mostly depend on transitive dependencies
        # STRUMPACK and SuperLU-dist, so don't provide a separate variant for
        # them.
        have_metis = 'metis' in spec
        options.append(define('TPL_ENABLE_METIS', have_metis))
        if have_metis:
            options.extend([
                define('METIS_LIBRARY_DIRS', spec['metis'].prefix.lib),
                define('METIS_LIBRARY_NAMES', 'metis'),
                define('TPL_METIS_INCLUDE_DIRS', spec['metis'].prefix.include),
            ])

        have_parmetis = 'parmetis' in spec
        options.append(define('TPL_ENABLE_ParMETIS', have_parmetis))
        if have_parmetis:
            options.extend([
                define('ParMETIS_LIBRARY_DIRS', [
                    spec['parmetis'].prefix.lib, spec['metis'].prefix.lib
                ]),
                define('ParMETIS_LIBRARY_NAMES', ['parmetis', 'metis']),
                define('TPL_ParMETIS_INCLUDE_DIRS', [
                    spec['parmetis'].prefix.include,
                    spec['metis'].prefix.include
                ]),
            ])

        options.append(define_tpl_enable('MUMPS'))
        options.append(define_tpl_enable('SCALAPACK', 'mumps'))
        if '+mumps' in spec:
            scalapack = spec['scalapack'].libs
            options.extend([
                define('MUMPS_LIBRARY_DIRS', spec['mumps'].prefix.lib),
                # order is important!
                define('MUMPS_LIBRARY_NAMES', [
                    'dmumps', 'mumps_common', 'pord'
                ]),
                define('SCALAPACK_LIBRARY_NAMES', scalapack.names),
                define('SCALAPACK_LIBRARY_DIRS', scalapack.directories),
            ])
            # see
            # https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
            cxx_flags.extend([
                '-DMUMPS_5_0'
            ])

        options.append(define_tpl_enable('SuperLUDist', 'superlu-dist'))
        if '+superlu-dist' in spec:
            options.extend([
                define('KokkosTSQR_ENABLE_Complex', False),
                define('TPL_ENABLE_SuperLUDist', True),
                define('SuperLUDist_LIBRARY_DIRS',
                       spec['superlu-dist'].prefix.lib),
                define('SuperLUDist_INCLUDE_DIRS',
                       spec['superlu-dist'].prefix.include),
            ])
            if spec.satisfies('^[email protected]:'):
                options.extend([
                    define('HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG', True),
                ])

        if '+strumpack' in spec:
            options.append(define('Amesos2_ENABLE_STRUMPACK', True))

        options.append(define_tpl_enable('Pnetcdf'))
        if '+pnetcdf' in spec:
            options.extend([
                define('TPL_Netcdf_Enables_Netcdf4', True),
                define('TPL_Netcdf_PARALLEL', True),
                define('PNetCDF_ROOT', spec['parallel-netcdf'].prefix),
            ])

        if '@13: +kokkos' in spec:
            kkmarch = Kokkos.spack_micro_arch_map.get(spec.target.name, None)
            if kkmarch:
                options.append(define("Kokkos_ARCH_" + kkmarch.upper(), True))

        # ################# Miscellaneous Stuff ######################
        # CUDA
        options.append(define_tpl_enable('CUDA'))
        if '+cuda' in spec:
            options.extend([
                define('Kokkos_ENABLE_CUDA', True),
                define('Kokkos_ENABLE_CUDA_UVM', True),
                define('Kokkos_ENABLE_CUDA_LAMBDA', True)])
            if '+cuda_rdc' in spec:
                options.append(define(
                    'Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE',
                    True))
            for iArchCC in spec.variants['cuda_arch'].value:
                options.append(define(
                    "Kokkos_ARCH_" +
                    Kokkos.spack_cuda_arch_map[iArchCC].upper(),
                    True))
            if '+wrapper' in spec:
                cxx_flags.extend(['--expt-extended-lambda'])

        # OpenMP
        options.append(define_trilinos_enable('OpenMP'))
        if '+openmp' in spec:
            options.append(define('Kokkos_ENABLE_OpenMP', True))
            if '+tpetra' in spec:
                options.append(define('Tpetra_INST_OPENMP', True))

        # Fortran lib (assumes clang is built with gfortran!)
        if '+fortran' in spec and (
                spec.satisfies('%gcc') or spec.satisfies('%clang') or
                spec.satisfies('%apple-clang')
        ):
            options.append(define('Trilinos_ENABLE_Fortran', True))
            if '+mpi' in spec:
                libgfortran = os.path.dirname(os.popen(
                    '%s --print-file-name libgfortran.a' %
                    spec['mpi'].mpifc).read())
                options.append(define(
                    'Trilinos_EXTRA_LINK_FLAGS',
                    '-L%s/ -lgfortran' % (libgfortran),
                ))

        # Explicit Template Instantiation (ETI) in Tpetra
        # NOTE: Trilinos will soon move to fixed std::uint64_t for GO and
        # std::int32_t or std::int64_t for local.
        options.append(define_from_variant(
            'Trilinos_ENABLE_EXPLICIT_INSTANTIATION',
            'explicit_template_instantiation'))

        complex_s = spec.variants['complex'].value
        float_s = spec.variants['float'].value
        options.extend([
            define('Teuchos_ENABLE_COMPLEX', complex_s),
            define('Teuchos_ENABLE_FLOAT', float_s),
        ])

        if '+explicit_template_instantiation' in spec and '+tpetra' in spec:
            options.extend([
                define('Tpetra_INST_DOUBLE', True),
                define('Tpetra_INST_COMPLEX_DOUBLE', complex_s),
                define('Tpetra_INST_COMPLEX_FLOAT', float_s and complex_s),
                define('Tpetra_INST_FLOAT', float_s),
                define('Tpetra_INST_SERIAL', True),
            ])

            gotype = spec.variants['gotype'].value
            if gotype == 'all':
                # default in older Trilinos versions to enable multiple GOs
                options.extend([
                    define('Tpetra_INST_INT_INT', True),
                    define('Tpetra_INST_INT_LONG', True),
                    define('Tpetra_INST_INT_LONG_LONG', True),
                ])
            else:
                options.extend([
                    define('Tpetra_INST_INT_INT', gotype == 'int'),
                    define('Tpetra_INST_INT_LONG', gotype == 'long'),
                    define('Tpetra_INST_INT_LONG_LONG', gotype == 'long_long'),
                ])

        # disable due to compiler / config errors:
        if spec.satisfies('%xl') or spec.satisfies('%xl_r'):
            options.extend([
                define('Trilinos_ENABLE_Pamgen', False),
                define('Trilinos_ENABLE_Stokhos', False),
            ])

        if sys.platform == 'darwin':
            options.append(define('Trilinos_ENABLE_FEI', False))
            if '+stk' in spec:
                cxx_flags.extend(['-DSTK_NO_BOOST_STACKTRACE'])

        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append(define('CMAKE_MACOSX_RPATH', True))
        else:
            options.append(define('CMAKE_INSTALL_NAME_DIR', self.prefix.lib))

        if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
            # Panzer uses some std:chrono that is not recognized by Intel
            # Don't know which (maybe all) Trilinos versions this applies to
            # Don't know which (maybe all) Intel versions this applies to
            options.append(define('Trilinos_ENABLE_Panzer', False))

        # collect CXX flags:
        options.append(define('CMAKE_CXX_FLAGS', (' '.join(cxx_flags))))

        # disable due to compiler / config errors:
        options.append(define('Trilinos_ENABLE_Pike', False))

        return options
Пример #11
0
    def cmake_args(self):
        spec = self.spec
        from_variant = self.define_from_variant

        options = []

        # #################### Base Settings #######################

        if '+mpi' in spec:
            options.extend([
                '-DCMAKE_C_COMPILER=%s'       % spec['mpi'].mpicc,
                '-DCMAKE_CXX_COMPILER=%s'     % spec['mpi'].mpicxx,
                '-DCMAKE_Fortran_COMPILER=%s' % spec['mpi'].mpifc,
                '-DTPL_ENABLE_MPI:BOOL=ON',
                '-DMPI_BASE_DIR:PATH=%s'      % spec['mpi'].prefix,
            ])

        options.extend([
            '-DSEACASProj_ENABLE_TESTS:BOOL=ON',
            '-DSEACASProj_ENABLE_CXX11:BOOL=ON',
            from_variant('CMAKE_INSTALL_RPATH_USE_LINK_PATH', 'shared'),
            from_variant('BUILD_SHARED_LIBS', 'shared'),
            '-DSEACASProj_ENABLE_Kokkos:BOOL=OFF',
            '-DSEACASProj_HIDE_DEPRECATED_CODE:BOOL=OFF',
            from_variant('SEACASExodus_ENABLE_THREADSAFE', 'thread_safe'),
            from_variant('SEACASIoss_ENABLE_THREADSAFE', 'thread_safe'),
            from_variant('SEACASProj_ENABLE_Fortran', 'fortran'),
            from_variant('TPL_ENABLE_X11', 'x11'),
        ])

        # ########## What applications should be built #############
        # Check whether they want everything; if so, do the easy way...
        if '+applications' in spec and '+legacy' in spec:
            options.extend([
                '-DSEACASProj_ENABLE_ALL_PACKAGES:BOOL=ON',
                '-DSEACASProj_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON',
                '-DSEACASProj_ENABLE_SECONDARY_TESTED_CODE:BOOL=ON',
            ])
        else:
            # Don't want everything; handle the subsets:
            options.extend([
                '-DSEACASProj_ENABLE_ALL_PACKAGES:BOOL=OFF',
                '-DSEACASProj_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=OFF',
                '-DSEACASProj_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF',
                '-DSEACASProj_ENABLE_SEACASIoss:BOOL=ON',
                '-DSEACASProj_ENABLE_SEACASExodus:BOOL=ON',
                from_variant('SEACASProj_ENABLE_SEACASExodus_for', 'fortran'),
                from_variant('SEACASProj_ENABLE_SEACASExoIIv2for32', 'fortran'),
            ])

            if '+applications' in spec:
                options.extend([
                    '-DSEACASProj_ENABLE_SEACASAprepro:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASAprepro_lib:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASConjoin:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASEjoin:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASEpu:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASExo2mat:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASExo_format:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASExodiff:BOOL=ON',
                    from_variant('SEACASProj_ENABLE_SEACASExplore', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASGrepos', 'fortran'),
                    '-DSEACASProj_ENABLE_SEACASMat2exo:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASNas2exo:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASNemslice:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASNemspread:BOOL=ON',
                    '-DSEACASProj_ENABLE_SEACASSlice:BOOL=ON',
                ])

            if '+legacy' in spec:
                options.extend([
                    from_variant('SEACASProj_ENABLE_SEACASAlgebra', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASBlot', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASEx1ex2v2', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASEx2ex1v2', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASExomatlab', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASExotec2', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASExotxt', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASFastq', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASGen3D', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASGenshell', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASGjoin', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASMapvar', 'fortran'),
                    '-DSEACASProj_ENABLE_SEACASMapvar-kd:BOOL=%s' % (
                        'ON' if '+fortran' in spec else 'OFF'),
                    '-DSEACASProj_ENABLE_SEACASNemesis:BOOL=ON',
                    from_variant('SEACASProj_ENABLE_SEACASNumbers', 'fortran'),
                    from_variant('SEACASProj_ENABLE_SEACASTxtexo', 'fortran'),
                ])

        # ##################### Dependencies ##########################
        # Always need NetCDF-C
        options.extend([
            '-DTPL_ENABLE_Netcdf:BOOL=ON',
            '-DNetCDF_ROOT:PATH=%s' % spec['netcdf-c'].prefix,
        ])

        if '+metis' in spec:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=ON',
                '-DMETIS_LIBRARY_DIRS=%s' % spec['metis'].prefix.lib,
                '-DMETIS_LIBRARY_NAMES=metis',
                '-DTPL_METIS_INCLUDE_DIRS=%s' % spec['metis'].prefix.include,
                '-DTPL_ENABLE_ParMETIS:BOOL=ON',
                '-DParMETIS_LIBRARY_DIRS=%s;%s' % (
                    spec['parmetis'].prefix.lib, spec['metis'].prefix.lib),
                '-DParMETIS_LIBRARY_NAMES=parmetis;metis',
                '-DTPL_ParMETIS_INCLUDE_DIRS=%s;%s' % (
                    spec['parmetis'].prefix.include,
                    spec['metis'].prefix.include)
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=OFF',
                '-DTPL_ENABLE_ParMETIS:BOOL=OFF',
            ])

        if '+matio' in spec:
            options.extend([
                '-DTPL_ENABLE_Matio:BOOL=ON',
                '-DMatio_ROOT:PATH=%s' % spec['matio'].prefix
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_Matio:BOOL=OFF'
            ])

        if '+cgns' in spec:
            options.extend([
                '-DTPL_ENABLE_CGNS:BOOL=ON',
                '-DCGNS_ROOT:PATH=%s' % spec['cgns'].prefix,
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_CGNS:BOOL=OFF'
            ])

        if '+adios2' in spec:
            options.extend([
                '-DTPL_ENABLE_ADIOS2:BOOL=ON',
                '-DADIOS2_ROOT:PATH=%s' % spec['adios2'].prefix,
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_ADIOS2:BOOL=OFF'
            ])

        # ################# RPath Handling ######################
        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH:BOOL=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s' %
                           self.prefix.lib)

        return options
Пример #12
0
    def cmake_args(self):
        spec = self.spec
        define = CMakePackage.define

        def define_trilinos_enable(cmake_var, spec_var=None):
            if spec_var is None:
                spec_var = cmake_var.lower()
            return self.define_from_variant('Trilinos_ENABLE_' + cmake_var,
                                            spec_var)

        def define_tpl_enable(cmake_var, spec_var=None):
            if spec_var is None:
                spec_var = cmake_var.lower()
            return self.define_from_variant('TPL_ENABLE_' + cmake_var,
                                            spec_var)

        cxx_flags = []
        options = []

        # #################### Base Settings #######################

        options.extend([
            define('Trilinos_VERBOSE_CONFIGURE', False),
            define('Trilinos_ENABLE_TESTS', False),
            define('Trilinos_ENABLE_EXAMPLES', False),
            define('Trilinos_ENABLE_CXX11', True),
            self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
            define_trilinos_enable('DEBUG', 'debug'),
            # The following can cause problems on systems that don't have
            # static libraries available for things like dl and pthreads
            # for example when trying to build static libs
            # define('TPL_FIND_SHARED_LIBS', (
            #     'ON' if '+shared' in spec else 'OFF'))
            # define('Trilinos_LINK_SEARCH_START_STATIC', (
            #     'OFF' if '+shared' in spec else 'ON'))
        ])

        # MPI settings
        options.append(define_tpl_enable('MPI'))
        if '+mpi' in spec:
            # Force Trilinos to use the MPI wrappers instead of raw compilers
            # this is needed on Apple systems that require full resolution of
            # all symbols when linking shared libraries
            options.extend([
                define('CMAKE_C_COMPILER', spec['mpi'].mpicc),
                define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx),
                define('CMAKE_Fortran_COMPILER', spec['mpi'].mpifc),
                define('MPI_BASE_DIR', spec['mpi'].prefix),
            ])

        # ################## Trilinos Packages #####################

        options.extend([
            define_trilinos_enable('ALL_OPTIONAL_PACKAGES', 'alloptpkgs'),
            define_trilinos_enable('Amesos'),
            define_trilinos_enable('Amesos2'),
            define_trilinos_enable('Anasazi'),
            define_trilinos_enable('AztecOO', 'aztec'),
            define_trilinos_enable('Belos'),
            define_trilinos_enable('Epetra'),
            define_trilinos_enable('EpetraExt'),
            define_trilinos_enable('Ifpack'),
            define_trilinos_enable('Ifpack2'),
            define_trilinos_enable('Intrepid'),
            define_trilinos_enable('Intrepid2'),
            define_trilinos_enable('Isorropia'),
            define_trilinos_enable('Kokkos'),
            define_trilinos_enable('MiniTensor'),
            define_trilinos_enable('Mesquite'),
            define_trilinos_enable('ML'),
            define_trilinos_enable('MueLu'),
            define_trilinos_enable('NOX'),
            define_trilinos_enable('Piro'),
            define_trilinos_enable('Phalanx'),
            define_trilinos_enable('PyTrilinos', 'python'),
            define_trilinos_enable('ROL'),
            define_trilinos_enable('Rythmos'),
            define_trilinos_enable('Sacado'),
            define_trilinos_enable('Shards'),
            define_trilinos_enable('ShyLU'),
            define_trilinos_enable('STK'),
            define_trilinos_enable('Stratimikos'),
            define_trilinos_enable('Teko'),
            define_trilinos_enable('Tempus'),
            define_trilinos_enable('Teuchos'),
            define_trilinos_enable('Tpetra'),
            define_trilinos_enable('Zoltan'),
            define_trilinos_enable('Zoltan2'),
        ])

        options.append(
            self.define_from_variant('USE_XSDK_DEFAULTS', 'xsdkflags'))

        if '+dtk' in spec:
            options.extend([
                define('Trilinos_EXTRA_REPOSITORIES', 'DataTransferKit'),
                define('Trilinos_ENABLE_DataTransferKit', True),
            ])

        if '+exodus' in spec:
            options.extend([
                define('Trilinos_ENABLE_SEACAS', True),
                define('Trilinos_ENABLE_SEACASExodus', True),
                define('Trilinos_ENABLE_SEACASIoss', True),
                define('Trilinos_ENABLE_SEACASEpu', True),
                define('Trilinos_ENABLE_SEACASExodiff', True),
                define('Trilinos_ENABLE_SEACASNemspread', True),
                define('Trilinos_ENABLE_SEACASNemslice', True),
            ])
        else:
            options.extend([
                define('Trilinos_ENABLE_SEACASExodus', False),
                define('Trilinos_ENABLE_SEACASIoss', False),
            ])

        if '+chaco' in spec:
            options.extend([
                define('Trilinos_ENABLE_SEACAS', True),
                define('Trilinos_ENABLE_SEACASChaco', True),
            ])
        else:
            # don't disable SEACAS, could be needed elsewhere
            options.extend([
                define('Trilinos_ENABLE_SEACASChaco', False),
                define('Trilinos_ENABLE_SEACASNemslice', False)
            ])

        if '+stratimikos' in spec:
            # Explicitly enable Thyra (ThyraCore is required). If you don't do
            # this, then you get "NOT setting ${pkg}_ENABLE_Thyra=ON since
            # Thyra is NOT enabled at this point!" leading to eventual build
            # errors if using MueLu because `Xpetra_ENABLE_Thyra` is set to
            # off.
            options.append(define('Trilinos_ENABLE_Thyra', True))

            # Add thyra adapters based on package enables
            options.extend(
                define_trilinos_enable('Thyra' + pkg + 'Adapters', pkg.lower())
                for pkg in ['Epetra', 'EpetraExt', 'Tpetra'])

        # ######################### TPLs #############################

        blas = spec['blas'].libs
        lapack = spec['lapack'].libs
        options.extend([
            define('TPL_ENABLE_BLAS', True),
            define('BLAS_LIBRARY_NAMES', blas.names),
            define('BLAS_LIBRARY_DIRS', blas.directories),
            define('TPL_ENABLE_LAPACK', True),
            define('LAPACK_LIBRARY_NAMES', lapack.names),
            define('LAPACK_LIBRARY_DIRS', lapack.directories),
            define_tpl_enable('GLM'),
            define_tpl_enable('Matio'),
            define_tpl_enable('X11'),
            define_trilinos_enable('Gtest', 'gtest'),
        ])

        options.append(define_tpl_enable('Netcdf'))
        if '+netcdf' in spec:
            options.append(define('NetCDF_ROOT', spec['netcdf-c'].prefix))

        options.append(define_tpl_enable('HYPRE'))
        if '+hypre' in spec:
            options.extend([
                define('HYPRE_INCLUDE_DIRS', spec['hypre'].prefix.include),
                define('HYPRE_LIBRARY_DIRS', spec['hypre'].prefix.lib),
            ])

        options.append(define_tpl_enable('Boost'))
        if '+boost' in spec:
            options.extend([
                define('Boost_INCLUDE_DIRS', spec['boost'].prefix.include),
                define('Boost_LIBRARY_DIRS', spec['boost'].prefix.lib),
            ])

        options.append(define_tpl_enable('HDF5'))
        if '+hdf5' in spec:
            options.extend([
                define('HDF5_INCLUDE_DIRS', spec['hdf5'].prefix.include),
                define('HDF5_LIBRARY_DIRS', spec['hdf5'].prefix.lib),
            ])

        if '+suite-sparse' in spec:
            options.extend([
                # FIXME: Trilinos seems to be looking for static libs only,
                # patch CMake TPL file?
                define('TPL_ENABLE_Cholmod', False),
                # define('TPL_ENABLE_Cholmod', True),
                # define('Cholmod_LIBRARY_DIRS', (
                #    spec['suite-sparse'].prefix.lib)
                # define('Cholmod_INCLUDE_DIRS', (
                #    spec['suite-sparse'].prefix.include)
                define('TPL_ENABLE_UMFPACK', True),
                define('UMFPACK_LIBRARY_DIRS',
                       spec['suite-sparse'].prefix.lib),
                define('UMFPACK_INCLUDE_DIRS',
                       spec['suite-sparse'].prefix.include),
                define('UMFPACK_LIBRARY_NAMES', [
                    'umfpack', 'amd', 'colamd', 'cholmod', 'suitesparseconfig'
                ]),
            ])
        else:
            options.extend([
                define('TPL_ENABLE_Cholmod', False),
                define('TPL_ENABLE_UMFPACK', False),
            ])

        options.append(define_tpl_enable('METIS'))
        options.append(define_tpl_enable('ParMETIS', 'metis'))
        if '+metis' in spec:
            options.extend([
                define('METIS_LIBRARY_DIRS', spec['metis'].prefix.lib),
                define('METIS_LIBRARY_NAMES', 'metis'),
                define('TPL_METIS_INCLUDE_DIRS', spec['metis'].prefix.include),
                define('TPL_ENABLE_ParMETIS', True),
                define(
                    'ParMETIS_LIBRARY_DIRS',
                    [spec['parmetis'].prefix.lib, spec['metis'].prefix.lib]),
                define('ParMETIS_LIBRARY_NAMES', ['parmetis', 'metis']),
                define('TPL_ParMETIS_INCLUDE_DIRS', [
                    spec['parmetis'].prefix.include,
                    spec['metis'].prefix.include
                ]),
            ])

        options.append(define_tpl_enable('MUMPS'))
        options.append(define_tpl_enable('SCALAPACK', 'mumps'))
        if '+mumps' in spec:
            scalapack = spec['scalapack'].libs
            options.extend([
                define('MUMPS_LIBRARY_DIRS', spec['mumps'].prefix.lib),
                # order is important!
                define('MUMPS_LIBRARY_NAMES',
                       ['dmumps', 'mumps_common', 'pord']),
                define('SCALAPACK_LIBRARY_NAMES', scalapack.names),
                define('SCALAPACK_LIBRARY_DIRS', scalapack.directories),
            ])
            # see
            # https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
            cxx_flags.extend(['-DMUMPS_5_0'])

        options.append(define_tpl_enable('SuperLUDist', 'superlu-dist'))
        if '+superlu-dist' in spec:
            options.extend([
                define('KokkosTSQR_ENABLE_Complex', False),
                define('TPL_ENABLE_SuperLUDist', True),
                define('SuperLUDist_LIBRARY_DIRS',
                       spec['superlu-dist'].prefix.lib),
                define('SuperLUDist_INCLUDE_DIRS',
                       spec['superlu-dist'].prefix.include),
            ])
            if spec.satisfies('^[email protected]:'):
                options.extend([
                    define('HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG', True),
                ])

        options.append(define_tpl_enable('SuperLU'))
        if '+superlu' in spec:
            options.extend([
                define('SuperLU_LIBRARY_DIRS', spec['superlu'].prefix.lib),
                define('SuperLU_INCLUDE_DIRS', spec['superlu'].prefix.include),
            ])

        options.append(define_tpl_enable('Pnetcdf'))
        if '+pnetcdf' in spec:
            options.extend([
                define('TPL_Netcdf_Enables_Netcdf4', True),
                define('TPL_Netcdf_PARALLEL', True),
                define('PNetCDF_ROOT', spec['parallel-netcdf'].prefix),
            ])

        options.append(define_tpl_enable('Zlib'))
        if '+zlib' in spec:
            options.extend([
                define('TPL_ENABLE_Zlib', True),
                define('Zlib_ROOT', spec['zlib'].prefix),
            ])

        options.append(define_tpl_enable('CGNS'))
        if '+cgns' in spec:
            options.extend([
                define('TPL_ENABLE_CGNS', True),
                define('CGNS_INCLUDE_DIRS', spec['cgns'].prefix.include),
                define('CGNS_LIBRARY_DIRS', spec['cgns'].prefix.lib),
            ])

        options.append(self.define_from_variant('TPL_ENABLE_ADIOS2', 'adios2'))

        # ################# Miscellaneous Stuff ######################

        # OpenMP
        options.append(define_trilinos_enable('OpenMP'))
        if '+openmp' in spec:
            options.append(define('Kokkos_ENABLE_OpenMP', True))
            if '+tpetra' in spec:
                options.append(define('Tpetra_INST_OPENMP', True))

        # Fortran lib (assumes clang is built with gfortran!)
        if '+fortran' in spec and (spec.satisfies('%gcc')
                                   or spec.satisfies('%clang')
                                   or spec.satisfies('%apple-clang')):
            options.append(define('Trilinos_ENABLE_Fortran', True))
            if '+mpi' in spec:
                libgfortran = os.path.dirname(
                    os.popen('%s --print-file-name libgfortran.a' %
                             spec['mpi'].mpifc).read())
                options.append(
                    define(
                        'Trilinos_EXTRA_LINK_FLAGS',
                        '-L%s/ -lgfortran' % (libgfortran),
                    ))

        float_s = '+float' in spec
        complex_s = '+complex' in spec
        if '+teuchos' in spec:
            options.extend([
                define('Teuchos_ENABLE_COMPLEX', complex_s),
                define('Teuchos_ENABLE_FLOAT', float_s),
            ])

        # Explicit Template Instantiation (ETI) in Tpetra
        # NOTE: Trilinos will soon move to fixed std::uint64_t for GO and
        # std::int32_t or std::int64_t for local.
        options.append(
            self.define_from_variant('Trilinos_ENABLE_EXPLICIT_INSTANTIATION',
                                     'explicit_template_instantiation'))

        if '+explicit_template_instantiation' in spec and '+tpetra' in spec:
            options.extend([
                define('Tpetra_INST_DOUBLE', True),
                define('Tpetra_INST_COMPLEX_DOUBLE', complex_s),
                define('Tpetra_INST_COMPLEX_FLOAT', float_s and complex_s),
                define('Tpetra_INST_FLOAT', float_s),
                define('Tpetra_INST_SERIAL', True),
            ])

            gotype = spec.variants['gotype'].value
            # default in older Trilinos versions to enable multiple GOs
            if ((gotype == 'none') and spec.satisfies('@:12.14.1')):
                options.extend([
                    '-DTpetra_INST_INT_INT:BOOL=ON',
                    '-DTpetra_INST_INT_LONG:BOOL=ON',
                    '-DTpetra_INST_INT_LONG_LONG:BOOL=ON'
                ])
            # set default GO in newer versions to long
            elif (gotype == 'none'):
                options.extend([
                    '-DTpetra_INST_INT_INT:BOOL=OFF',
                    '-DTpetra_INST_INT_LONG:BOOL=ON',
                    '-DTpetra_INST_INT_LONG_LONG:BOOL=OFF'
                ])
            # if another GO is specified, use this
            else:
                options.extend([
                    define('Tpetra_INST_INT_INT', gotype == 'int'),
                    define('Tpetra_INST_INT_LONG', gotype == 'long'),
                    define('Tpetra_INST_INT_LONG_LONG', gotype == 'long_long'),
                ])

        # disable due to compiler / config errors:
        if spec.satisfies('%xl') or spec.satisfies('%xl_r'):
            options.extend([
                define('Trilinos_ENABLE_Pamgen', False),
                define('Trilinos_ENABLE_Stokhos', False),
            ])

        if sys.platform == 'darwin':
            options.append(define('Trilinos_ENABLE_FEI', False))

        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append(define('CMAKE_MACOSX_RPATH', True))
        else:
            options.append(define('CMAKE_INSTALL_NAME_DIR', self.prefix.lib))

        if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
            # Panzer uses some std:chrono that is not recognized by Intel
            # Don't know which (maybe all) Trilinos versions this applies to
            # Don't know which (maybe all) Intel versions this applies to
            options.append(define('Trilinos_ENABLE_Panzer', False))

        # collect CXX flags:
        options.append(define('CMAKE_CXX_FLAGS', (' '.join(cxx_flags))))

        # disable due to compiler / config errors:
        options.append(define('Trilinos_ENABLE_Pike', False))

        return options
Пример #13
0
    def cmake_args(self):
        spec = self.spec

        cxx_flags = []
        options = []

        # #################### Base Settings #######################

        mpi_bin = spec['mpi'].prefix.bin
        options.extend([
            '-DTrilinos_VERBOSE_CONFIGURE:BOOL=OFF',
            '-DTrilinos_ENABLE_TESTS:BOOL=OFF',
            '-DTrilinos_ENABLE_EXAMPLES:BOOL=OFF',
            '-DTrilinos_ENABLE_CXX11:BOOL=ON',
            '-DBUILD_SHARED_LIBS:BOOL=%s' %
            ('ON' if '+shared' in spec else 'OFF'),
            '-DTrilinos_ENABLE_DEBUG:BOOL=%s' %
            ('ON' if '+debug' in spec else 'OFF'),

            # The following can cause problems on systems that don't have
            # static libraries available for things like dl and pthreads
            # for example when trying to build static libs
            # '-DTPL_FIND_SHARED_LIBS:BOOL=%s' % (
            #     'ON' if '+shared' in spec else 'OFF'),
            # '-DTrilinos_LINK_SEARCH_START_STATIC:BOOL=%s' % (
            #     'OFF' if '+shared' in spec else 'ON'),

            # Force Trilinos to use the MPI wrappers instead of raw compilers
            # this is needed on Apple systems that require full resolution of
            # all symbols when linking shared libraries
            '-DTPL_ENABLE_MPI:BOOL=ON',
            '-DCMAKE_C_COMPILER=%s' % spec['mpi'].mpicc,
            '-DCMAKE_CXX_COMPILER=%s' % spec['mpi'].mpicxx,
            '-DCMAKE_Fortran_COMPILER=%s' % spec['mpi'].mpifc,
            '-DMPI_BASE_DIR:PATH=%s' % spec['mpi'].prefix
        ])

        # ################## Trilinos Packages #####################

        options.extend([
            '-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=%s' %
            ('ON' if '+alloptpkgs' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Amesos:BOOL=%s' %
            ('ON' if '+amesos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Amesos2:BOOL=%s' %
            ('ON' if '+amesos2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Anasazi:BOOL=%s' %
            ('ON' if '+anasazi' in spec else 'OFF'),
            '-DTrilinos_ENABLE_AztecOO:BOOL=%s' %
            ('ON' if '+aztec' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Belos:BOOL=%s' %
            ('ON' if '+belos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Epetra:BOOL=%s' %
            ('ON' if '+epetra' in spec else 'OFF'),
            '-DTrilinos_ENABLE_EpetraExt:BOOL=%s' %
            ('ON' if '+epetraext' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Ifpack:BOOL=%s' %
            ('ON' if '+ifpack' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Ifpack2:BOOL=%s' %
            ('ON' if '+ifpack2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Intrepid=%s' %
            ('ON' if '+intrepid' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Intrepid2=%s' %
            ('ON' if '+intrepid2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Isorropia=%s' %
            ('ON' if '+isorropia' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Kokkos:BOOL=%s' %
            ('ON' if '+kokkos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_MiniTensor=%s' %
            ('ON' if '+minitensor' in spec else 'OFF'),
            '-DTrilinos_ENABLE_ML:BOOL=%s' %
            ('ON' if '+ml' in spec else 'OFF'),
            '-DTrilinos_ENABLE_MueLu:BOOL=%s' %
            ('ON' if '+muelu' in spec else 'OFF'),
            '-DTrilinos_ENABLE_NOX:BOOL=%s' %
            ('ON' if '+nox' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Piro:BOOL=%s' %
            ('ON' if '+piro' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Phalanx=%s' %
            ('ON' if '+phalanx' in spec else 'OFF'),
            '-DTrilinos_ENABLE_PyTrilinos:BOOL=%s' %
            ('ON' if '+python' in spec else 'OFF'),
            '-DTrilinos_ENABLE_ROL:BOOL=%s' %
            ('ON' if '+rol' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Rythmos=%s' %
            ('ON' if '+rythmos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Sacado:BOOL=%s' %
            ('ON' if '+sacado' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Shards=%s' %
            ('ON' if '+shards' in spec else 'OFF'),
            '-DTrilinos_ENABLE_ShyLU=%s' %
            ('ON' if '+shylu' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Teko=%s' % ('ON' if '+teko' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Tempus=%s' %
            ('ON' if '+tempus' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Teuchos:BOOL=%s' %
            ('ON' if '+teuchos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Tpetra:BOOL=%s' %
            ('ON' if '+tpetra' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Zoltan:BOOL=%s' %
            ('ON' if '+zoltan' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Zoltan2:BOOL=%s' %
            ('ON' if '+zoltan2' in spec else 'OFF'),
        ])

        if '+xsdkflags' in spec:
            options.extend(['-DUSE_XSDK_DEFAULTS=YES'])

        if '+stk' in spec:
            options.extend(['-DTrilinos_ENABLE_STK:BOOL=ON'])
        else:
            options.extend(['-DTrilinos_ENABLE_STK:BOOL=OFF'])

        if '+dtk' in spec:
            options.extend([
                '-DTrilinos_EXTRA_REPOSITORIES:STRING=DataTransferKit',
                '-DTrilinos_ENABLE_DataTransferKit:BOOL=ON'
            ])

        if '+exodus' in spec:
            options.extend([
                '-DTrilinos_ENABLE_SEACAS:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASExodus:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASIoss:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASEpu:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASExodiff:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASNemspread:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASNemslice:BOOL=ON'
            ])
        else:
            options.extend([
                '-DTrilinos_ENABLE_SEACASExodus:BOOL=OFF',
                '-DTrilinos_ENABLE_SEACASIoss:BOOL=OFF'
            ])

        if '+chaco' in spec:
            options.extend([
                '-DTrilinos_ENABLE_SEACAS:BOOL=ON'
                '-DTrilinos_ENABLE_SEACASChaco:BOOL=ON'
            ])
        else:
            # don't disable SEACAS, could be needed elsewhere
            options.extend([
                '-DTrilinos_ENABLE_SEACASChaco:BOOL=OFF',
                '-DTrilinos_ENABLE_SEACASNemslice=OFF'
            ])

        # ######################### TPLs #############################

        blas = spec['blas'].libs
        lapack = spec['lapack'].libs
        # Note: -DXYZ_LIBRARY_NAMES= needs semicolon separated list of names
        options.extend([
            '-DTPL_ENABLE_BLAS=ON',
            '-DBLAS_LIBRARY_NAMES=%s' % ';'.join(blas.names),
            '-DBLAS_LIBRARY_DIRS=%s' % ';'.join(blas.directories),
            '-DTPL_ENABLE_LAPACK=ON',
            '-DLAPACK_LIBRARY_NAMES=%s' % ';'.join(lapack.names),
            '-DLAPACK_LIBRARY_DIRS=%s' % ';'.join(lapack.directories),
            '-DTPL_ENABLE_Netcdf:BOOL=ON',
            '-DNetCDF_ROOT:PATH=%s' % spec['netcdf-c'].prefix,
            '-DTPL_ENABLE_X11:BOOL=%s' % ('ON' if '+x11' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Gtest:BOOL=%s' %
            ('ON' if '+gtest' in spec else 'OFF'),
        ])

        if '+hypre' in spec:
            options.extend([
                '-DTPL_ENABLE_HYPRE:BOOL=ON',
                '-DHYPRE_INCLUDE_DIRS:PATH=%s' % spec['hypre'].prefix.include,
                '-DHYPRE_LIBRARY_DIRS:PATH=%s' % spec['hypre'].prefix.lib
            ])

        if '+boost' in spec:
            options.extend([
                '-DTPL_ENABLE_Boost:BOOL=ON',
                '-DBoost_INCLUDE_DIRS:PATH=%s' % spec['boost'].prefix.include,
                '-DBoost_LIBRARY_DIRS:PATH=%s' % spec['boost'].prefix.lib
            ])
        else:
            options.extend(['-DTPL_ENABLE_Boost:BOOL=OFF'])

        if '+hdf5' in spec:
            options.extend([
                '-DTPL_ENABLE_HDF5:BOOL=ON',
                '-DHDF5_INCLUDE_DIRS:PATH=%s' % spec['hdf5'].prefix.include,
                '-DHDF5_LIBRARY_DIRS:PATH=%s' % spec['hdf5'].prefix.lib
            ])
        else:
            options.extend(['-DTPL_ENABLE_HDF5:BOOL=OFF'])

        if '+suite-sparse' in spec:
            options.extend([
                # FIXME: Trilinos seems to be looking for static libs only,
                # patch CMake TPL file?
                '-DTPL_ENABLE_Cholmod:BOOL=OFF',
                # '-DTPL_ENABLE_Cholmod:BOOL=ON',
                # '-DCholmod_LIBRARY_DIRS:PATH=%s' % (
                #    spec['suite-sparse'].prefix.lib,
                # '-DCholmod_INCLUDE_DIRS:PATH=%s' % (
                #    spec['suite-sparse'].prefix.include,
                '-DTPL_ENABLE_UMFPACK:BOOL=ON',
                '-DUMFPACK_LIBRARY_DIRS:PATH=%s' %
                (spec['suite-sparse'].prefix.lib),
                '-DUMFPACK_INCLUDE_DIRS:PATH=%s' %
                (spec['suite-sparse'].prefix.include),
                '-DUMFPACK_LIBRARY_NAMES=umfpack;amd;colamd;cholmod;' +
                'suitesparseconfig'
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_Cholmod:BOOL=OFF',
                '-DTPL_ENABLE_UMFPACK:BOOL=OFF',
            ])

        if '+metis' in spec:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=ON',
                '-DMETIS_LIBRARY_DIRS=%s' % spec['metis'].prefix.lib,
                '-DMETIS_LIBRARY_NAMES=metis',
                '-DTPL_METIS_INCLUDE_DIRS=%s' % spec['metis'].prefix.include,
                '-DTPL_ENABLE_ParMETIS:BOOL=ON',
                '-DParMETIS_LIBRARY_DIRS=%s;%s' %
                (spec['parmetis'].prefix.lib, spec['metis'].prefix.lib),
                '-DParMETIS_LIBRARY_NAMES=parmetis;metis',
                '-DTPL_ParMETIS_INCLUDE_DIRS=%s;%s' %
                (spec['parmetis'].prefix.include, spec['metis'].prefix.include)
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=OFF',
                '-DTPL_ENABLE_ParMETIS:BOOL=OFF',
            ])

        if '+mumps' in spec:
            scalapack = spec['scalapack'].libs
            options.extend([
                '-DTPL_ENABLE_MUMPS:BOOL=ON',
                '-DMUMPS_LIBRARY_DIRS=%s' % spec['mumps'].prefix.lib,
                # order is important!
                '-DMUMPS_LIBRARY_NAMES=dmumps;mumps_common;pord',
                '-DTPL_ENABLE_SCALAPACK:BOOL=ON',
                '-DSCALAPACK_LIBRARY_NAMES=%s' % ';'.join(scalapack.names),
                '-DSCALAPACK_LIBRARY_DIRS=%s' % ';'.join(scalapack.directories)
            ])
            # see
            # https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
            cxx_flags.extend(['-DMUMPS_5_0'])
        else:
            options.extend([
                '-DTPL_ENABLE_MUMPS:BOOL=OFF',
                '-DTPL_ENABLE_SCALAPACK:BOOL=OFF',
            ])

        if '+superlu-dist' in spec:
            options.extend(['-DKokkosTSQR_ENABLE_Complex:BOOL=OFF'])
            options.extend([
                '-DTPL_ENABLE_SuperLUDist:BOOL=ON',
                '-DSuperLUDist_LIBRARY_DIRS=%s' %
                spec['superlu-dist'].prefix.lib,
                '-DSuperLUDist_INCLUDE_DIRS=%s' %
                spec['superlu-dist'].prefix.include
            ])
            if spec.satisfies('^[email protected]:'):
                options.extend(
                    ['-DHAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG:BOOL=ON'])
        else:
            options.extend([
                '-DTPL_ENABLE_SuperLUDist:BOOL=OFF',
            ])

        if '+superlu' in spec:
            options.extend([
                '-DTPL_ENABLE_SuperLU:BOOL=ON',
                '-DSuperLU_LIBRARY_DIRS=%s' % spec['superlu'].prefix.lib,
                '-DSuperLU_INCLUDE_DIRS=%s' % spec['superlu'].prefix.include
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_SuperLU:BOOL=OFF',
            ])

        if '+pnetcdf' in spec:
            options.extend([
                '-DTPL_ENABLE_Pnetcdf:BOOL=ON',
                '-DTPL_Netcdf_Enables_Netcdf4:BOOL=ON',
                '-DTPL_Netcdf_PARALLEL:BOOL=ON',
                '-DPNetCDF_ROOT:PATH=%s' % spec['parallel-netcdf'].prefix
            ])
        else:
            options.extend(['-DTPL_ENABLE_Pnetcdf:BOOL=OFF'])

        if '+zlib' in spec:
            options.extend([
                '-DTPL_ENABLE_Zlib:BOOL=ON',
                '-DZlib_ROOT:PATH=%s' % spec['zlib'].prefix,
            ])
        else:
            options.extend(['-DTPL_ENABLE_Zlib:BOOL=OFF'])

        if '+cgns' in spec:
            options.extend([
                '-DTPL_ENABLE_CGNS:BOOL=ON',
                '-DCGNS_INCLUDE_DIRS:PATH=%s' % spec['cgns'].prefix.include,
                '-DCGNS_LIBRARY_DIRS:PATH=%s' % spec['cgns'].prefix.lib
            ])
        else:
            options.extend(['-DTPL_ENABLE_CGNS:BOOL=OFF'])

        options.append('-DTPL_ENABLE_ADIOS2:BOOL=' + str('+adios2' in spec))
        # ################# Miscellaneous Stuff ######################

        # OpenMP
        if '+openmp' in spec:
            options.extend([
                '-DTrilinos_ENABLE_OpenMP:BOOL=ON',
                '-DKokkos_ENABLE_OpenMP:BOOL=ON'
            ])
            if '+tpetra' in spec:
                options.extend(['-DTpetra_INST_OPENMP:BOOL=ON'])

        # Fortran lib
        if '+fortran' in spec:
            if spec.satisfies('%gcc') or spec.satisfies('%clang'):
                libgfortran = os.path.dirname(
                    os.popen('%s --print-file-name libgfortran.a' %
                             join_path(mpi_bin, 'mpif90')).read())
                options.extend([
                    '-DTrilinos_EXTRA_LINK_FLAGS:STRING=-L%s/ -lgfortran' %
                    (libgfortran), '-DTrilinos_ENABLE_Fortran=ON'
                ])

        float_s = 'ON' if '+float' in spec else 'OFF'
        complex_s = 'ON' if '+complex' in spec else 'OFF'
        complex_float_s = 'ON' if ('+complex' in spec
                                   and '+float' in spec) else 'OFF'
        if '+teuchos' in spec:
            options.extend([
                '-DTeuchos_ENABLE_COMPLEX=%s' % complex_s,
                '-DTeuchos_ENABLE_FLOAT=%s' % float_s
            ])

        # Explicit Template Instantiation (ETI) in Tpetra
        # NOTE: Trilinos will soon move to fixed std::uint64_t for GO and
        # std::int32_t or std::int64_t for local.
        options.append(
            '-DTrilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=%s' %
            ('ON' if '+explicit_template_instantiation' in spec else 'OFF'))

        if '+explicit_template_instantiation' in spec and '+tpetra' in spec:
            options.extend([
                '-DTpetra_INST_DOUBLE:BOOL=ON',
                '-DTpetra_INST_INT_LONG:BOOL=ON',
                '-DTpetra_INST_INT_LONG_LONG:BOOL=ON',
                '-DTpetra_INST_COMPLEX_DOUBLE=%s' % complex_s,
                '-DTpetra_INST_COMPLEX_FLOAT=%s' % complex_float_s,
                '-DTpetra_INST_FLOAT=%s' % float_s, '-DTpetra_INST_SERIAL=ON'
            ])

        # disable due to compiler / config errors:
        if spec.satisfies('%xl') or spec.satisfies('%xl_r'):
            options.extend([
                '-DTrilinos_ENABLE_Pamgen:BOOL=OFF',
                '-DTrilinos_ENABLE_Stokhos:BOOL=OFF'
            ])

        if sys.platform == 'darwin':
            options.extend(['-DTrilinos_ENABLE_FEI=OFF'])

        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s' %
                           self.prefix.lib)

        if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
            # Panzer uses some std:chrono that is not recognized by Intel
            # Don't know which (maybe all) Trilinos versions this applies to
            # Don't know which (maybe all) Intel versions this applies to
            options.extend(['-DTrilinos_ENABLE_Panzer:BOOL=OFF'])

        # collect CXX flags:
        options.extend([
            '-DCMAKE_CXX_FLAGS:STRING=%s' % (' '.join(cxx_flags)),
        ])

        # disable due to compiler / config errors:
        options.extend(['-DTrilinos_ENABLE_Pike=OFF'])

        return options
Пример #14
0
class Gcc(AutotoolsPackage, GNUMirrorPackage):
    """The GNU Compiler Collection includes front ends for C, C++, Objective-C,
    Fortran, Ada, and Go, as well as libraries for these languages."""

    homepage = 'https://gcc.gnu.org'
    gnu_mirror_path = 'gcc/gcc-9.2.0/gcc-9.2.0.tar.xz'
    git = 'git://gcc.gnu.org/git/gcc.git'
    list_url = 'https://ftp.gnu.org/gnu/gcc/'
    list_depth = 1

    maintainers = ['michaelkuhn', 'alalazo']

    version('master', branch='master')

    version('12.1.0',
            sha256=
            '62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b')

    version('11.3.0',
            sha256=
            'b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39')
    version('11.2.0',
            sha256=
            'd08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b')
    version('11.1.0',
            sha256=
            '4c4a6fb8a8396059241c2e674b85b351c26a5d678274007f076957afa1cc9ddf')

    version('10.4.0',
            sha256=
            'c9297d5bcd7cb43f3dfc2fed5389e948c9312fd962ef6a4ce455cff963ebe4f1')
    version('10.3.0',
            sha256=
            '64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344')
    version('10.2.0',
            sha256=
            'b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c')
    version('10.1.0',
            sha256=
            'b6898a23844b656f1b68691c5c012036c2e694ac4b53a8918d4712ad876e7ea2')

    version('9.5.0',
            sha256=
            '27769f64ef1d4cd5e2be8682c0c93f9887983e6cfd1a927ce5a0a2915a95cf8f')
    version('9.4.0',
            sha256=
            'c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e')
    version('9.3.0',
            sha256=
            '71e197867611f6054aa1119b13a0c0abac12834765fe2d81f35ac57f84f742d1')
    version('9.2.0',
            sha256=
            'ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206')
    version('9.1.0',
            sha256=
            '79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0')

    version('8.5.0',
            sha256=
            'd308841a511bb830a6100397b0042db24ce11f642dab6ea6ee44842e5325ed50')
    version('8.4.0',
            sha256=
            'e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4')
    version('8.3.0',
            sha256=
            '64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c')
    version('8.2.0',
            sha256=
            '196c3c04ba2613f893283977e6011b2345d1cd1af9abeac58e916b1aab3e0080')
    version('8.1.0',
            sha256=
            '1d1866f992626e61349a1ccd0b8d5253816222cdc13390dcfaa74b093aa2b153')

    version('7.5.0',
            sha256=
            'b81946e7f01f90528a1f7352ab08cc602b9ccc05d4e44da4bd501c5a189ee661')
    version('7.4.0',
            sha256=
            'eddde28d04f334aec1604456e536416549e9b1aa137fc69204e65eb0c009fe51')
    version('7.3.0',
            sha256=
            '832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c')
    version('7.2.0',
            sha256=
            '1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a')
    version('7.1.0',
            sha256=
            '8a8136c235f64c6fef69cac0d73a46a1a09bb250776a050aec8f9fc880bebc17')

    version('6.5.0',
            sha256=
            '7ef1796ce497e89479183702635b14bb7a46b53249209a5e0f999bebf4740945')
    version('6.4.0',
            sha256=
            '850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4')
    version('6.3.0',
            sha256=
            'f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f')
    version('6.2.0',
            sha256=
            '9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5')
    version('6.1.0',
            sha256=
            '09c4c85cabebb971b1de732a0219609f93fc0af5f86f6e437fd8d7f832f1a351')

    version('5.5.0',
            sha256=
            '530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87')
    version('5.4.0',
            sha256=
            '608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a')
    version('5.3.0',
            sha256=
            'b84f5592e9218b73dbae612b5253035a7b34a9a1f7688d2e1bfaaf7267d5c4db')
    version('5.2.0',
            sha256=
            '5f835b04b5f7dd4f4d2dc96190ec1621b8d89f2dc6f638f9f8bc1b1014ba8cad')
    version('5.1.0',
            sha256=
            'b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad')

    version('4.9.4',
            sha256=
            '6c11d292cd01b294f9f84c9a59c230d80e9e4a47e5c6355f046bb36d4f358092')
    version('4.9.3',
            sha256=
            '2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e')
    version('4.9.2',
            sha256=
            '2020c98295856aa13fda0f2f3a4794490757fc24bcca918d52cc8b4917b972dd')
    version('4.9.1',
            sha256=
            'd334781a124ada6f38e63b545e2a3b8c2183049515a1abab6d513f109f1d717e')
    version('4.8.5',
            sha256=
            '22fb1e7e0f68a63cee631d85b20461d1ea6bda162f03096350e38c8d427ecf23')
    version('4.8.4',
            sha256=
            '4a80aa23798b8e9b5793494b8c976b39b8d9aa2e53cd5ed5534aff662a7f8695')
    version('4.7.4',
            sha256=
            '92e61c6dc3a0a449e62d72a38185fda550168a86702dea07125ebd3ec3996282')
    version('4.6.4',
            sha256=
            '35af16afa0b67af9b8eb15cafb76d2bc5f568540552522f5dc2c88dd45d977e8')
    version('4.5.4',
            sha256=
            'eef3f0456db8c3d992cbb51d5d32558190bc14f3bc19383dd93acc27acc6befc')

    # We specifically do not add 'all' variant here because:
    # (i) Ada, Go, Jit, and Objective-C++ are not default languages.
    # In that respect, the name 'all' is rather misleading.
    # (ii) Languages other than c,c++,fortran are prone to configure bug in GCC
    # For example, 'java' appears to ignore custom location of zlib
    # (iii) meaning of 'all' changes with GCC version, i.e. 'java' is not part
    # of gcc7. Correctly specifying conflicts() and depends_on() in such a
    # case is a PITA.
    variant('languages',
            default='c,c++,fortran',
            values=('ada', 'brig', 'c', 'c++', 'fortran', 'go', 'java', 'jit',
                    'lto', 'objc', 'obj-c++'),
            multi=True,
            description='Compilers and runtime libraries to build')
    variant('binutils', default=False, description='Build via binutils')
    variant('piclibs',
            default=False,
            description='Build PIC versions of libgfortran.a and libstdc++.a')
    variant('strip',
            default=False,
            description='Strip executables to reduce installation size')
    variant('nvptx',
            default=False,
            description='Target nvptx offloading to NVIDIA GPUs')
    variant('bootstrap', default=True, description='Enable 3-stage bootstrap')
    variant('graphite',
            default=False,
            description='Enable Graphite loop optimizations (requires ISL)')
    variant('build_type',
            default='RelWithDebInfo',
            values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel'),
            description='CMake-like build type. '
            'Debug: -O0 -g; Release: -O3; '
            'RelWithDebInfo: -O2 -g; MinSizeRel: -Os')
    variant('profiled',
            default=False,
            description='Use Profile Guided Optimization',
            when='+bootstrap %gcc')

    depends_on('flex', type='build', when='@master')

    # https://gcc.gnu.org/install/prerequisites.html
    depends_on('[email protected]:')
    # mawk is not sufficient for go support
    depends_on('[email protected]:', type='build')
    depends_on('[email protected]:', type='build')
    depends_on('libtool', type='build')
    # dependencies required for git versions
    depends_on('[email protected]:', when='@master', type='build')
    depends_on('[email protected]:', when='@master', type='build')
    depends_on('[email protected]:', when='@master', type='build')

    # GCC 7.3 does not compile with newer releases on some platforms, see
    #   https://github.com/spack/spack/issues/6902#issuecomment-433030376
    depends_on('[email protected]:3.1.6', when='@:9.9')
    depends_on('[email protected]:', when='@10:')
    depends_on('[email protected]:', when='@4.5:')
    # Already released GCC versions do not support any newer version of ISL
    #   GCC 5.4 https://github.com/spack/spack/issues/6902#issuecomment-433072097
    #   GCC 7.3 https://github.com/spack/spack/issues/6902#issuecomment-433030376
    #   GCC 9+  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724
    with when('+graphite'):
        depends_on('[email protected]', when='@5.0:5.2')
        depends_on('[email protected]', when='@5.3:5.9')
        depends_on('[email protected]:0.18', when='@6:8.9')
        depends_on('[email protected]:0.20', when='@9:9.9')
        depends_on('[email protected]:', when='@10:')

    depends_on('zlib', when='@6:')
    depends_on('zstd', when='@10:')
    depends_on('diffutils', type='build')
    depends_on('iconv', when='platform=darwin')
    depends_on('gnat', when='languages=ada')
    depends_on('binutils+gas+ld+plugins~libiberty',
               when='+binutils',
               type=('build', 'link', 'run'))
    depends_on('zip', type='build', when='languages=java')

    # The server is sometimes a bit slow to respond
    timeout = {'timeout': 60}

    # TODO: integrate these libraries.
    # depends_on('ppl')
    # depends_on('cloog')

    # https://gcc.gnu.org/install/test.html
    depends_on('[email protected]', type='test')
    depends_on('expect', type='test')
    depends_on('tcl', type='test')
    depends_on('[email protected]:', type='test')
    depends_on('[email protected]:', type='test')

    # See https://golang.org/doc/install/gccgo#Releases
    with when('languages=go'):
        provides('golang', when='@4.6:')
        provides('golang@:1', when='@4.7.1:')
        provides('golang@:1.1', when='@4.8:')
        provides('golang@:1.1.2', when='@4.8.2:')
        provides('golang@:1.2', when='@4.9:')
        provides('golang@:1.4', when='@5:')
        provides('golang@:1.6.1', when='@6:')
        provides('golang@:1.8', when='@7:')
        # GCC 4.6 added support for the Go programming language.
        # See https://gcc.gnu.org/gcc-4.6/changes.html
        conflicts('@:4.5', msg='support for Go has been added in GCC 4.6')
        # Go is not supported on macOS
        conflicts('platform=darwin', msg='Go not supported on MacOS')

    # For a list of valid languages for a specific release,
    # run the following command in the GCC source directory:
    #    $ grep ^language= gcc/*/config-lang.in
    # See https://gcc.gnu.org/install/configure.html

    # Support for processing BRIG 1.0 files was added in GCC 7
    # BRIG is a binary format for HSAIL:
    # (Heterogeneous System Architecture Intermediate Language).
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=brig', when='@:6')

    # BRIG does not seem to be supported on macOS
    conflicts('languages=brig', when='platform=darwin')

    # GCC 4.8 added a 'c' language. I'm sure C was always built,
    # but this is the first version that accepts 'c' as a valid language.
    conflicts('languages=c', when='@:4.7')

    # The GCC Java frontend and associated libjava runtime library
    # have been removed from GCC as of GCC 7.
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=java', when='@7:')

    # GCC 5 added the ability to build GCC as a Just-In-Time compiler.
    # See https://gcc.gnu.org/gcc-5/changes.html
    conflicts('languages=jit', when='@:4')

    with when('+nvptx'):
        depends_on('cuda')
        resource(
            name='newlib',
            url='ftp://sourceware.org/pub/newlib/newlib-3.0.0.20180831.tar.gz',
            sha256=
            '3ad3664f227357df15ff34e954bfd9f501009a647667cd307bf0658aefd6eb5b',
            destination='newlibsource',
            fetch_options=timeout)
        # nvptx-tools does not seem to work as a dependency,
        # but does fine when the source is inside the gcc build directory
        # nvptx-tools doesn't have any releases, so grabbing the last commit
        resource(
            name='nvptx-tools',
            git='https://github.com/MentorEmbedded/nvptx-tools',
            commit='d0524fbdc86dfca068db5a21cc78ac255b335be5',
        )
        # NVPTX offloading supported in 7 and later by limited languages
        conflicts('@:6', msg='NVPTX only supported in gcc 7 and above')
        conflicts('languages=ada')
        conflicts('languages=brig')
        conflicts('languages=go')
        conflicts('languages=java')
        conflicts('languages=jit')
        conflicts('languages=objc')
        conflicts('languages=obj-c++')
        # NVPTX build disables bootstrap
        conflicts('+bootstrap')

    # Binutils can't build ld on macOS
    conflicts('+binutils', when='platform=darwin')

    # Bootstrap comparison failure:
    #   see https://github.com/spack/spack/issues/23296
    #   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100340
    #   on XCode 12.5
    conflicts('+bootstrap', when='@:11.1 %[email protected]')

    # aarch64/M1 is supported in GCC 12+
    conflicts('@:11.2,11.3.1:',
              when='target=aarch64: platform=darwin',
              msg='Only GCC 11.3.0 supports macOS M1 (aarch64)')

    # Newer binutils than RHEL's is required to run `as` on some instructions
    # generated by new GCC (see https://github.com/spack/spack/issues/12235)
    conflicts('~binutils',
              when='@7: os=rhel6',
              msg='New GCC cannot use system assembler on RHEL6')

    # GCC 11 requires GCC 4.8 or later (https://gcc.gnu.org/gcc-11/changes.html)
    conflicts('%gcc@:4.7', when='@11:')

    if sys.platform == 'darwin':
        # Fix parallel build on APFS filesystem
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797
        if macos_version() >= Version('10.13'):
            patch('darwin/apfs.patch', when='@5.5.0,6.1:6.4,7.1:7.3')
            # from homebrew via macports
            # https://trac.macports.org/ticket/56502#no1
            # see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83531
            patch('darwin/headers-10.13-fix.patch', when='@5.5.0')
        if macos_version() >= Version('10.14'):
            # Fix system headers for Mojave SDK:
            # https://github.com/Homebrew/homebrew-core/pull/39041
            patch(
                'https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/8.3.0-xcode-bug-_Atomic-fix.patch',
                sha256=
                '33ee92bf678586357ee8ab9d2faddf807e671ad37b97afdd102d5d153d03ca84',
                when='@6:8.3')
        if macos_version() >= Version('10.15'):
            # Fix system headers for Catalina SDK
            # (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
            patch(
                'https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/9.2.0-catalina.patch',
                sha256=
                '0b8d14a7f3c6a2f0d2498526e86e088926671b5da50a554ffa6b7f73ac4f132b',
                when='@9.2.0')

            # See https://raw.githubusercontent.com/Homebrew/homebrew-core/3b7db4457ac64a31e3bbffc54b04c4bd824a4a4a/Formula/gcc.rb
            patch(
                'https://github.com/iains/gcc-darwin-arm64/commit/20f61faaed3b335d792e38892d826054d2ac9f15.patch?full_index=1',
                sha256=
                'c0605179a856ca046d093c13cea4d2e024809ec2ad4bf3708543fc3d2e60504b',
                when='@11.2.0')

        # Apple M1 support, created from branch of Darwin maintainer for GCC:
        # https://github.com/iains/gcc-11-branch
        patch(
            'https://raw.githubusercontent.com/Homebrew/formula-patches/22dec3fc/gcc/gcc-11.3.0-arm.diff',
            sha256=
            'e02006b7ec917cc1390645d95735a6a866caed0dfe506d5bef742f7862cab218',
            when='@11.3.0 target=aarch64:')

        # Use -headerpad_max_install_names in the build,
        # otherwise updated load commands won't fit in the Mach-O header.
        # This is needed because `gcc` avoids the superenv shim.
        patch('darwin/gcc-7.1.0-headerpad.patch', when='@5:11.2')
        patch('darwin/gcc-6.1.0-jit.patch', when='@5:7')
        patch('darwin/gcc-4.9.patch1', when='@4.9.0:4.9.3')
        patch('darwin/gcc-4.9.patch2', when='@4.9.0:4.9.3')

        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92061
        patch('darwin/clang13.patch', when='@:11.1 %apple-clang@13')

    patch('piclibs.patch', when='+piclibs')
    patch('gcc-backport.patch', when='@4.7:4.9.3,5:5.3')

    # Backport libsanitizer patch for glibc >= 2.31 and 5.3.0 <= gcc <= 9.2.0
    # https://bugs.gentoo.org/708346
    patch('glibc-2.31-libsanitizer-1.patch',
          when='@7.1.0:7.5.0,8.1.0:8.3.0,9.0.0:9.2.0')
    patch('glibc-2.31-libsanitizer-1-gcc-6.patch',
          when='@5.3.0:5.5.0,6.1.0:6.5.0')
    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:8.3.0,9.0.0:9.2.0')
    patch('glibc-2.31-libsanitizer-2-gcc-6.patch',
          when='@5.3.0:5.5.0,6.1.0:6.5.0')
    patch('glibc-2.31-libsanitizer-2-gcc-7.patch', when='@7.1.0:7.5.0')
    patch(
        'https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=2b40941d23b1570cdd90083b58fa0f66aa58c86e',
        sha256=
        'b48e48736062e64a6da7cbe7e21a6c1c89422d1f49ef547c73b479a3f3f4935f',
        when='@6.5.0,7.4.0:7.5.0,8.2.0:9.3.0')
    patch(
        'https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=745dae5923aba02982563481d75a21595df22ff8',
        sha256=
        'eaa00c91e08a5e767f023911a49bc1b2d1a3eea38703b745ab260f90e8da41aa',
        when='@10.1.0:10.3.0,11.1.0')

    # Older versions do not compile with newer versions of glibc
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
    patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
    patch('ucontext_t-java.patch', when='@4.9,5.1:5.4,6.1:6.4 languages=java')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066
    patch('stack_t-4.9.patch', when='@4.9')
    patch('stack_t.patch', when='@5.1:5.4,6.1:6.4,7.1')
    # https://bugs.busybox.net/show_bug.cgi?id=10061
    patch('signal.patch', when='@4.9,5.1:5.4')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85835
    patch('sys_ustat.h.patch', when='@5.0:6.4,7.0:7.3,8.1')
    patch('sys_ustat-4.9.patch', when='@4.9')

    # this patch removes cylades support from gcc-5 and allows gcc-5 to be built
    # with newer glibc versions.
    patch('glibc-2.31-libsanitizer-3-gcc-5.patch', when='@5.3.0:5.5.0')

    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95005
    patch('zstd.patch', when='@10')

    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100102
    patch(
        'https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=fc930b3010bd0de899a3da3209eab20664ddb703',
        sha256=
        '28c5ab3b564d83dd7e6e35b9c683141a4cb57ee886c5367e54a0828538b3c789',
        when='@10.1:10.3')
    patch(
        'https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=f1feb74046e0feb0596b93bbb822fae02940a90e',
        sha256=
        '3e5029489b79fc0d47fd6719f3d5c9d3bbc727a4a0cbff161a5517e8a3c98cb6',
        when='@11.1')

    build_directory = 'spack-build'

    @classproperty
    def executables(cls):
        names = [r'gcc', r'[^\w]?g\+\+', r'gfortran']
        suffixes = [r'', r'-mp-\d+\.\d', r'-\d+\.\d', r'-\d+', r'\d\d']
        return [r''.join(x) for x in itertools.product(names, suffixes)]

    @classmethod
    def filter_detected_exes(cls, prefix, exes_in_prefix):
        result = []
        for exe in exes_in_prefix:
            # On systems like Ubuntu we might get multiple executables
            # with the string "gcc" in them. See:
            # https://helpmanual.io/packages/apt/gcc/
            basename = os.path.basename(exe)
            substring_to_be_filtered = [
                'c99-gcc',
                'c89-gcc',
                '-nm',
                '-ar',
                'ranlib',
                'clang'  # clang++ matches g++ -> clan[g++]
            ]
            if any(x in basename for x in substring_to_be_filtered):
                continue
            # Filter out links in favor of real executables on
            # all systems but Cray
            host_platform = str(spack.platforms.host())
            if os.path.islink(exe) and host_platform != 'cray':
                continue

            result.append(exe)

        return result

    @classmethod
    def determine_version(cls, exe):
        try:
            output = spack.compiler.get_compiler_version_output(
                exe, '--version')
        except Exception:
            output = ''
        # Apple's gcc is actually apple clang, so skip it.
        # Users can add it manually to compilers.yaml at their own risk.
        if 'Apple' in output:
            return None

        version_regex = re.compile(r'([\d\.]+)')
        for vargs in ('-dumpfullversion', '-dumpversion'):
            try:
                output = spack.compiler.get_compiler_version_output(exe, vargs)
                match = version_regex.search(output)
                if match:
                    return match.group(1)
            except spack.util.executable.ProcessError:
                pass
            except Exception as e:
                tty.debug(e)

        return None

    @classmethod
    def determine_variants(cls, exes, version_str):
        languages, compilers = set(), {}
        for exe in exes:
            basename = os.path.basename(exe)
            if 'g++' in basename:
                languages.add('c++')
                compilers['cxx'] = exe
            elif 'gfortran' in basename:
                languages.add('fortran')
                compilers['fortran'] = exe
            elif 'gcc' in basename:
                languages.add('c')
                compilers['c'] = exe
        variant_str = 'languages={0}'.format(','.join(languages))
        return variant_str, {'compilers': compilers}

    @classmethod
    def validate_detected_spec(cls, spec, extra_attributes):
        # For GCC 'compilers' is a mandatory attribute
        msg = ('the extra attribute "compilers" must be set for '
               'the detected spec "{0}"'.format(spec))
        assert 'compilers' in extra_attributes, msg

        compilers = extra_attributes['compilers']
        for constraint, key in {
                'languages=c': 'c',
                'languages=c++': 'cxx',
                'languages=fortran': 'fortran'
        }.items():
            if spec.satisfies(constraint, strict=True):
                msg = '{0} not in {1}'
                assert key in compilers, msg.format(key, spec)

    @property
    def cc(self):
        msg = "cannot retrieve C compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('c', None)
        result = None
        if 'languages=c' in self.spec:
            result = str(self.spec.prefix.bin.gcc)
        return result

    @property
    def cxx(self):
        msg = "cannot retrieve C++ compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('cxx', None)
        result = None
        if 'languages=c++' in self.spec:
            result = os.path.join(self.spec.prefix.bin, 'g++')
        return result

    @property
    def fortran(self):
        msg = "cannot retrieve Fortran compiler [spec is not concrete]"
        assert self.spec.concrete, msg
        if self.spec.external:
            return self.spec.extra_attributes['compilers'].get('fortran', None)
        result = None
        if 'languages=fortran' in self.spec:
            result = str(self.spec.prefix.bin.gfortran)
        return result

    def url_for_version(self, version):
        # This function will be called when trying to fetch from url, before
        # mirrors are tried. It takes care of modifying the suffix of gnu
        # mirror path so that Spack will also look for the correct file in
        # the mirrors
        if (version < Version('6.4.0') and version != Version('5.5.0')) \
                or version == Version('7.1.0'):
            self.gnu_mirror_path = self.gnu_mirror_path.replace('xz', 'bz2')
        return super(Gcc, self).url_for_version(version)

    def patch(self):
        spec = self.spec
        prefix = self.spec.prefix

        # Fix a standard header file for OS X Yosemite that
        # is GCC incompatible by replacing non-GCC compliant macros
        if 'yosemite' in spec.architecture:
            if os.path.isfile('/usr/include/dispatch/object.h'):
                new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
                mkdirp(new_dispatch_dir)
                new_header = join_path(new_dispatch_dir, 'object.h')
                install('/usr/include/dispatch/object.h', new_header)
                filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
                            'typedef void* dispatch_block_t', new_header)

        # Use installed libz
        if self.version >= Version('6'):
            filter_file('@zlibdir@', '-L{0}'.format(spec['zlib'].prefix.lib),
                        'gcc/Makefile.in')
            filter_file('@zlibinc@',
                        '-I{0}'.format(spec['zlib'].prefix.include),
                        'gcc/Makefile.in')

        if spec.satisfies('+nvptx'):
            # backport of 383400a6078d upstream to allow support of cuda@11:
            filter_file('#define ASM_SPEC "%{misa=*:-m %*}"',
                        '#define ASM_SPEC "%{misa=*:-m %*; :-m sm_35}"',
                        'gcc/config/nvptx/nvptx.h',
                        string=True)
            filter_file(
                'Target RejectNegative ToLower Joined '
                'Enum(ptx_isa) Var(ptx_isa_option) Init(PTX_ISA_SM30)',
                'Target RejectNegative ToLower Joined '
                'Enum(ptx_isa) Var(ptx_isa_option) Init(PTX_ISA_SM35)',
                'gcc/config/nvptx/nvptx.opt',
                string=True)
        self.build_optimization_config()

    def get_common_target_flags(self, spec):
        """Get the right (but pessimistic) architecture specific flags supported by
        both host gcc and to-be-built gcc. For example: gcc@7 %gcc@12 target=znver3
        should pick -march=znver1, since that's what gcc@7 supports."""
        archs = [spec.target] + spec.target.ancestors
        for arch in archs:
            try:
                return arch.optimization_flags('gcc', spec.version)
            except UnsupportedMicroarchitecture:
                pass
        # no arch specific flags in common, unlikely to happen.
        return ''

    def build_optimization_config(self):
        """Write a config/spack.mk file with sensible optimization flags, taking into
        account bootstrapping subtleties."""
        build_type_flags = {
            'Debug': '-O0 -g',
            'Release': '-O3',
            'RelWithDebInfo': '-O2 -g',
            'MinSizeRel': '-Os'
        }

        # Generic optimization flags.
        flags = build_type_flags[self.spec.variants['build_type'].value]

        # Pessimistic target specific flags. For example, when building
        # gcc@11 %gcc@7 on znver3, Spack will fix the target to znver1 during
        # concretization, so we'll stick to that. The other way around however can
        # result in compilation errors, when gcc@7 is built with gcc@11, and znver3
        # is taken as a the target, which gcc@7 doesn't support.
        if '+bootstrap %gcc' in self.spec:
            flags += ' ' + self.get_common_target_flags(self.spec)

        if '+bootstrap' in self.spec:
            variables = [
                'BOOT_CFLAGS', 'CFLAGS_FOR_TARGET', 'CXXFLAGS_FOR_TARGET'
            ]
        else:
            variables = ['CFLAGS', 'CXXFLAGS']

        # Redefine a few variables without losing other defaults:
        # BOOT_CFLAGS = $(filter-out -O% -g%, $(BOOT_CFLAGS)) -O3
        # This makes sure that build_type=Release is really -O3, not -O3 -g.
        fmt_string = '{} := $(filter-out -O% -g%, $({})) {}\n'
        with open('config/spack.mk', 'w') as f:
            for var in variables:
                f.write(fmt_string.format(var, var, flags))
            # Improve the build time for stage 2 a bit by enabling -O1 in stage 1.
            # Note: this is ignored under ~bootstrap.
            f.write('STAGE1_CFLAGS += -O1\n')

    # https://gcc.gnu.org/install/configure.html
    def configure_args(self):
        spec = self.spec

        # Generic options to compile GCC
        options = [
            # Distributor options
            '--with-pkgversion=Spack GCC',
            '--with-bugurl=https://github.com/spack/spack/issues',
            # Xcode 10 dropped 32-bit support
            '--disable-multilib',
            '--enable-languages={0}'.format(','.join(
                spec.variants['languages'].value)),
            # Drop gettext dependency
            '--disable-nls'
        ]

        # Avoid excessive realpath/stat calls for every system header
        # by making -fno-canonical-system-headers the default.
        if self.version >= Version('4.8.0'):
            options.append('--disable-canonical-system-headers')

        # Use installed libz
        if self.version >= Version('6'):
            options.append('--with-system-zlib')

        if 'zstd' in spec:
            options.append('--with-zstd-include={0}'.format(
                spec['zstd'].headers.directories[0]))
            options.append('--with-zstd-lib={0}'.format(
                spec['zstd'].libs.directories[0]))

        # Enabling language "jit" requires --enable-host-shared.
        if 'languages=jit' in spec:
            options.append('--enable-host-shared')

        # Binutils
        if spec.satisfies('+binutils'):
            binutils = spec['binutils'].prefix.bin
            options.extend([
                '--with-gnu-ld',
                '--with-ld=' + binutils.ld,
                '--with-gnu-as',
                '--with-as=' + binutils.join('as'),
            ])

        # enable_bootstrap
        if spec.satisfies('+bootstrap'):
            options.extend([
                '--enable-bootstrap',
            ])
        else:
            options.extend([
                '--disable-bootstrap',
            ])

        # Configure include and lib directories explicitly for these
        # dependencies since the short GCC option assumes that libraries
        # are installed in "/lib" which might not be true on all OS
        # (see #10842)
        #
        # More info at: https://gcc.gnu.org/install/configure.html
        for dep_str in ('mpfr', 'gmp', 'mpc', 'isl'):
            if dep_str not in spec:
                options.append('--without-{0}'.format(dep_str))
                continue

            dep_spec = spec[dep_str]
            include_dir = dep_spec.headers.directories[0]
            lib_dir = dep_spec.libs.directories[0]
            options.extend([
                '--with-{0}-include={1}'.format(dep_str, include_dir),
                '--with-{0}-lib={1}'.format(dep_str, lib_dir)
            ])

        # nvptx-none offloading for host compiler
        if spec.satisfies('+nvptx'):
            options.extend([
                '--enable-offload-targets=nvptx-none',
                '--with-cuda-driver-include={0}'.format(
                    spec['cuda'].prefix.include),
                '--with-cuda-driver-lib={0}'.format(
                    spec['cuda'].libs.directories[0]), '--disable-bootstrap',
                '--disable-multilib'
            ])

        if sys.platform == 'darwin':
            options.extend([
                '--with-native-system-header-dir=/usr/include',
                '--with-sysroot={0}'.format(macos_sdk_path()),
                '--with-libiconv-prefix={0}'.format(spec['iconv'].prefix)
            ])

        # enable appropriate bootstrapping flags
        stage1_ldflags = str(self.rpath_args)
        boot_ldflags = stage1_ldflags + ' -static-libstdc++ -static-libgcc'
        options.append('--with-stage1-ldflags=' + stage1_ldflags)
        options.append('--with-boot-ldflags=' + boot_ldflags)
        options.append('--with-build-config=spack')

        return options

    # run configure/make/make(install) for the nvptx-none target
    # before running the host compiler phases
    @run_before('configure')
    def nvptx_install(self):
        spec = self.spec
        prefix = self.prefix

        if not spec.satisfies('+nvptx'):
            return

        # config.guess returns the host triple, e.g. "x86_64-pc-linux-gnu"
        guess = Executable('./config.guess')
        targetguess = guess(output=str).rstrip('\n')

        options = getattr(self, 'configure_flag_args', [])
        options += ['--prefix={0}'.format(prefix)]

        options += [
            '--with-cuda-driver-include={0}'.format(
                spec['cuda'].prefix.include),
            '--with-cuda-driver-lib={0}'.format(
                spec['cuda'].libs.directories[0]),
        ]

        with working_dir('nvptx-tools'):
            configure = Executable("./configure")
            configure(*options)
            make()
            make('install')

        pattern = join_path(self.stage.source_path, 'newlibsource', '*')
        files = glob.glob(pattern)

        if files:
            symlink(join_path(files[0], 'newlib'), 'newlib')

        # self.build_directory = 'spack-build-nvptx'
        with working_dir('spack-build-nvptx', create=True):

            options = [
                '--prefix={0}'.format(prefix),
                '--enable-languages={0}'.format(','.join(
                    spec.variants['languages'].value)),
                '--with-mpfr={0}'.format(spec['mpfr'].prefix),
                '--with-gmp={0}'.format(spec['gmp'].prefix),
                '--target=nvptx-none',
                '--with-build-time-tools={0}'.format(
                    join_path(prefix, 'nvptx-none', 'bin')),
                '--enable-as-accelerator-for={0}'.format(targetguess),
                '--disable-sjlj-exceptions',
                '--enable-newlib-io-long-long',
            ]

            configure = Executable("../configure")
            configure(*options)
            make()
            make('install')

    @property
    def build_targets(self):
        if '+profiled' in self.spec:
            return ['profiledbootstrap']
        return []

    @property
    def install_targets(self):
        if '+strip' in self.spec:
            return ['install-strip']
        return ['install']

    @property
    def spec_dir(self):
        # e.g. lib/gcc/x86_64-unknown-linux-gnu/4.9.2
        spec_dir = glob.glob('{0}/gcc/*/*'.format(self.prefix.lib))
        return spec_dir[0] if spec_dir else None

    @run_after('install')
    def write_rpath_specs(self):
        """Generate a spec file so the linker adds a rpath to the libs
           the compiler used to build the executable.

           .. caution::

              The custom spec file by default with *always* pass ``-Wl,-rpath
              ...`` to the linker, which will cause the linker to *ignore* the
              value of ``LD_RUN_PATH``, which otherwise would be saved to the
              binary as the default rpath. See the mitigation below for how to
              temporarily disable this behavior.

           Structure the specs file so that users can define a custom spec file
           to suppress the spack-linked rpaths to facilitate rpath adjustment
           for relocatable binaries. The custom spec file
           :file:`{norpath}.spec` will have a single
           line followed by two blanks lines::

               *link_libgcc_rpath:



           It can be passed to the GCC linker using the argument
           ``--specs=norpath.spec`` to disable the automatic rpath and restore
           the behavior of ``LD_RUN_PATH``."""
        if not self.spec_dir:
            tty.warn('Could not install specs for {0}.'.format(
                self.spec.format('{name}{@version}')))
            return

        gcc = self.spec['gcc'].command
        lines = gcc('-dumpspecs', output=str).splitlines(True)
        specs_file = join_path(self.spec_dir, 'specs')

        # Save a backup
        with open(specs_file + '.orig', 'w') as out:
            out.writelines(lines)

        # Find which directories have shared libraries
        rpath_libdirs = []
        for dir in ['lib', 'lib64']:
            libdir = join_path(self.prefix, dir)
            if glob.glob(join_path(libdir, "*." + dso_suffix)):
                rpath_libdirs.append(libdir)

        if not rpath_libdirs:
            # No shared libraries
            tty.warn('No dynamic libraries found in lib/lib64')
            return

        # Overwrite the specs file
        with open(specs_file, 'w') as out:
            for line in lines:
                out.write(line)
                if line.startswith('*link_libgcc:'):
                    # Insert at start of line following link_libgcc, which gets
                    # inserted into every call to the linker
                    out.write('%(link_libgcc_rpath) ')

            # Add easily-overridable rpath string at the end
            out.write('*link_libgcc_rpath:\n')
            if 'platform=darwin' in self.spec:
                # macOS linker requires separate rpath commands
                out.write(' '.join('-rpath ' + lib for lib in rpath_libdirs))
            else:
                # linux linker uses colon-separated rpath
                out.write('-rpath ' + ':'.join(rpath_libdirs))
            out.write('\n')
        set_install_permissions(specs_file)
        tty.info('Wrote new spec file to {0}'.format(specs_file))

    def setup_run_environment(self, env):
        # Search prefix directory for possibly modified compiler names
        from spack.compilers.gcc import Gcc as Compiler

        # Get the contents of the installed binary directory
        bin_path = self.spec.prefix.bin

        if not os.path.isdir(bin_path):
            return

        bin_contents = os.listdir(bin_path)

        # Find the first non-symlink compiler binary present for each language
        for lang in ['cc', 'cxx', 'fc', 'f77']:
            for filename, regexp in itertools.product(
                    bin_contents, Compiler.search_regexps(lang)):
                if not regexp.match(filename):
                    continue

                abspath = os.path.join(bin_path, filename)
                if os.path.islink(abspath):
                    continue

                # Set the proper environment variable
                env.set(lang.upper(), abspath)
                # Stop searching filename/regex combos for this language
                break
Пример #15
0
class Oce(Package):
    """Open CASCADE Community Edition:
    patches/improvements/experiments contributed by users over the official
    Open CASCADE library.
    """
    homepage = "https://github.com/tpaviot/oce"
    url = "https://github.com/tpaviot/oce/archive/OCE-0.18.tar.gz"

    version('0.18.3', sha256='c553d6a7bf52f790abc3b6bb7a1e91a65947e92a426bb1a88a11960c31f0966c')
    version('0.18.2', sha256='dc21ddea678a500ad87c773e9a502ed7a71768cf83d9af0bd4c43294186a7fef')
    version('0.18.1', sha256='1acf5da4bffa3592ca9f3535af9b927b79fcfeadcb81e9963e89aec192929a6c')
    version('0.18',   sha256='226e45e77c16a4a6e127c71fefcd171410703960ae75c7ecc7eb68895446a993')
    version('0.17.2', sha256='8d9995360cd531cbd4a7aa4ca5ed969f08ec7c7a37755e2f3d4ef832c1b2f56e')
    version('0.17.1', sha256='b1ff0cb8cf31339bbb30ac7ed2415d376b9b75810279d2f497e115f08c090928')
    version('0.17',   sha256='9ab0dc2a2d125b46cef458b56c6d171dfe2218d825860d616c5ab17994b8f74d')
    version('0.16.1', sha256='d31030c8da4a1b33f767d0d59895a995c8eabc8fc65cbe0558734f6021ea2f57')
    version('0.16',   sha256='841fe4337a5a4e733e36a2efc4fe60a4e6e8974917028df05d47a02f59787515')

    variant('tbb', default=True,
            description='Build with Intel Threading Building Blocks')
    variant('X11', default=False,
            description='Build with X11 enabled')

    depends_on('[email protected]:', type='build')
    depends_on('tbb', when='+tbb')

    # There is a bug in OCE which appears with Clang (version?) or GCC 6.0
    # and has to do with compiler optimization, see
    # https://github.com/tpaviot/oce/issues/576
    # http://tracker.dev.opencascade.org/view.php?id=26042
    # https://github.com/tpaviot/oce/issues/605
    # https://github.com/tpaviot/oce/commit/61cb965b9ffeca419005bc15e635e67589c421dd.patch
    patch('null.patch', when='@0.16:0.17.1')

    # OCE depends on xlocale.h from glibc-headers but it was removed in 2.26,
    # see https://github.com/tpaviot/oce/issues/675
    patch('xlocale.patch', level=0, when='@0.18.1:0.18.2')

    # fix build with Xcode 8 "previous definition of CLOCK_REALTIME"
    # reported 27 Sep 2016 https://github.com/tpaviot/oce/issues/643
    if (platform.system() == "Darwin") and (
       macos_version() == Version('10.12')):
        patch('sierra.patch', when='@0.17.2:0.18.0')

    def install(self, spec, prefix):
        options = []
        options.extend(std_cmake_args)
        options.extend([
            '-DOCE_INSTALL_PREFIX=%s' % prefix,
            '-DOCE_BUILD_SHARED_LIB:BOOL=ON',
            '-DCMAKE_BUILD_TYPE:STRING=Release',
            '-DOCE_DATAEXCHANGE:BOOL=ON',
            '-DOCE_DISABLE_X11:BOOL=%s' % (
                'OFF' if '+X11' in spec else 'ON'),
            '-DOCE_DRAW:BOOL=OFF',
            '-DOCE_MODEL:BOOL=ON',
            '-DOCE_MULTITHREAD_LIBRARY:STRING=%s' % (
                'TBB' if '+tbb' in spec else 'NONE'),
            '-DOCE_OCAF:BOOL=ON',
            '-DOCE_USE_TCL_TEST_FRAMEWORK:BOOL=OFF',
            '-DOCE_VISUALISATION:BOOL=OFF',
            '-DOCE_WITH_FREEIMAGE:BOOL=OFF',
            '-DOCE_WITH_GL2PS:BOOL=OFF',
            '-DOCE_WITH_OPENCL:BOOL=OFF'
        ])

        if platform.system() == 'Darwin':
            options.extend([
                '-DOCE_OSX_USE_COCOA:BOOL=ON',
            ])

        if platform.system() == 'Darwin' and (
           macos_version() >= Version('10.12')):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)

        cmake('.', *options)
        make("install/strip")
        if self.run_tests:
            make("test")
Пример #16
0
    def cmake_args(self):
        spec = self.spec

        cxx_flags = []
        options = []

        # #################### Base Settings #######################

        mpi_bin = spec['mpi'].prefix.bin
        options.extend([
            '-DTrilinos_VERBOSE_CONFIGURE:BOOL=OFF',
            '-DTrilinos_ENABLE_TESTS:BOOL=OFF',
            '-DTrilinos_ENABLE_EXAMPLES:BOOL=OFF',
            '-DTrilinos_ENABLE_CXX11:BOOL=ON',
            '-DBUILD_SHARED_LIBS:BOOL=%s' % (
                'ON' if '+shared' in spec else 'OFF'),

            # The following can cause problems on systems that don't have
            # static libraries available for things like dl and pthreads
            # for example when trying to build static libs
            # '-DTPL_FIND_SHARED_LIBS:BOOL=%s' % (
            #     'ON' if '+shared' in spec else 'OFF'),
            # '-DTrilinos_LINK_SEARCH_START_STATIC:BOOL=%s' % (
            #     'OFF' if '+shared' in spec else 'ON'),

            # Force Trilinos to use the MPI wrappers instead of raw compilers
            # this is needed on Apple systems that require full resolution of
            # all symbols when linking shared libraries
            '-DTPL_ENABLE_MPI:BOOL=ON',
            '-DCMAKE_C_COMPILER=%s'       % spec['mpi'].mpicc,
            '-DCMAKE_CXX_COMPILER=%s'     % spec['mpi'].mpicxx,
            '-DCMAKE_Fortran_COMPILER=%s' % spec['mpi'].mpifc,
            '-DMPI_BASE_DIR:PATH=%s'      % spec['mpi'].prefix
        ])

        # ################## Trilinos Packages #####################

        options.extend([
            '-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=%s' % (
                'ON' if '+alloptpkgs' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Amesos:BOOL=%s' % (
                'ON' if '+amesos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Amesos2:BOOL=%s' % (
                'ON' if '+amesos2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Anasazi:BOOL=%s' % (
                'ON' if '+anasazi' in spec else 'OFF'),
            '-DTrilinos_ENABLE_AztecOO:BOOL=%s' % (
                'ON' if '+aztec' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Belos:BOOL=%s' % (
                'ON' if '+belos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Epetra:BOOL=%s' % (
                'ON' if '+epetra' in spec else 'OFF'),
            '-DTrilinos_ENABLE_EpetraExt:BOOL=%s' % (
                'ON' if '+epetraext' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Ifpack:BOOL=%s' % (
                'ON' if '+ifpack' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Ifpack2:BOOL=%s' % (
                'ON' if '+ifpack2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Intrepid=%s' % (
                'ON' if '+intrepid' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Intrepid2=%s' % (
                'ON' if '+intrepid2' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Isorropia=%s' % (
                'ON' if '+isorropia' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Kokkos:BOOL=%s' % (
                'ON' if '+kokkos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_MiniTensor=%s' % (
                'ON' if '+minitensor' in spec else 'OFF'),
            '-DTrilinos_ENABLE_ML:BOOL=%s' % (
                'ON' if '+ml' in spec else 'OFF'),
            '-DTrilinos_ENABLE_MueLu:BOOL=%s' % (
                'ON' if '+muelu' in spec else 'OFF'),
            '-DTrilinos_ENABLE_NOX:BOOL=%s' % (
                'ON' if '+nox' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Piro:BOOL=%s' % (
                'ON' if '+piro' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Phalanx=%s' % (
                'ON' if '+phalanx' in spec else 'OFF'),
            '-DTrilinos_ENABLE_PyTrilinos:BOOL=%s' % (
                'ON' if '+python' in spec else 'OFF'),
            '-DTrilinos_ENABLE_ROL:BOOL=%s' % (
                'ON' if '+rol' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Rythmos=%s' % (
                'ON' if '+rythmos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Sacado:BOOL=%s' % (
                'ON' if '+sacado' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Shards=%s' % (
                'ON' if '+shards' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Teko=%s' % (
                'ON' if '+teko' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Tempus=%s' % (
                'ON' if '+tempus' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Teuchos:BOOL=%s' % (
                'ON' if '+teuchos' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Tpetra:BOOL=%s' % (
                'ON' if '+tpetra' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Zoltan:BOOL=%s' % (
                'ON' if '+zoltan' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Zoltan2:BOOL=%s' % (
                'ON' if '+zoltan2' in spec else 'OFF'),
        ])

        if '+xsdkflags' in spec:
            options.extend(['-DUSE_XSDK_DEFAULTS=YES'])

        if '+stk' in spec:
            # Currently these are fairly specific to the Nalu package
            # They can likely change when necessary in the future
            options.extend([
                '-DTrilinos_ENABLE_STKMesh:BOOL=ON',
                '-DTrilinos_ENABLE_STKNGP:BOOL=ON',
                '-DTrilinos_ENABLE_STKSimd:BOOL=ON',
                '-DTrilinos_ENABLE_STKIO:BOOL=ON',
                '-DTrilinos_ENABLE_STKTransfer:BOOL=ON',
                '-DTrilinos_ENABLE_STKSearch:BOOL=ON',
                '-DTrilinos_ENABLE_STKUtil:BOOL=ON',
                '-DTrilinos_ENABLE_STKTopology:BOOL=ON',
                '-DTrilinos_ENABLE_STKUnit_tests:BOOL=ON',
                '-DTrilinos_ENABLE_STKUnit_test_utils:BOOL=ON',
                '-DTrilinos_ENABLE_STKClassic:BOOL=OFF',
                '-DTrilinos_ENABLE_STKExprEval:BOOL=ON'
            ])

        if '+dtk' in spec:
            options.extend([
                '-DTrilinos_EXTRA_REPOSITORIES:STRING=DataTransferKit',
                '-DTpetra_INST_INT_UNSIGNED_LONG:BOOL=ON',
                '-DTrilinos_ENABLE_DataTransferKit:BOOL=ON'
            ])

        if '+exodus' in spec:
            # Currently these are fairly specific to the Nalu package
            # They can likely change when necessary in the future
            options.extend([
                '-DTrilinos_ENABLE_SEACAS:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASExodus:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASEpu:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASExodiff:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASNemspread:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASNemslice:BOOL=ON',
                '-DTrilinos_ENABLE_SEACASIoss:BOOL=ON'
            ])
        else:
            options.extend([
                '-DTrilinos_ENABLE_SEACAS:BOOL=OFF',
                '-DTrilinos_ENABLE_SEACASExodus:BOOL=OFF'
            ])

        # ######################### TPLs #############################

        blas = spec['blas'].libs
        lapack = spec['lapack'].libs
        # Note: -DXYZ_LIBRARY_NAMES= needs semicolon separated list of names
        options.extend([
            '-DTPL_ENABLE_BLAS=ON',
            '-DBLAS_LIBRARY_NAMES=%s' % ';'.join(blas.names),
            '-DBLAS_LIBRARY_DIRS=%s' % ';'.join(blas.directories),
            '-DTPL_ENABLE_LAPACK=ON',
            '-DLAPACK_LIBRARY_NAMES=%s' % ';'.join(lapack.names),
            '-DLAPACK_LIBRARY_DIRS=%s' % ';'.join(lapack.directories),
            '-DTPL_ENABLE_Netcdf:BOOL=ON',
            '-DNetCDF_ROOT:PATH=%s' % spec['netcdf'].prefix,
            '-DTPL_ENABLE_X11:BOOL=%s' % (
                'ON' if '+x11' in spec else 'OFF'),
            '-DTrilinos_ENABLE_Gtest:BOOL=%s' % (
                'ON' if '+gtest' in spec else 'OFF'),
        ])

        if '+hypre' in spec:
            options.extend([
                '-DTPL_ENABLE_HYPRE:BOOL=ON',
                '-DHYPRE_INCLUDE_DIRS:PATH=%s' % spec['hypre'].prefix.include,
                '-DHYPRE_LIBRARY_DIRS:PATH=%s' % spec['hypre'].prefix.lib
            ])

        if '+boost' in spec:
            options.extend([
                '-DTPL_ENABLE_Boost:BOOL=ON',
                '-DBoost_INCLUDE_DIRS:PATH=%s' % spec['boost'].prefix.include,
                '-DBoost_LIBRARY_DIRS:PATH=%s' % spec['boost'].prefix.lib
            ])
        else:
            options.extend(['-DTPL_ENABLE_Boost:BOOL=OFF'])

        if '+hdf5' in spec:
            options.extend([
                '-DTPL_ENABLE_HDF5:BOOL=ON',
                '-DHDF5_INCLUDE_DIRS:PATH=%s' % spec['hdf5'].prefix.include,
                '-DHDF5_LIBRARY_DIRS:PATH=%s' % spec['hdf5'].prefix.lib
            ])
        else:
            options.extend(['-DTPL_ENABLE_HDF5:BOOL=OFF'])

        if '+suite-sparse' in spec:
            options.extend([
                # FIXME: Trilinos seems to be looking for static libs only,
                # patch CMake TPL file?
                '-DTPL_ENABLE_Cholmod:BOOL=OFF',
                # '-DTPL_ENABLE_Cholmod:BOOL=ON',
                # '-DCholmod_LIBRARY_DIRS:PATH=%s' % (
                #    spec['suite-sparse'].prefix.lib,
                # '-DCholmod_INCLUDE_DIRS:PATH=%s' % (
                #    spec['suite-sparse'].prefix.include,
                '-DTPL_ENABLE_UMFPACK:BOOL=ON',
                '-DUMFPACK_LIBRARY_DIRS:PATH=%s' % (
                    spec['suite-sparse'].prefix.lib),
                '-DUMFPACK_INCLUDE_DIRS:PATH=%s' % (
                    spec['suite-sparse'].prefix.include),
                '-DUMFPACK_LIBRARY_NAMES=umfpack;amd;colamd;cholmod;' +
                'suitesparseconfig'
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_Cholmod:BOOL=OFF',
                '-DTPL_ENABLE_UMFPACK:BOOL=OFF',
            ])

        if '+metis' in spec:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=ON',
                '-DMETIS_LIBRARY_DIRS=%s' % spec['metis'].prefix.lib,
                '-DMETIS_LIBRARY_NAMES=metis',
                '-DTPL_METIS_INCLUDE_DIRS=%s' % spec['metis'].prefix.include,
                '-DTPL_ENABLE_ParMETIS:BOOL=ON',
                '-DParMETIS_LIBRARY_DIRS=%s;%s' % (
                    spec['parmetis'].prefix.lib, spec['metis'].prefix.lib),
                '-DParMETIS_LIBRARY_NAMES=parmetis;metis',
                '-DTPL_ParMETIS_INCLUDE_DIRS=%s;%s' % (
                    spec['parmetis'].prefix.include,
                    spec['metis'].prefix.include)
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_METIS:BOOL=OFF',
                '-DTPL_ENABLE_ParMETIS:BOOL=OFF',
            ])

        if '+mumps' in spec:
            scalapack = spec['scalapack'].libs
            options.extend([
                '-DTPL_ENABLE_MUMPS:BOOL=ON',
                '-DMUMPS_LIBRARY_DIRS=%s' % spec['mumps'].prefix.lib,
                # order is important!
                '-DMUMPS_LIBRARY_NAMES=dmumps;mumps_common;pord',
                '-DTPL_ENABLE_SCALAPACK:BOOL=ON',
                '-DSCALAPACK_LIBRARY_NAMES=%s' % ';'.join(scalapack.names),
                '-DSCALAPACK_LIBRARY_DIRS=%s' % ';'.join(scalapack.directories)
            ])
            # see
            # https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
            cxx_flags.extend([
                '-DMUMPS_5_0'
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_MUMPS:BOOL=OFF',
                '-DTPL_ENABLE_SCALAPACK:BOOL=OFF',
            ])

        if '+superlu-dist' in spec:
            options.extend([
                '-DKokkosTSQR_ENABLE_Complex:BOOL=OFF'
            ])
            options.extend([
                '-DTPL_ENABLE_SuperLUDist:BOOL=ON',
                '-DSuperLUDist_LIBRARY_DIRS=%s' %
                spec['superlu-dist'].prefix.lib,
                '-DSuperLUDist_INCLUDE_DIRS=%s' %
                spec['superlu-dist'].prefix.include
            ])
            if spec.satisfies('^[email protected]:'):
                options.extend([
                    '-DHAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG:BOOL=ON'
                ])
        else:
            options.extend([
                '-DTPL_ENABLE_SuperLUDist:BOOL=OFF',
            ])

        if '+superlu' in spec:
            options.extend([
                '-DTPL_ENABLE_SuperLU:BOOL=ON',
                '-DSuperLU_LIBRARY_DIRS=%s' %
                spec['superlu'].prefix.lib,
                '-DSuperLU_INCLUDE_DIRS=%s' %
                spec['superlu'].prefix.include
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_SuperLU:BOOL=OFF',
            ])

        if '+pnetcdf' in spec:
            options.extend([
                '-DTPL_ENABLE_Pnetcdf:BOOL=ON',
                '-DTPL_Netcdf_Enables_Netcdf4:BOOL=ON',
                '-DTPL_Netcdf_PARALLEL:BOOL=ON',
                '-DPNetCDF_ROOT:PATH=%s' % spec['parallel-netcdf'].prefix
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_Pnetcdf:BOOL=OFF'
            ])

        if '+zlib' in spec:
            options.extend([
                '-DTPL_ENABLE_Zlib:BOOL=ON',
                '-DZlib_ROOT:PATH=%s' % spec['zlib'].prefix,
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_Zlib:BOOL=OFF'
            ])

        if '+cgns' in spec:
            options.extend([
                '-DTPL_ENABLE_CGNS:BOOL=ON',
                '-DCGNS_INCLUDE_DIRS:PATH=%s' % spec['cgns'].prefix.include,
                '-DCGNS_LIBRARY_DIRS:PATH=%s' % spec['cgns'].prefix.lib
            ])
        else:
            options.extend([
                '-DTPL_ENABLE_CGNS:BOOL=OFF'
            ])

        # ################# Miscellaneous Stuff ######################

        # OpenMP
        if '+openmp' in spec:
            options.extend([
                '-DTrilinos_ENABLE_OpenMP:BOOL=ON',
                '-DKokkos_ENABLE_OpenMP:BOOL=ON'
            ])
            if '+tpetra' in spec:
                options.extend([
                    '-DTpetra_INST_OPENMP:BOOL=ON'
                ])

        # Fortran lib
        if '+fortran' in spec:
            if spec.satisfies('%gcc') or spec.satisfies('%clang'):
                libgfortran = os.path.dirname(os.popen(
                    '%s --print-file-name libgfortran.a' %
                    join_path(mpi_bin, 'mpif90')).read())
                options.extend([
                    '-DTrilinos_EXTRA_LINK_FLAGS:STRING=-L%s/ -lgfortran' % (
                        libgfortran),
                    '-DTrilinos_ENABLE_Fortran=ON'
                ])

        float_s = 'ON' if '+float' in spec else 'OFF'
        complex_s = 'ON' if '+complex' in spec else 'OFF'
        complex_float_s = 'ON' if ('+complex' in spec and
                                   '+float' in spec) else 'OFF'
        if '+teuchos' in spec:
            options.extend([
                '-DTeuchos_ENABLE_COMPLEX=%s' % complex_s,
                '-DTeuchos_ENABLE_FLOAT=%s' % float_s
            ])

        # Explicit Template Instantiation (ETI) in Tpetra
        # NOTE: Trilinos will soon move to fixed std::uint64_t for GO and
        # std::int32_t or std::int64_t for local.
        options.append(
            '-DTrilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=%s' % (
                'ON' if '+explicit_template_instantiation' in spec else 'OFF'
            )
        )

        if '+explicit_template_instantiation' in spec and '+tpetra' in spec:
            options.extend([
                '-DTpetra_INST_DOUBLE:BOOL=ON',
                '-DTpetra_INST_INT_LONG:BOOL=ON',
                '-DTpetra_INST_COMPLEX_DOUBLE=%s' % complex_s,
                '-DTpetra_INST_COMPLEX_FLOAT=%s' % complex_float_s,
                '-DTpetra_INST_FLOAT=%s' % float_s,
                '-DTpetra_INST_SERIAL=ON'
            ])

        # disable due to compiler / config errors:
        if spec.satisfies('%xl') or spec.satisfies('%xl_r'):
            options.extend([
                '-DTrilinos_ENABLE_Pamgen:BOOL=OFF',
                '-DTrilinos_ENABLE_Stokhos:BOOL=OFF'
            ])

        if sys.platform == 'darwin':
            options.extend([
                '-DTrilinos_ENABLE_FEI=OFF'
            ])

        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s' %
                           self.prefix.lib)

        if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
            # Panzer uses some std:chrono that is not recognized by Intel
            # Don't know which (maybe all) Trilinos versions this applies to
            # Don't know which (maybe all) Intel versions this applies to
            options.extend([
                '-DTrilinos_ENABLE_Panzer:BOOL=OFF'
            ])

        # collect CXX flags:
        options.extend([
            '-DCMAKE_CXX_FLAGS:STRING=%s' % (' '.join(cxx_flags)),
        ])

        # disable due to compiler / config errors:
        options.extend([
            '-DTrilinos_ENABLE_Pike=OFF'
        ])

        return options
Пример #17
0
class Gcc(AutotoolsPackage):
    """The GNU Compiler Collection includes front ends for C, C++, Objective-C,
    Fortran, Ada, and Go, as well as libraries for these languages."""

    homepage = 'https://gcc.gnu.org'
    url = 'http://ftp.gnu.org/gnu/gcc/gcc-7.1.0/gcc-7.1.0.tar.bz2'
    list_url = 'http://ftp.gnu.org/gnu/gcc/'
    list_depth = 1

    version(
        '8.2.0',
        '64898a165f67e136d802a92e7633bf1b06c85266027e52127ea025bf5fc2291b5e858288aac0bdba246e6cdf7c6ec88bc8e0e7f3f6f1985f4297710cafde56ed'
    )
    version('8.1.0', '65f7c65818dc540b3437605026d329fc')
    version('7.3.0', 'be2da21680f27624f3a87055c4ba5af2')
    version('7.2.0', 'ff370482573133a7fcdd96cd2f552292')
    version('7.1.0', '6bf56a2bca9dac9dbbf8e8d1036964a8')
    version('6.4.0', '11ba51a0cfb8471927f387c8895fe232')
    version('6.3.0', '677a7623c7ef6ab99881bc4e048debb6')
    version('6.2.0', '9768625159663b300ae4de2f4745fcc4')
    version('6.1.0', '8fb6cb98b8459f5863328380fbf06bd1')
    version('5.5.0', '0f70424213b4a1113c04ba66ddda0c1f')
    version('5.4.0', '4c626ac2a83ef30dfb9260e6f59c2b30')
    version('5.3.0', 'c9616fd448f980259c31de613e575719')
    version('5.2.0', 'a51bcfeb3da7dd4c623e27207ed43467')
    version('5.1.0', 'd5525b1127d07d215960e6051c5da35e')
    version('4.9.4', '87c24a4090c1577ba817ec6882602491')
    version('4.9.3', '6f831b4d251872736e8e9cc09746f327')
    version('4.9.2', '4df8ee253b7f3863ad0b86359cd39c43')
    version('4.9.1', 'fddf71348546af523353bd43d34919c1')
    version('4.8.5', '80d2c2982a3392bb0b89673ff136e223')
    version('4.8.4', '5a84a30839b2aca22a2d723de2a626ec')
    version('4.7.4', '4c696da46297de6ae77a82797d2abe28')
    version('4.6.4', 'b407a3d1480c11667f293bfb1f17d1a4')
    version('4.5.4', '27e459c2566b8209ab064570e1b378f7')

    # We specifically do not add 'all' variant here because:
    # (i) Ada, Go, Jit, and Objective-C++ are not default languages.
    # In that respect, the name 'all' is rather misleading.
    # (ii) Languages other than c,c++,fortran are prone to configure bug in GCC
    # For example, 'java' appears to ignore custom location of zlib
    # (iii) meaning of 'all' changes with GCC version, i.e. 'java' is not part
    # of gcc7. Correctly specifying conflicts() and depends_on() in such a
    # case is a PITA.
    variant('languages',
            default='c,c++,fortran',
            values=('ada', 'brig', 'c', 'c++', 'fortran', 'go', 'java', 'jit',
                    'lto', 'objc', 'obj-c++'),
            multi=True,
            description='Compilers and runtime libraries to build')
    variant('binutils', default=False, description='Build via binutils')
    variant('piclibs',
            default=False,
            description='Build PIC versions of libgfortran.a and libstdc++.a')
    variant('strip',
            default=False,
            description='Strip executables to reduce installation size')

    # https://gcc.gnu.org/install/prerequisites.html
    depends_on('[email protected]:')
    depends_on('[email protected]:')
    depends_on('[email protected]:', when='@4.5:')
    depends_on('[email protected]', when='@5:5.9')
    depends_on('[email protected]:', when='@6:')
    depends_on('zlib', when='@6:')
    depends_on('gnat', when='languages=ada')
    depends_on('binutils~libiberty', when='+binutils')
    depends_on('zip', type='build', when='languages=java')

    # TODO: integrate these libraries.
    # depends_on('ppl')
    # depends_on('cloog')

    # https://gcc.gnu.org/install/test.html
    depends_on('[email protected]', type='test')
    depends_on('expect', type='test')
    depends_on('tcl', type='test')
    depends_on('[email protected]:', type='test')
    depends_on('[email protected]:', type='test')

    # See https://golang.org/doc/install/gccgo#Releases
    provides('golang', when='languages=go @4.6:')
    provides('golang@:1', when='languages=go @4.7.1:')
    provides('golang@:1.1', when='languages=go @4.8:')
    provides('golang@:1.1.2', when='languages=go @4.8.2:')
    provides('golang@:1.2', when='languages=go @4.9:')
    provides('golang@:1.4', when='languages=go @5:')
    provides('golang@:1.6.1', when='languages=go @6:')
    provides('golang@:1.8', when='languages=go @7:')

    # For a list of valid languages for a specific release,
    # run the following command in the GCC source directory:
    #    $ grep ^language= gcc/*/config-lang.in
    # See https://gcc.gnu.org/install/configure.html

    # Support for processing BRIG 1.0 files was added in GCC 7
    # BRIG is a binary format for HSAIL:
    # (Heterogeneous System Architecture Intermediate Language).
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=brig', when='@:6')

    # BRIG does not seem to be supported on macOS
    conflicts('languages=brig', when='platform=darwin')

    # GCC 4.8 added a 'c' language. I'm sure C was always built,
    # but this is the first version that accepts 'c' as a valid language.
    conflicts('languages=c', when='@:4.7')

    # GCC 4.6 added support for the Go programming language.
    # See https://gcc.gnu.org/gcc-4.6/changes.html
    conflicts('languages=go', when='@:4.5')

    # Go is not supported on macOS
    conflicts('languages=go', when='platform=darwin')

    # The GCC Java frontend and associated libjava runtime library
    # have been removed from GCC as of GCC 7.
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=java', when='@7:')

    # GCC 5 added the ability to build GCC as a Just-In-Time compiler.
    # See https://gcc.gnu.org/gcc-5/changes.html
    conflicts('languages=jit', when='@:4')

    if sys.platform == 'darwin':
        # Fix parallel build on APFS filesystem
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797
        if macos_version() >= Version('10.13'):
            patch('darwin/apfs.patch', when='@5.5.0,6.1:6.4,7.1:7.3')
            # from homebrew via macports
            # https://trac.macports.org/ticket/56502#no1
            # see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83531
            patch('darwin/headers-10.13-fix.patch', when='@5.5.0')
        patch('darwin/gcc-7.1.0-headerpad.patch', when='@5:')
        patch('darwin/gcc-6.1.0-jit.patch', when='@5:7')
        patch('darwin/gcc-4.9.patch1', when='@4.9.0:4.9.3')
        patch('darwin/gcc-4.9.patch2', when='@4.9.0:4.9.3')

    patch('piclibs.patch', when='+piclibs')
    patch('gcc-backport.patch', when='@4.7:4.9.2,5:5.3')

    # Older versions do not compile with newer versions of glibc
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
    patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
    patch('ucontext_t-java.patch', when='@4.9,5.1:5.4,6.1:6.4 languages=java')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066
    patch('stack_t-4.9.patch', when='@4.9')
    patch('stack_t.patch', when='@5.1:5.4,6.1:6.4,7.1')
    # https://bugs.busybox.net/show_bug.cgi?id=10061
    patch('signal.patch', when='@4.9,5.1:5.4')

    build_directory = 'spack-build'

    def url_for_version(self, version):
        url = 'http://ftp.gnu.org/gnu/gcc/gcc-{0}/gcc-{0}.tar.{1}'
        suffix = 'xz'

        if version < Version('6.4.0') or version == Version('7.1.0'):
            suffix = 'bz2'

        if version == Version('5.5.0'):
            suffix = 'xz'

        return url.format(version, suffix)

    def patch(self):
        spec = self.spec
        prefix = self.spec.prefix

        # Fix a standard header file for OS X Yosemite that
        # is GCC incompatible by replacing non-GCC compliant macros
        if 'yosemite' in spec.architecture:
            if os.path.isfile('/usr/include/dispatch/object.h'):
                new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
                mkdirp(new_dispatch_dir)
                new_header = join_path(new_dispatch_dir, 'object.h')
                shutil.copyfile('/usr/include/dispatch/object.h', new_header)
                filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
                            'typedef void* dispatch_block_t', new_header)

        # Use installed libz
        if self.version >= Version('6'):
            filter_file('@zlibdir@', '-L{0}'.format(spec['zlib'].prefix.lib),
                        'gcc/Makefile.in')
            filter_file('@zlibinc@',
                        '-I{0}'.format(spec['zlib'].prefix.include),
                        'gcc/Makefile.in')

    def configure_args(self):
        spec = self.spec

        # Generic options to compile GCC
        options = [
            '--disable-multilib', '--enable-languages={0}'.format(','.join(
                spec.variants['languages'].value)),
            '--with-mpfr={0}'.format(spec['mpfr'].prefix),
            '--with-gmp={0}'.format(spec['gmp'].prefix), '--enable-lto',
            '--with-quad'
        ]

        # Use installed libz
        if self.version >= Version('6'):
            options.append('--with-system-zlib')

        # Enabling language "jit" requires --enable-host-shared.
        if 'languages=jit' in spec:
            options.append('--enable-host-shared')

        # Binutils
        if spec.satisfies('+binutils'):
            static_bootstrap_flags = '-static-libstdc++ -static-libgcc'
            binutils_options = [
                '--with-sysroot=/',
                '--with-stage1-ldflags={0} {1}'.format(self.rpath_args,
                                                       static_bootstrap_flags),
                '--with-boot-ldflags={0} {1}'.format(self.rpath_args,
                                                     static_bootstrap_flags),
                '--with-gnu-ld',
                '--with-ld={0}/ld'.format(spec['binutils'].prefix.bin),
                '--with-gnu-as',
                '--with-as={0}/as'.format(spec['binutils'].prefix.bin),
            ]
            options.extend(binutils_options)

        # MPC
        if 'mpc' in spec:
            options.append('--with-mpc={0}'.format(spec['mpc'].prefix))

        # ISL
        if 'isl' in spec:
            options.append('--with-isl={0}'.format(spec['isl'].prefix))

        # macOS
        if sys.platform == 'darwin':
            options.append('--with-build-config=bootstrap-debug')

        return options

    @property
    def build_targets(self):
        if sys.platform == 'darwin':
            return ['bootstrap']
        return []

    @property
    def install_targets(self):
        if '+strip' in self.spec:
            return ['install-strip']
        return ['install']

    @property
    def spec_dir(self):
        # e.g. lib/gcc/x86_64-unknown-linux-gnu/4.9.2
        spec_dir = glob.glob('{0}/gcc/*/*'.format(self.prefix.lib))
        return spec_dir[0] if spec_dir else None

    @run_after('install')
    def write_rpath_specs(self):
        """Generate a spec file so the linker adds a rpath to the libs
           the compiler used to build the executable."""
        if not self.spec_dir:
            tty.warn('Could not install specs for {0}.'.format(
                self.spec.format('$_$@')))
            return

        gcc = self.spec['gcc'].command
        lines = gcc('-dumpspecs', output=str).strip().split('\n')
        specs_file = join_path(self.spec_dir, 'specs')
        with open(specs_file, 'w') as out:
            for line in lines:
                out.write(line + '\n')
                if line.startswith('*link:'):
                    out.write('-rpath {0}:{1} '.format(self.prefix.lib,
                                                       self.prefix.lib64))
        set_install_permissions(specs_file)

    def setup_environment(self, spack_env, run_env):
        run_env.set('CC', join_path(self.spec.prefix.bin, 'gcc'))
        run_env.set('CXX', join_path(self.spec.prefix.bin, 'g++'))
        run_env.set('FC', join_path(self.spec.prefix.bin, 'gfortran'))
        run_env.set('F77', join_path(self.spec.prefix.bin, 'gfortran'))
        run_env.set('F90', join_path(self.spec.prefix.bin, 'gfortran'))
Пример #18
0
class Gcc(AutotoolsPackage):
    """The GNU Compiler Collection includes front ends for C, C++, Objective-C,
    Fortran, Ada, and Go, as well as libraries for these languages."""

    homepage = 'https://gcc.gnu.org'
    url = 'https://ftpmirror.gnu.org/gcc/gcc-7.1.0/gcc-7.1.0.tar.bz2'
    svn = 'svn://gcc.gnu.org/svn/gcc/'
    list_url = 'http://ftp.gnu.org/gnu/gcc/'
    list_depth = 1

    version('develop', svn=svn + 'trunk')

    version('9.2.0',
            sha256=
            'ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206')
    version('9.1.0',
            sha256=
            '79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0')

    version('8.3.0',
            sha256=
            '64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c')
    version('8.2.0',
            sha256=
            '196c3c04ba2613f893283977e6011b2345d1cd1af9abeac58e916b1aab3e0080')
    version('8.1.0',
            sha256=
            '1d1866f992626e61349a1ccd0b8d5253816222cdc13390dcfaa74b093aa2b153')

    version('7.4.0',
            sha256=
            'eddde28d04f334aec1604456e536416549e9b1aa137fc69204e65eb0c009fe51')
    version('7.3.0',
            sha256=
            '832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c')
    version('7.2.0',
            sha256=
            '1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a')
    version('7.1.0',
            sha256=
            '8a8136c235f64c6fef69cac0d73a46a1a09bb250776a050aec8f9fc880bebc17')

    version('6.5.0',
            sha256=
            '7ef1796ce497e89479183702635b14bb7a46b53249209a5e0f999bebf4740945')
    version('6.4.0',
            sha256=
            '850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4')
    version('6.3.0',
            sha256=
            'f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f')
    version('6.2.0',
            sha256=
            '9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5')
    version('6.1.0',
            sha256=
            '09c4c85cabebb971b1de732a0219609f93fc0af5f86f6e437fd8d7f832f1a351')

    version('5.5.0',
            sha256=
            '530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87')
    version('5.4.0',
            sha256=
            '608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a')
    version('5.3.0',
            sha256=
            'b84f5592e9218b73dbae612b5253035a7b34a9a1f7688d2e1bfaaf7267d5c4db')
    version('5.2.0',
            sha256=
            '5f835b04b5f7dd4f4d2dc96190ec1621b8d89f2dc6f638f9f8bc1b1014ba8cad')
    version('5.1.0',
            sha256=
            'b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad')

    version('4.9.4',
            sha256=
            '6c11d292cd01b294f9f84c9a59c230d80e9e4a47e5c6355f046bb36d4f358092')
    version('4.9.3',
            sha256=
            '2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e')
    version('4.9.2',
            sha256=
            '2020c98295856aa13fda0f2f3a4794490757fc24bcca918d52cc8b4917b972dd')
    version('4.9.1',
            sha256=
            'd334781a124ada6f38e63b545e2a3b8c2183049515a1abab6d513f109f1d717e')
    version('4.8.5',
            sha256=
            '22fb1e7e0f68a63cee631d85b20461d1ea6bda162f03096350e38c8d427ecf23')
    version('4.8.4',
            sha256=
            '4a80aa23798b8e9b5793494b8c976b39b8d9aa2e53cd5ed5534aff662a7f8695')
    version('4.7.4',
            sha256=
            '92e61c6dc3a0a449e62d72a38185fda550168a86702dea07125ebd3ec3996282')
    version('4.6.4',
            sha256=
            '35af16afa0b67af9b8eb15cafb76d2bc5f568540552522f5dc2c88dd45d977e8')
    version('4.5.4',
            sha256=
            'eef3f0456db8c3d992cbb51d5d32558190bc14f3bc19383dd93acc27acc6befc')

    # We specifically do not add 'all' variant here because:
    # (i) Ada, Go, Jit, and Objective-C++ are not default languages.
    # In that respect, the name 'all' is rather misleading.
    # (ii) Languages other than c,c++,fortran are prone to configure bug in GCC
    # For example, 'java' appears to ignore custom location of zlib
    # (iii) meaning of 'all' changes with GCC version, i.e. 'java' is not part
    # of gcc7. Correctly specifying conflicts() and depends_on() in such a
    # case is a PITA.
    variant('languages',
            default='c,c++,fortran',
            values=('ada', 'brig', 'c', 'c++', 'fortran', 'go', 'java', 'jit',
                    'lto', 'objc', 'obj-c++'),
            multi=True,
            description='Compilers and runtime libraries to build')
    variant('binutils', default=False, description='Build via binutils')
    variant('piclibs',
            default=False,
            description='Build PIC versions of libgfortran.a and libstdc++.a')
    variant('strip',
            default=False,
            description='Strip executables to reduce installation size')
    variant('nvptx',
            default=False,
            description='Target nvptx offloading to NVIDIA GPUs')

    # https://gcc.gnu.org/install/prerequisites.html
    depends_on('[email protected]:')
    # GCC 7.3 does not compile with newer releases on some platforms, see
    #   https://github.com/spack/spack/issues/6902#issuecomment-433030376
    depends_on('[email protected]:3.1.6')
    depends_on('[email protected]:', when='@4.5:')
    # Already released GCC versions do not support any newer version of ISL
    #   GCC 5.4 https://github.com/spack/spack/issues/6902#issuecomment-433072097
    #   GCC 7.3 https://github.com/spack/spack/issues/6902#issuecomment-433030376
    #   GCC 9+  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724
    depends_on('[email protected]', when='@5:5.9')
    depends_on('[email protected]:0.18', when='@6:8.9')
    depends_on('[email protected]:0.20', when='@9:')
    depends_on('zlib', when='@6:')
    depends_on('libiconv', when='platform=darwin')
    depends_on('gnat', when='languages=ada')
    depends_on('binutils~libiberty', when='+binutils')
    depends_on('zip', type='build', when='languages=java')
    depends_on('cuda', when='+nvptx')

    resource(
        name='newlib',
        url='ftp://sourceware.org/pub/newlib/newlib-3.0.0.20180831.tar.gz',
        sha256=
        '3ad3664f227357df15ff34e954bfd9f501009a647667cd307bf0658aefd6eb5b',
        destination='newlibsource',
        when='+nvptx')

    # nvptx-tools does not seem to work as a dependency,
    # but does fine when the source is inside the gcc build directory
    # nvptx-tools doesn't have any releases, so grabbing the last commit
    resource(name='nvptx-tools',
             git='https://github.com/MentorEmbedded/nvptx-tools',
             commit='5f6f343a302d620b0868edab376c00b15741e39e',
             when='+nvptx')

    # TODO: integrate these libraries.
    # depends_on('ppl')
    # depends_on('cloog')

    # https://gcc.gnu.org/install/test.html
    depends_on('[email protected]', type='test')
    depends_on('expect', type='test')
    depends_on('tcl', type='test')
    depends_on('[email protected]:', type='test')
    depends_on('[email protected]:', type='test')

    # See https://golang.org/doc/install/gccgo#Releases
    provides('golang', when='languages=go @4.6:')
    provides('golang@:1', when='languages=go @4.7.1:')
    provides('golang@:1.1', when='languages=go @4.8:')
    provides('golang@:1.1.2', when='languages=go @4.8.2:')
    provides('golang@:1.2', when='languages=go @4.9:')
    provides('golang@:1.4', when='languages=go @5:')
    provides('golang@:1.6.1', when='languages=go @6:')
    provides('golang@:1.8', when='languages=go @7:')

    # For a list of valid languages for a specific release,
    # run the following command in the GCC source directory:
    #    $ grep ^language= gcc/*/config-lang.in
    # See https://gcc.gnu.org/install/configure.html

    # Support for processing BRIG 1.0 files was added in GCC 7
    # BRIG is a binary format for HSAIL:
    # (Heterogeneous System Architecture Intermediate Language).
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=brig', when='@:6')

    # BRIG does not seem to be supported on macOS
    conflicts('languages=brig', when='platform=darwin')

    # GCC 4.8 added a 'c' language. I'm sure C was always built,
    # but this is the first version that accepts 'c' as a valid language.
    conflicts('languages=c', when='@:4.7')

    # GCC 4.6 added support for the Go programming language.
    # See https://gcc.gnu.org/gcc-4.6/changes.html
    conflicts('languages=go', when='@:4.5')

    # Go is not supported on macOS
    conflicts('languages=go', when='platform=darwin')

    # The GCC Java frontend and associated libjava runtime library
    # have been removed from GCC as of GCC 7.
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=java', when='@7:')

    # GCC 5 added the ability to build GCC as a Just-In-Time compiler.
    # See https://gcc.gnu.org/gcc-5/changes.html
    conflicts('languages=jit', when='@:4')

    # NVPTX offloading supported in 7 and later by limited languages
    conflicts('+nvptx',
              when='@:6',
              msg='NVPTX only supported in gcc 7 and above')
    conflicts('languages=ada', when='+nvptx')
    conflicts('languages=brig', when='+nvptx')
    conflicts('languages=go', when='+nvptx')
    conflicts('languages=java', when='+nvptx')
    conflicts('languages=jit', when='+nvptx')
    conflicts('languages=objc', when='+nvptx')
    conflicts('languages=obj-c++', when='+nvptx')

    if sys.platform == 'darwin':
        # Fix parallel build on APFS filesystem
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797
        if macos_version() >= Version('10.13'):
            patch('darwin/apfs.patch', when='@5.5.0,6.1:6.4,7.1:7.3')
            # from homebrew via macports
            # https://trac.macports.org/ticket/56502#no1
            # see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83531
            patch('darwin/headers-10.13-fix.patch', when='@5.5.0')
        if macos_version() >= Version('10.15'):
            # Fix system headers for Catalina SDK
            # (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
            patch(
                'https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/9.2.0-catalina.patch',
                sha256=
                '0b8d14a7f3c6a2f0d2498526e86e088926671b5da50a554ffa6b7f73ac4f132b',
                when='@9.2.0:')
        # Use -headerpad_max_install_names in the build,
        # otherwise updated load commands won't fit in the Mach-O header.
        # This is needed because `gcc` avoids the superenv shim.
        patch('darwin/gcc-7.1.0-headerpad.patch', when='@5:')
        patch('darwin/gcc-6.1.0-jit.patch', when='@5:7')
        patch('darwin/gcc-4.9.patch1', when='@4.9.0:4.9.3')
        patch('darwin/gcc-4.9.patch2', when='@4.9.0:4.9.3')

    patch('piclibs.patch', when='+piclibs')
    patch('gcc-backport.patch', when='@4.7:4.9.3,5:5.3')

    # Older versions do not compile with newer versions of glibc
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
    patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
    patch('ucontext_t-java.patch', when='@4.9,5.1:5.4,6.1:6.4 languages=java')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066
    patch('stack_t-4.9.patch', when='@4.9')
    patch('stack_t.patch', when='@5.1:5.4,6.1:6.4,7.1')
    # https://bugs.busybox.net/show_bug.cgi?id=10061
    patch('signal.patch', when='@4.9,5.1:5.4')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85835
    patch('sys_ustat.h.patch', when='@5.0:6.4,7.0:7.3,8.1')
    patch('sys_ustat-4.9.patch', when='@4.9')

    build_directory = 'spack-build'

    def url_for_version(self, version):
        url = 'https://ftpmirror.gnu.org/gcc/gcc-{0}/gcc-{0}.tar.{1}'
        suffix = 'xz'

        if version < Version('6.4.0') or version == Version('7.1.0'):
            suffix = 'bz2'

        if version == Version('5.5.0'):
            suffix = 'xz'

        return url.format(version, suffix)

    def patch(self):
        spec = self.spec
        prefix = self.spec.prefix

        # Fix a standard header file for OS X Yosemite that
        # is GCC incompatible by replacing non-GCC compliant macros
        if 'yosemite' in spec.architecture:
            if os.path.isfile('/usr/include/dispatch/object.h'):
                new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
                mkdirp(new_dispatch_dir)
                new_header = join_path(new_dispatch_dir, 'object.h')
                install('/usr/include/dispatch/object.h', new_header)
                filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
                            'typedef void* dispatch_block_t', new_header)

        # Use installed libz
        if self.version >= Version('6'):
            filter_file('@zlibdir@', '-L{0}'.format(spec['zlib'].prefix.lib),
                        'gcc/Makefile.in')
            filter_file('@zlibinc@',
                        '-I{0}'.format(spec['zlib'].prefix.include),
                        'gcc/Makefile.in')

    # https://gcc.gnu.org/install/configure.html
    def configure_args(self):
        spec = self.spec

        # Generic options to compile GCC
        options = [
            # Distributor options
            '--with-pkgversion=Spack GCC',
            '--with-bugurl=https://github.com/spack/spack/issues',
            # Xcode 10 dropped 32-bit support
            '--disable-multilib',
            '--enable-languages={0}'.format(','.join(
                spec.variants['languages'].value)),
            # Drop gettext dependency
            '--disable-nls',
            '--with-mpfr={0}'.format(spec['mpfr'].prefix),
            '--with-gmp={0}'.format(spec['gmp'].prefix),
        ]

        # Use installed libz
        if self.version >= Version('6'):
            options.append('--with-system-zlib')

        # Enabling language "jit" requires --enable-host-shared.
        if 'languages=jit' in spec:
            options.append('--enable-host-shared')

        # Binutils
        if spec.satisfies('+binutils'):
            static_bootstrap_flags = '-static-libstdc++ -static-libgcc'
            options.extend([
                '--with-sysroot=/',
                '--with-stage1-ldflags={0} {1}'.format(self.rpath_args,
                                                       static_bootstrap_flags),
                '--with-boot-ldflags={0} {1}'.format(self.rpath_args,
                                                     static_bootstrap_flags),
                '--with-gnu-ld',
                '--with-ld={0}/ld'.format(spec['binutils'].prefix.bin),
                '--with-gnu-as',
                '--with-as={0}/as'.format(spec['binutils'].prefix.bin),
            ])

        # MPC
        if 'mpc' in spec:
            options.append('--with-mpc={0}'.format(spec['mpc'].prefix))

        # ISL
        if 'isl' in spec:
            options.append('--with-isl={0}'.format(spec['isl'].prefix))

        # nvptx-none offloading for host compiler
        if spec.satisfies('+nvptx'):
            options.extend([
                '--enable-offload-targets=nvptx-none',
                '--with-cuda-driver-include={0}'.format(
                    spec['cuda'].prefix.include),
                '--with-cuda-driver-lib={0}'.format(
                    spec['cuda'].libs.directories[0]), '--disable-bootstrap',
                '--disable-multilib'
            ])

        if sys.platform == 'darwin':
            options.extend([
                '--with-native-system-header-dir=/usr/include',
                '--with-sysroot={0}'.format(macos_sdk_path()),
                '--with-libiconv-prefix={0}'.format(spec['libiconv'].prefix)
            ])

        return options

    # run configure/make/make(install) for the nvptx-none target
    # before running the host compiler phases
    @run_before('configure')
    def nvptx_install(self):
        spec = self.spec
        prefix = self.prefix

        if not spec.satisfies('+nvptx'):
            return

        # config.guess returns the host triple, e.g. "x86_64-pc-linux-gnu"
        guess = Executable('./config.guess')
        targetguess = guess(output=str).rstrip('\n')

        options = getattr(self, 'configure_flag_args', [])
        options += ['--prefix={0}'.format(prefix)]

        options += [
            '--with-cuda-driver-include={0}'.format(
                spec['cuda'].prefix.include),
            '--with-cuda-driver-lib={0}'.format(
                spec['cuda'].libs.directories[0]),
        ]

        with working_dir('nvptx-tools'):
            configure = Executable("./configure")
            configure(*options)
            make()
            make('install')

        pattern = join_path(self.stage.source_path, 'newlibsource', '*')
        files = glob.glob(pattern)

        if files:
            symlink(join_path(files[0], 'newlib'), 'newlib')

        # self.build_directory = 'spack-build-nvptx'
        with working_dir('spack-build-nvptx', create=True):

            options = [
                '--prefix={0}'.format(prefix),
                '--enable-languages={0}'.format(','.join(
                    spec.variants['languages'].value)),
                '--with-mpfr={0}'.format(spec['mpfr'].prefix),
                '--with-gmp={0}'.format(spec['gmp'].prefix),
                '--target=nvptx-none',
                '--with-build-time-tools={0}'.format(
                    join_path(prefix, 'nvptx-none', 'bin')),
                '--enable-as-accelerator-for={0}'.format(targetguess),
                '--disable-sjlj-exceptions',
                '--enable-newlib-io-long-long',
            ]

            configure = Executable("../configure")
            configure(*options)
            make()
            make('install')

    @property
    def install_targets(self):
        if '+strip' in self.spec:
            return ['install-strip']
        return ['install']

    @property
    def spec_dir(self):
        # e.g. lib/gcc/x86_64-unknown-linux-gnu/4.9.2
        spec_dir = glob.glob('{0}/gcc/*/*'.format(self.prefix.lib))
        return spec_dir[0] if spec_dir else None

    @run_after('install')
    def write_rpath_specs(self):
        """Generate a spec file so the linker adds a rpath to the libs
           the compiler used to build the executable."""
        if not self.spec_dir:
            tty.warn('Could not install specs for {0}.'.format(
                self.spec.format('{name}{@version}')))
            return

        gcc = self.spec['gcc'].command
        lines = gcc('-dumpspecs', output=str).strip().split('\n')
        specs_file = join_path(self.spec_dir, 'specs')
        with open(specs_file, 'w') as out:
            for line in lines:
                out.write(line + '\n')
                if line.startswith('*link:'):
                    out.write('-rpath {0}:{1} '.format(self.prefix.lib,
                                                       self.prefix.lib64))
        set_install_permissions(specs_file)

    def setup_run_environment(self, env):
        # Search prefix directory for possibly modified compiler names
        from spack.compilers.gcc import Gcc as Compiler

        # Get the contents of the installed binary directory
        bin_path = self.spec.prefix.bin

        if not os.path.isdir(bin_path):
            return

        bin_contents = os.listdir(bin_path)

        # Find the first non-symlink compiler binary present for each language
        for lang in ['cc', 'cxx', 'fc', 'f77']:
            for filename, regexp in itertools.product(
                    bin_contents, Compiler.search_regexps(lang)):
                if not regexp.match(filename):
                    continue

                abspath = os.path.join(bin_path, filename)
                if os.path.islink(abspath):
                    continue

                # Set the proper environment variable
                env.set(lang.upper(), abspath)
                # Stop searching filename/regex combos for this language
                break
Пример #19
0
class Gcc(AutotoolsPackage):
    """The GNU Compiler Collection includes front ends for C, C++, Objective-C,
    Fortran, Ada, and Go, as well as libraries for these languages."""

    homepage = 'https://gcc.gnu.org'
    url = 'https://ftpmirror.gnu.org/gcc/gcc-7.1.0/gcc-7.1.0.tar.bz2'
    svn = 'svn://gcc.gnu.org/svn/gcc/'
    list_url = 'http://ftp.gnu.org/gnu/gcc/'
    list_depth = 1

    version('develop', svn=svn + 'trunk')

    version(
        '9.1.0',
        'b6134df027e734cee5395afd739fcfa4ea319a6017d662e54e89df927dea19d3fff7a6e35d676685383034e3db01c9d0b653f63574c274eeb15a2cb0bc7a1f28'
    )

    version(
        '8.3.0',
        '1811337ae3add9680cec64968a2509d085b6dc5b6783fc1e8c295e3e47416196fd1a3ad8dfe7e10be2276b4f62c357659ce2902f239f60a8648548231b4b5802'
    )
    version(
        '8.2.0',
        '64898a165f67e136d802a92e7633bf1b06c85266027e52127ea025bf5fc2291b5e858288aac0bdba246e6cdf7c6ec88bc8e0e7f3f6f1985f4297710cafde56ed'
    )
    version('8.1.0', '65f7c65818dc540b3437605026d329fc')

    version(
        '7.4.0',
        'eddde28d04f334aec1604456e536416549e9b1aa137fc69204e65eb0c009fe51')
    version('7.3.0', 'be2da21680f27624f3a87055c4ba5af2')
    version('7.2.0', 'ff370482573133a7fcdd96cd2f552292')
    version('7.1.0', '6bf56a2bca9dac9dbbf8e8d1036964a8')

    version(
        '6.5.0',
        '7ef1796ce497e89479183702635b14bb7a46b53249209a5e0f999bebf4740945')
    version('6.4.0', '11ba51a0cfb8471927f387c8895fe232')
    version('6.3.0', '677a7623c7ef6ab99881bc4e048debb6')
    version('6.2.0', '9768625159663b300ae4de2f4745fcc4')
    version('6.1.0', '8fb6cb98b8459f5863328380fbf06bd1')

    version('5.5.0', '0f70424213b4a1113c04ba66ddda0c1f')
    version('5.4.0', '4c626ac2a83ef30dfb9260e6f59c2b30')
    version('5.3.0', 'c9616fd448f980259c31de613e575719')
    version('5.2.0', 'a51bcfeb3da7dd4c623e27207ed43467')
    version('5.1.0', 'd5525b1127d07d215960e6051c5da35e')

    version('4.9.4', '87c24a4090c1577ba817ec6882602491')
    version('4.9.3', '6f831b4d251872736e8e9cc09746f327')
    version('4.9.2', '4df8ee253b7f3863ad0b86359cd39c43')
    version('4.9.1', 'fddf71348546af523353bd43d34919c1')
    version('4.8.5', '80d2c2982a3392bb0b89673ff136e223')
    version('4.8.4', '5a84a30839b2aca22a2d723de2a626ec')
    version('4.7.4', '4c696da46297de6ae77a82797d2abe28')
    version('4.6.4', 'b407a3d1480c11667f293bfb1f17d1a4')
    version('4.5.4', '27e459c2566b8209ab064570e1b378f7')

    # We specifically do not add 'all' variant here because:
    # (i) Ada, Go, Jit, and Objective-C++ are not default languages.
    # In that respect, the name 'all' is rather misleading.
    # (ii) Languages other than c,c++,fortran are prone to configure bug in GCC
    # For example, 'java' appears to ignore custom location of zlib
    # (iii) meaning of 'all' changes with GCC version, i.e. 'java' is not part
    # of gcc7. Correctly specifying conflicts() and depends_on() in such a
    # case is a PITA.
    variant('languages',
            default='c,c++,fortran',
            values=('ada', 'brig', 'c', 'c++', 'fortran', 'go', 'java', 'jit',
                    'lto', 'objc', 'obj-c++'),
            multi=True,
            description='Compilers and runtime libraries to build')
    variant('binutils', default=False, description='Build via binutils')
    variant('piclibs',
            default=False,
            description='Build PIC versions of libgfortran.a and libstdc++.a')
    variant('strip',
            default=False,
            description='Strip executables to reduce installation size')
    variant('nvptx',
            default=False,
            description='Target nvptx offloading to NVIDIA GPUs')

    # https://gcc.gnu.org/install/prerequisites.html
    depends_on('[email protected]:')
    # GCC 7.3 does not compile with newer releases on some platforms, see
    #   https://github.com/spack/spack/issues/6902#issuecomment-433030376
    depends_on('[email protected]:3.1.6')
    depends_on('[email protected]:', when='@4.5:')
    # Already released GCC versions do not support any newer version of ISL
    #   GCC 5.4 https://github.com/spack/spack/issues/6902#issuecomment-433072097
    #   GCC 7.3 https://github.com/spack/spack/issues/6902#issuecomment-433030376
    #   GCC 9+  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724
    depends_on('[email protected]', when='@5:5.9')
    depends_on('[email protected]:0.18', when='@6:8.9')
    depends_on('[email protected]:0.20', when='@9:')
    depends_on('zlib', when='@6:')
    depends_on('gnat', when='languages=ada')
    depends_on('binutils~libiberty', when='+binutils')
    depends_on('zip', type='build', when='languages=java')
    depends_on('cuda', when='+nvptx')

    resource(
        name='newlib',
        url='ftp://sourceware.org/pub/newlib/newlib-3.0.0.20180831.tar.gz',
        sha256=
        '3ad3664f227357df15ff34e954bfd9f501009a647667cd307bf0658aefd6eb5b',
        destination='newlibsource',
        when='+nvptx')

    # nvptx-tools does not seem to work as a dependency,
    # but does fine when the source is inside the gcc build directory
    # nvptx-tools doesn't have any releases, so grabbing the last commit
    resource(name='nvptx-tools',
             git='https://github.com/MentorEmbedded/nvptx-tools',
             commit='5f6f343a302d620b0868edab376c00b15741e39e',
             when='+nvptx')

    # TODO: integrate these libraries.
    # depends_on('ppl')
    # depends_on('cloog')

    # https://gcc.gnu.org/install/test.html
    depends_on('[email protected]', type='test')
    depends_on('expect', type='test')
    depends_on('tcl', type='test')
    depends_on('[email protected]:', type='test')
    depends_on('[email protected]:', type='test')

    # See https://golang.org/doc/install/gccgo#Releases
    provides('golang', when='languages=go @4.6:')
    provides('golang@:1', when='languages=go @4.7.1:')
    provides('golang@:1.1', when='languages=go @4.8:')
    provides('golang@:1.1.2', when='languages=go @4.8.2:')
    provides('golang@:1.2', when='languages=go @4.9:')
    provides('golang@:1.4', when='languages=go @5:')
    provides('golang@:1.6.1', when='languages=go @6:')
    provides('golang@:1.8', when='languages=go @7:')

    # For a list of valid languages for a specific release,
    # run the following command in the GCC source directory:
    #    $ grep ^language= gcc/*/config-lang.in
    # See https://gcc.gnu.org/install/configure.html

    # Support for processing BRIG 1.0 files was added in GCC 7
    # BRIG is a binary format for HSAIL:
    # (Heterogeneous System Architecture Intermediate Language).
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=brig', when='@:6')

    # BRIG does not seem to be supported on macOS
    conflicts('languages=brig', when='platform=darwin')

    # GCC 4.8 added a 'c' language. I'm sure C was always built,
    # but this is the first version that accepts 'c' as a valid language.
    conflicts('languages=c', when='@:4.7')

    # GCC 4.6 added support for the Go programming language.
    # See https://gcc.gnu.org/gcc-4.6/changes.html
    conflicts('languages=go', when='@:4.5')

    # Go is not supported on macOS
    conflicts('languages=go', when='platform=darwin')

    # The GCC Java frontend and associated libjava runtime library
    # have been removed from GCC as of GCC 7.
    # See https://gcc.gnu.org/gcc-7/changes.html
    conflicts('languages=java', when='@7:')

    # GCC 5 added the ability to build GCC as a Just-In-Time compiler.
    # See https://gcc.gnu.org/gcc-5/changes.html
    conflicts('languages=jit', when='@:4')

    # NVPTX offloading supported in 7 and later by limited languages
    conflicts('+nvptx',
              when='@:6',
              msg='NVPTX only supported in gcc 7 and above')
    conflicts('languages=ada', when='+nvptx')
    conflicts('languages=brig', when='+nvptx')
    conflicts('languages=go', when='+nvptx')
    conflicts('languages=java', when='+nvptx')
    conflicts('languages=jit', when='+nvptx')
    conflicts('languages=objc', when='+nvptx')
    conflicts('languages=obj-c++', when='+nvptx')

    if sys.platform == 'darwin':
        # Fix parallel build on APFS filesystem
        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797
        if macos_version() >= Version('10.13'):
            patch('darwin/apfs.patch', when='@5.5.0,6.1:6.4,7.1:7.3')
            # from homebrew via macports
            # https://trac.macports.org/ticket/56502#no1
            # see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83531
            patch('darwin/headers-10.13-fix.patch', when='@5.5.0')
        patch('darwin/gcc-7.1.0-headerpad.patch', when='@5:')
        patch('darwin/gcc-6.1.0-jit.patch', when='@5:7')
        patch('darwin/gcc-4.9.patch1', when='@4.9.0:4.9.3')
        patch('darwin/gcc-4.9.patch2', when='@4.9.0:4.9.3')

    patch('piclibs.patch', when='+piclibs')
    patch('gcc-backport.patch', when='@4.7:4.9.2,5:5.3')

    # Older versions do not compile with newer versions of glibc
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
    patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
    patch('ucontext_t-java.patch', when='@4.9,5.1:5.4,6.1:6.4 languages=java')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066
    patch('stack_t-4.9.patch', when='@4.9')
    patch('stack_t.patch', when='@5.1:5.4,6.1:6.4,7.1')
    # https://bugs.busybox.net/show_bug.cgi?id=10061
    patch('signal.patch', when='@4.9,5.1:5.4')
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85835
    patch('sys_ustat.h.patch', when='@5.0:6.4,7.0:7.3,8.1')
    patch('sys_ustat-4.9.patch', when='@4.9')

    build_directory = 'spack-build'

    def url_for_version(self, version):
        url = 'https://ftpmirror.gnu.org/gcc/gcc-{0}/gcc-{0}.tar.{1}'
        suffix = 'xz'

        if version < Version('6.4.0') or version == Version('7.1.0'):
            suffix = 'bz2'

        if version == Version('5.5.0'):
            suffix = 'xz'

        return url.format(version, suffix)

    def patch(self):
        spec = self.spec
        prefix = self.spec.prefix

        # Fix a standard header file for OS X Yosemite that
        # is GCC incompatible by replacing non-GCC compliant macros
        if 'yosemite' in spec.architecture:
            if os.path.isfile('/usr/include/dispatch/object.h'):
                new_dispatch_dir = join_path(prefix, 'include', 'dispatch')
                mkdirp(new_dispatch_dir)
                new_header = join_path(new_dispatch_dir, 'object.h')
                install('/usr/include/dispatch/object.h', new_header)
                filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)',
                            'typedef void* dispatch_block_t', new_header)

        # Use installed libz
        if self.version >= Version('6'):
            filter_file('@zlibdir@', '-L{0}'.format(spec['zlib'].prefix.lib),
                        'gcc/Makefile.in')
            filter_file('@zlibinc@',
                        '-I{0}'.format(spec['zlib'].prefix.include),
                        'gcc/Makefile.in')

    def configure_args(self):
        spec = self.spec

        # Generic options to compile GCC
        options = [
            '--disable-multilib', '--enable-languages={0}'.format(','.join(
                spec.variants['languages'].value)),
            '--with-mpfr={0}'.format(spec['mpfr'].prefix),
            '--with-gmp={0}'.format(spec['gmp'].prefix), '--enable-lto',
            '--with-quad'
        ]

        # Use installed libz
        if self.version >= Version('6'):
            options.append('--with-system-zlib')

        # Enabling language "jit" requires --enable-host-shared.
        if 'languages=jit' in spec:
            options.append('--enable-host-shared')

        # Binutils
        if spec.satisfies('+binutils'):
            static_bootstrap_flags = '-static-libstdc++ -static-libgcc'
            binutils_options = [
                '--with-sysroot=/',
                '--with-stage1-ldflags={0} {1}'.format(self.rpath_args,
                                                       static_bootstrap_flags),
                '--with-boot-ldflags={0} {1}'.format(self.rpath_args,
                                                     static_bootstrap_flags),
                '--with-gnu-ld',
                '--with-ld={0}/ld'.format(spec['binutils'].prefix.bin),
                '--with-gnu-as',
                '--with-as={0}/as'.format(spec['binutils'].prefix.bin),
            ]
            options.extend(binutils_options)

        # MPC
        if 'mpc' in spec:
            options.append('--with-mpc={0}'.format(spec['mpc'].prefix))

        # ISL
        if 'isl' in spec:
            options.append('--with-isl={0}'.format(spec['isl'].prefix))

        # macOS
        if sys.platform == 'darwin':
            options.append('--with-build-config=bootstrap-debug')

        # nvptx-none offloading for host compiler
        if spec.satisfies('+nvptx'):
            options.extend([
                '--enable-offload-targets=nvptx-none',
                '--with-cuda-driver-include={0}'.format(
                    spec['cuda'].prefix.include),
                '--with-cuda-driver-lib={0}'.format(
                    spec['cuda'].libs.directories[0]), '--disable-bootstrap',
                '--disable-multilib'
            ])

        if sys.platform == 'darwin':
            options.extend([
                '--with-native-system-header-dir=/usr/include',
                '--with-sysroot={0}'.format(macos_sdk_path())
            ])

        return options

    # run configure/make/make(install) for the nvptx-none target
    # before running the host compiler phases
    @run_before('configure')
    def nvptx_install(self):
        spec = self.spec
        prefix = self.prefix

        if not spec.satisfies('+nvptx'):
            return

        # config.guess returns the host triple, e.g. "x86_64-pc-linux-gnu"
        guess = Executable('./config.guess')
        targetguess = guess(output=str).rstrip('\n')

        options = getattr(self, 'configure_flag_args', [])
        options += ['--prefix={0}'.format(prefix)]

        options += [
            '--with-cuda-driver-include={0}'.format(
                spec['cuda'].prefix.include),
            '--with-cuda-driver-lib={0}'.format(
                spec['cuda'].libs.directories[0]),
        ]

        with working_dir('nvptx-tools'):
            configure = Executable("./configure")
            configure(*options)
            make()
            make('install')

        pattern = join_path(self.stage.source_path, 'newlibsource', '*')
        files = glob.glob(pattern)

        if files:
            symlink(join_path(files[0], 'newlib'), 'newlib')

        # self.build_directory = 'spack-build-nvptx'
        with working_dir('spack-build-nvptx', create=True):

            options = [
                '--prefix={0}'.format(prefix),
                '--enable-languages={0}'.format(','.join(
                    spec.variants['languages'].value)),
                '--with-mpfr={0}'.format(spec['mpfr'].prefix),
                '--with-gmp={0}'.format(spec['gmp'].prefix),
                '--target=nvptx-none',
                '--with-build-time-tools={0}'.format(
                    join_path(prefix, 'nvptx-none', 'bin')),
                '--enable-as-accelerator-for={0}'.format(targetguess),
                '--disable-sjlj-exceptions',
                '--enable-newlib-io-long-long',
            ]

            configure = Executable("../configure")
            configure(*options)
            make()
            make('install')

    @property
    def build_targets(self):
        if sys.platform == 'darwin':
            return ['bootstrap']
        return []

    @property
    def install_targets(self):
        if '+strip' in self.spec:
            return ['install-strip']
        return ['install']

    @property
    def spec_dir(self):
        # e.g. lib/gcc/x86_64-unknown-linux-gnu/4.9.2
        spec_dir = glob.glob('{0}/gcc/*/*'.format(self.prefix.lib))
        return spec_dir[0] if spec_dir else None

    @run_after('install')
    def write_rpath_specs(self):
        """Generate a spec file so the linker adds a rpath to the libs
           the compiler used to build the executable."""
        if not self.spec_dir:
            tty.warn('Could not install specs for {0}.'.format(
                self.spec.format('{name}{@version}')))
            return

        gcc = self.spec['gcc'].command
        lines = gcc('-dumpspecs', output=str).strip().split('\n')
        specs_file = join_path(self.spec_dir, 'specs')
        with open(specs_file, 'w') as out:
            for line in lines:
                out.write(line + '\n')
                if line.startswith('*link:'):
                    out.write('-rpath {0}:{1} '.format(self.prefix.lib,
                                                       self.prefix.lib64))
        set_install_permissions(specs_file)

    def setup_environment(self, spack_env, run_env):
        run_env.set('CC', join_path(self.spec.prefix.bin, 'gcc'))
        run_env.set('CXX', join_path(self.spec.prefix.bin, 'g++'))
        run_env.set('FC', join_path(self.spec.prefix.bin, 'gfortran'))
        run_env.set('F77', join_path(self.spec.prefix.bin, 'gfortran'))
        run_env.set('F90', join_path(self.spec.prefix.bin, 'gfortran'))
Пример #20
0
 def setup_build_environment(self, env):
     if (self.spec.platform == 'darwin'
             and macos_version() >= Version('11')):
         # Many configure files rely on matching '10.*' for macOS version
         # detection and fail to add flags if it shows as version 11.
         env.set('MACOSX_DEPLOYMENT_TARGET', '10.16')
Пример #21
0
class PyTorch(PythonPackage, CudaPackage):
    """Tensors and Dynamic neural networks in Python
    with strong GPU acceleration."""

    homepage = "https://pytorch.org/"
    git = "https://github.com/pytorch/pytorch.git"

    maintainers = ['adamjstewart']

    # Exact set of modules is version- and variant-specific, just attempt to import the
    # core libraries to ensure that the package was successfully installed.
    import_modules = ['torch', 'torch.autograd', 'torch.nn', 'torch.utils']

    version('master', branch='master', submodules=True)
    version('1.12.0', tag='v1.12.0', submodules=True)
    version('1.11.0', tag='v1.11.0', submodules=True)
    version('1.10.2', tag='v1.10.2', submodules=True)
    version('1.10.1', tag='v1.10.1', submodules=True)
    version('1.10.0', tag='v1.10.0', submodules=True)
    version('1.9.1', tag='v1.9.1', submodules=True)
    version('1.9.0', tag='v1.9.0', submodules=True)
    version('1.8.2', tag='v1.8.2', submodules=True)
    version('1.8.1', tag='v1.8.1', submodules=True)
    version('1.8.0', tag='v1.8.0', submodules=True)
    version('1.7.1', tag='v1.7.1', submodules=True)
    version('1.7.0', tag='v1.7.0', submodules=True)
    version('1.6.0', tag='v1.6.0', submodules=True)
    version('1.5.1', tag='v1.5.1', submodules=True)
    version('1.5.0', tag='v1.5.0', submodules=True)
    version('1.4.1', tag='v1.4.1', submodules=True)
    version('1.3.1', tag='v1.3.1', submodules=True)
    version('1.3.0', tag='v1.3.0', submodules=True)
    version('1.2.0', tag='v1.2.0', submodules=True)
    version('1.1.0', tag='v1.1.0', submodules=True)
    version('1.0.1', tag='v1.0.1', submodules=True)
    version('1.0.0', tag='v1.0.0', submodules=True)

    is_darwin = sys.platform == 'darwin'

    # All options are defined in CMakeLists.txt.
    # Some are listed in setup.py, but not all.
    variant('debug', default=False, description="Build with debugging support")
    variant('caffe2', default=True, description='Build Caffe2', when='@1.7:')
    variant('test', default=False, description='Build C++ test binaries')
    variant('cuda', default=not is_darwin, description='Use CUDA')
    variant('rocm', default=False, description='Use ROCm')
    variant('cudnn',
            default=not is_darwin,
            description='Use cuDNN',
            when='+cuda')
    variant('fbgemm',
            default=True,
            description='Use FBGEMM (quantized 8-bit server operators)')
    variant('kineto',
            default=True,
            description='Use Kineto profiling library',
            when='@1.8:')
    variant('magma',
            default=not is_darwin,
            description='Use MAGMA',
            when='+cuda')
    variant('metal',
            default=is_darwin,
            description='Use Metal for Caffe2 iOS build')
    variant('mps',
            default=is_darwin and macos_version() >= Version('12.3'),
            description='Use MPS for macOS build',
            when='@1.12: platform=darwin')
    variant('nccl',
            default=True,
            description='Use NCCL',
            when='+cuda platform=linux')
    variant('nccl',
            default=True,
            description='Use NCCL',
            when='+cuda platform=cray')
    variant('nccl',
            default=True,
            description='Use NCCL',
            when='+rocm platform=linux')
    variant('nccl',
            default=True,
            description='Use NCCL',
            when='+rocm platform=cray')
    variant('nnpack', default=True, description='Use NNPACK')
    variant('numa',
            default=True,
            description='Use NUMA',
            when='platform=linux')
    variant('numa', default=True, description='Use NUMA', when='platform=cray')
    variant('numpy', default=True, description='Use NumPy')
    variant('openmp', default=True, description='Use OpenMP for parallel code')
    variant('qnnpack',
            default=True,
            description='Use QNNPACK (quantized 8-bit operators)')
    variant('valgrind',
            default=True,
            description='Use Valgrind',
            when='@1.8: platform=linux')
    variant('valgrind',
            default=True,
            description='Use Valgrind',
            when='@1.8: platform=cray')
    variant('xnnpack', default=True, description='Use XNNPACK', when='@1.5:')
    variant('mkldnn', default=True, description='Use MKLDNN')
    variant('distributed',
            default=not is_darwin,
            description='Use distributed')
    variant('mpi',
            default=not is_darwin,
            description='Use MPI for Caffe2',
            when='+distributed')
    variant('gloo',
            default=not is_darwin,
            description='Use Gloo',
            when='+distributed')
    variant('tensorpipe',
            default=not is_darwin,
            description='Use TensorPipe',
            when='@1.6: +distributed')
    variant('onnx_ml',
            default=True,
            description='Enable traditional ONNX ML API',
            when='@1.5:')
    variant('breakpad',
            default=True,
            description='Enable breakpad crash dump library',
            when='@1.9:1.11')

    conflicts('+cuda+rocm')
    conflicts('+breakpad', when='target=ppc64:')
    conflicts('+breakpad', when='target=ppc64le:')

    # https://github.com/pytorch/pytorch/issues/77811
    conflicts('+qnnpack', when='platform=darwin target=aarch64:')

    conflicts('cuda_arch=none',
              when='+cuda',
              msg='Must specify CUDA compute capabilities of your GPU, see '
              'https://developer.nvidia.com/cuda-gpus')

    # Required dependencies
    depends_on('[email protected]:', when='@1.11:', type='build')
    depends_on('[email protected]:', when='@1.10:', type='build')
    depends_on('[email protected]:', type='build')
    # Use Ninja generator to speed up build times, automatically used if found
    depends_on('[email protected]:', when='@1.1:', type='build')
    # See python_min_version in setup.py
    depends_on('[email protected]:', when='@1.11:', type=('build', 'link', 'run'))
    depends_on('[email protected]:', when='@1.7.1:', type=('build', 'link', 'run'))
    depends_on('[email protected]:',
               when='@1.6:1.7.0',
               type=('build', 'link', 'run'))
    depends_on('[email protected]:', when='@1.5', type=('build', 'link', 'run'))
    depends_on('[email protected]:2,3.5:', when='@1.4', type=('build', 'link', 'run'))
    depends_on('[email protected]:2,3.5:3.7',
               when='@:1.3',
               type=('build', 'link', 'run'))
    depends_on('py-setuptools', type=('build', 'run'))
    depends_on('py-future', when='@1.5:', type=('build', 'run'))
    depends_on('py-future', when='@1.1: ^python@:2', type=('build', 'run'))
    depends_on('py-pyyaml', type=('build', 'run'))
    depends_on('py-typing', when='^python@:3.4', type=('build', 'run'))
    depends_on('[email protected]',
               when='@1.8:',
               type=('build', 'link', 'run'))
    depends_on('[email protected]',
               when='@1.1:1.7',
               type=('build', 'link', 'run'))
    depends_on('[email protected]',
               when='@:1.0',
               type=('build', 'link', 'run'))
    depends_on('py-dataclasses',
               when='@1.7: ^[email protected]',
               type=('build', 'run'))
    depends_on('py-tqdm', type='run')
    # https://github.com/onnx/onnx#prerequisites
    depends_on('[email protected]:', type=('build', 'run'))
    depends_on('[email protected]:', when='@1.10:', type=('build', 'run'))
    depends_on('py-protobuf@:3.14', when='@:1.9', type=('build', 'run'))
    depends_on('[email protected]:', when='@1.10:')
    depends_on('protobuf@:3.14', when='@:1.9')
    # https://github.com/protocolbuffers/protobuf/issues/10051
    # https://github.com/pytorch/pytorch/issues/78362
    depends_on('py-protobuf@:3', type=('build', 'run'))
    depends_on('protobuf@:3', type=('build', 'run'))
    depends_on('[email protected]:',
               when='@1.7:',
               type=('build', 'run'))
    depends_on('blas')
    depends_on('lapack')
    depends_on('eigen')
    # https://github.com/pytorch/pytorch/issues/60329
    # depends_on('cpuinfo@2020-12-17', when='@1.8:')
    # depends_on('cpuinfo@2020-06-11', when='@1.6:1.7')
    # https://github.com/shibatch/sleef/issues/427
    # depends_on('[email protected]_2020-12-22', when='@1.8:')
    # https://github.com/pytorch/pytorch/issues/60334
    # depends_on('[email protected]_2019-07-30', when='@1.6:1.7')
    # https://github.com/Maratyszcza/FP16/issues/18
    # depends_on('fp16@2020-05-14', when='@1.6:')
    depends_on('pthreadpool@2021-04-13', when='@1.9:')
    depends_on('pthreadpool@2020-10-05', when='@1.8')
    depends_on('pthreadpool@2020-06-15', when='@1.6:1.7')
    depends_on('psimd@2020-05-17', when='@1.6:')
    depends_on('fxdiv@2020-04-17', when='@1.6:')
    depends_on('benchmark', when='@1.6:+test')

    # Optional dependencies
    # https://discuss.pytorch.org/t/compiling-1-10-1-from-source-with-gcc-11-and-cuda-11-5/140971
    depends_on('[email protected]:', when='@1.11:+cuda', type=('build', 'link', 'run'))
    depends_on('[email protected]:11.4',
               when='@1.6:1.10+cuda',
               type=('build', 'link', 'run'))
    depends_on('cuda@9:11.4',
               when='@1.1:1.5+cuda',
               type=('build', 'link', 'run'))
    depends_on('[email protected]:11.4',
               when='@:1.0+cuda',
               type=('build', 'link', 'run'))
    depends_on('cudnn@6:7', when='@:1.0+cudnn')
    depends_on('[email protected]:7', when='@1.1:1.5+cudnn')
    depends_on('cudnn@7:', when='@1.6:+cudnn')
    depends_on('magma', when='+magma')
    depends_on('nccl', when='+nccl')
    depends_on('numactl', when='+numa')
    depends_on('llvm-openmp', when='%apple-clang +openmp')
    depends_on('valgrind', when='+valgrind')
    with when("+rocm"):
        depends_on('hsa-rocr-dev')
        depends_on('hip')
        depends_on('rccl')
        depends_on('rocprim')
        depends_on('hipcub')
        depends_on('rocthrust')
        depends_on('roctracer-dev')
        depends_on('rocrand')
        depends_on('hipsparse')
        depends_on('hipfft')
        depends_on('rocfft')
        depends_on('rocblas')
        depends_on('miopen-hip')
    # https://github.com/pytorch/pytorch/issues/60332
    # depends_on('xnnpack@2022-02-16', when='@1.12:+xnnpack')
    # depends_on('xnnpack@2021-06-21', when='@1.10:1.11+xnnpack')
    # depends_on('xnnpack@2021-02-22', when='@1.8:1.9+xnnpack')
    # depends_on('xnnpack@2020-03-23', when='@1.6:1.7+xnnpack')
    depends_on('mpi', when='+mpi')
    # https://github.com/pytorch/pytorch/issues/60270
    # depends_on('gloo@2021-05-21', when='@1.10:+gloo')
    # depends_on('gloo@2021-05-04', when='@1.9+gloo')
    # depends_on('gloo@2020-09-18', when='@1.7:1.8+gloo')
    # depends_on('gloo@2020-03-17', when='@1.6+gloo')
    # https://github.com/pytorch/pytorch/issues/60331
    # depends_on('[email protected]', when='@1.12:+onnx_ml')
    # depends_on('[email protected]_2021-10-08', when='@1.11+onnx_ml')
    # depends_on('[email protected]', when='@1.10+onnx_ml')
    # depends_on('[email protected]_2020-11-03', when='@1.8:1.9+onnx_ml')
    # depends_on('[email protected]_2020-05-31', when='@1.6:1.7+onnx_ml')
    depends_on('mkl', when='+mkldnn')

    # Test dependencies
    depends_on('py-hypothesis', type='test')
    depends_on('py-six', type='test')
    depends_on('py-psutil', type='test')

    # Fix BLAS being overridden by MKL
    # https://github.com/pytorch/pytorch/issues/60328
    patch('https://github.com/pytorch/pytorch/pull/59220.patch?full_index=1',
          sha256=
          '6d5717267f901e8ee493dfacd08734d9bcc48ad29a76ca9ef702368e96bee675',
          when='@1.2:1.11')

    # Fixes build on older systems with glibc <2.12
    patch('https://github.com/pytorch/pytorch/pull/55063.patch?full_index=1',
          sha256=
          '2229bcbf20fbe88aa9f7318f89c126ec7f527875ffe689a763c78abfa127a65c',
          when='@1.1:1.8.1')

    # Fixes CMake configuration error when XNNPACK is disabled
    # https://github.com/pytorch/pytorch/pull/35607
    # https://github.com/pytorch/pytorch/pull/37865
    patch('xnnpack.patch', when='@1.5')

    # Fixes build error when ROCm is enabled for pytorch-1.5 release
    patch('rocm.patch', when='@1.5+rocm')

    # Fixes fatal error: sleef.h: No such file or directory
    # https://github.com/pytorch/pytorch/pull/35359
    # https://github.com/pytorch/pytorch/issues/26555
    # patch('sleef.patch', when='@:1.5')

    # Fixes compilation with Clang 9.0.0 and Apple Clang 11.0.3
    # https://github.com/pytorch/pytorch/pull/37086
    patch(
        'https://github.com/pytorch/pytorch/commit/e921cd222a8fbeabf5a3e74e83e0d8dfb01aa8b5.patch?full_index=1',
        sha256=
        '0f3ad037a95af9d34b1d085050c1e7771fd00f0b89e5b3a276097b7c9f4fabf8',
        when='@1.1:1.5')

    # Removes duplicate definition of getCusparseErrorString
    # https://github.com/pytorch/pytorch/issues/32083
    patch('cusparseGetErrorString.patch', when='@:1.0^[email protected]:')

    # Fixes 'FindOpenMP.cmake'
    # to detect openmp settings used by Fujitsu compiler.
    patch('detect_omp_of_fujitsu_compiler.patch', when='%fj')

    # Fixes to build with fujitsu-ssl2
    patch('fj-ssl2_1.11.patch', when='@1.11:^fujitsu-ssl2')
    patch('fj-ssl2_1.10.patch', when='@1.10^fujitsu-ssl2')
    patch('fj-ssl2_1.9.patch', when='@1.9^fujitsu-ssl2')
    patch('fj-ssl2_1.8.patch', when='@1.8^fujitsu-ssl2')
    patch('fj-ssl2_1.6-1.7.patch', when='@1.6:1.7^fujitsu-ssl2')
    patch('fj-ssl2_1.3-1.5.patch', when='@1.3:1.5^fujitsu-ssl2')
    patch('fj-ssl2_1.2.patch', when='@1.2^fujitsu-ssl2')

    # Fix compilation of +distributed~tensorpipe
    # https://github.com/pytorch/pytorch/issues/68002
    patch(
        'https://github.com/pytorch/pytorch/commit/c075f0f633fa0136e68f0a455b5b74d7b500865c.patch?full_index=1',
        sha256=
        '41271e494a3a60a65a8dd45ac053d1a6e4e4d5b42c2dac589ac67524f61ac41e',
        when='@1.10.0+distributed~tensorpipe')

    # Use patches from IBM's Open CE to enable building on Power systems
    # 03xx - patch temporary to fix a problem that when fixed upstream can be removed
    patch(
        'https://github.com/open-ce/pytorch-feedstock/raw/main/recipe/0302-cpp-extension.patch',
        sha256=
        'ecb3973fa7d0f4c8f8ae40433f3ca5622d730a7b16f6cb63325d1e95baff8aa2',
        when='@1.10.0: arch=ppc64le:')

    patch(
        'https://github.com/open-ce/pytorch-feedstock/raw/main/recipe/0311-PR66085-Remove-unused-dump-method-from-VSX-vec256-methods.patch',
        sha256=
        'f05db59f3def4c4215db7142d81029c73fe330c660492159b66d65ca5001f4d1',
        when='@1.10.0: arch=ppc64le:')

    patch(
        'https://github.com/open-ce/pytorch-feedstock/raw/main/recipe/0312-PR67331-Dummpy-VSX-bfloat16-implementation.patch',
        sha256=
        '860b64afa85f5e6647ebc3c91d5a0bb258784770900c9302c3599c98d5cff1ee',
        when='@1.10.0: arch=ppc64le:')

    patch(
        'https://github.com/open-ce/pytorch-feedstock/raw/main/recipe/0313-add-missing-vsx-dispatch.patch',
        sha256=
        '7393c2bc0b6d41ecc813c829a1e517bee864686652e91f174cb7bcdfb10ba451',
        when='@1.10.0: arch=ppc64le:')

    # Cherry-pick a patch to allow earlier versions of PyTorch to work with CUDA 11.4
    patch(
        'https://github.com/pytorch/pytorch/commit/c74c0c571880df886474be297c556562e95c00e0.patch?full_index=1',
        sha256=
        '8ff7d285e52e4718bad1ca01ceb3bb6471d7828329036bb94222717fcaa237da',
        when='@:1.9.1 ^[email protected]:')

    @property
    def libs(self):
        # TODO: why doesn't `python_platlib` work here?
        root = join_path(self.prefix, self.spec['python'].package.platlib,
                         'torch', 'lib')
        return find_libraries('libtorch', root)

    @property
    def headers(self):
        # TODO: why doesn't `python_platlib` work here?
        root = join_path(self.prefix, self.spec['python'].package.platlib,
                         'torch', 'include')
        headers = find_all_headers(root)
        headers.directories = [root]
        return headers

    @when('@1.5.0:')
    def patch(self):
        # https://github.com/pytorch/pytorch/issues/52208
        filter_file('torch_global_deps PROPERTIES LINKER_LANGUAGE C',
                    'torch_global_deps PROPERTIES LINKER_LANGUAGE CXX',
                    'caffe2/CMakeLists.txt')

    def setup_build_environment(self, env):
        """Set environment variables used to control the build.

        PyTorch's ``setup.py`` is a thin wrapper around ``cmake``.
        In ``tools/setup_helpers/cmake.py``, you can see that all
        environment variables that start with ``BUILD_``, ``USE_``,
        or ``CMAKE_``, plus a few more explicitly specified variable
        names, are passed directly to the ``cmake`` call. Therefore,
        most flags defined in ``CMakeLists.txt`` can be specified as
        environment variables.
        """
        def enable_or_disable(variant, keyword='USE', var=None, newer=False):
            """Set environment variable to enable or disable support for a
            particular variant.

            Parameters:
                variant (str): the variant to check
                keyword (str): the prefix to use for enabling/disabling
                var (str): CMake variable to set. Defaults to variant.upper()
                newer (bool): newer variants that never used NO_*
            """
            if var is None:
                var = variant.upper()

            # Version 1.1.0 switched from NO_* to USE_* or BUILD_*
            # But some newer variants have always used USE_* or BUILD_*
            if self.spec.satisfies('@1.1:') or newer:
                if '+' + variant in self.spec:
                    env.set(keyword + '_' + var, 'ON')
                elif '~' + variant in self.spec:
                    env.set(keyword + '_' + var, 'OFF')
            else:
                if '+' + variant in self.spec:
                    env.unset('NO_' + var)
                elif '~' + variant in self.spec:
                    env.set('NO_' + var, 'ON')

        # Build in parallel to speed up build times
        env.set('MAX_JOBS', make_jobs)

        # Spack logs have trouble handling colored output
        env.set('COLORIZE_OUTPUT', 'OFF')

        enable_or_disable('test', keyword='BUILD')
        enable_or_disable('caffe2', keyword='BUILD')

        enable_or_disable('cuda')
        if '+cuda' in self.spec:
            # cmake/public/cuda.cmake
            # cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake
            env.unset('CUDA_ROOT')
            torch_cuda_arch = ';'.join(
                '{0:.1f}'.format(float(i) / 10.0)
                for i in self.spec.variants['cuda_arch'].value)
            env.set('TORCH_CUDA_ARCH_LIST', torch_cuda_arch)
            if self.spec.satisfies('%clang'):
                for flag in self.spec.compiler_flags['cxxflags']:
                    if 'gcc-toolchain' in flag:
                        env.set('CMAKE_CUDA_FLAGS',
                                '=-Xcompiler={0}'.format(flag))

        enable_or_disable('rocm')
        if '+rocm' in self.spec:
            env.set('HSA_PATH', self.spec['hsa-rocr-dev'].prefix)
            env.set('ROCBLAS_PATH', self.spec['rocblas'].prefix)
            env.set('ROCFFT_PATH', self.spec['rocfft'].prefix)
            env.set('HIPFFT_PATH', self.spec['hipfft'].prefix)
            env.set('HIPSPARSE_PATH', self.spec['hipsparse'].prefix)
            env.set('THRUST_PATH', self.spec['rocthrust'].prefix.include)
            env.set('HIP_PATH', self.spec['hip'].prefix)
            env.set('HIPRAND_PATH', self.spec['rocrand'].prefix)
            env.set('ROCRAND_PATH', self.spec['rocrand'].prefix)
            env.set('MIOPEN_PATH', self.spec['miopen-hip'].prefix)
            env.set('RCCL_PATH', self.spec['rccl'].prefix)
            env.set('ROCPRIM_PATH', self.spec['rocprim'].prefix)
            env.set('HIPCUB_PATH', self.spec['hipcub'].prefix)
            env.set('ROCTHRUST_PATH', self.spec['rocthrust'].prefix)
            env.set('ROCTRACER_PATH', self.spec['roctracer-dev'].prefix)

        enable_or_disable('cudnn')
        if '+cudnn' in self.spec:
            # cmake/Modules_CUDA_fix/FindCUDNN.cmake
            env.set('CUDNN_INCLUDE_DIR', self.spec['cudnn'].prefix.include)
            env.set('CUDNN_LIBRARY', self.spec['cudnn'].libs[0])

        enable_or_disable('fbgemm')
        enable_or_disable('kineto')
        enable_or_disable('magma')
        enable_or_disable('metal')
        enable_or_disable('mps')
        enable_or_disable('breakpad')

        enable_or_disable('nccl')
        if '+nccl' in self.spec:
            env.set('NCCL_LIB_DIR', self.spec['nccl'].libs.directories[0])
            env.set('NCCL_INCLUDE_DIR', self.spec['nccl'].prefix.include)

        # cmake/External/nnpack.cmake
        enable_or_disable('nnpack')

        enable_or_disable('numa')
        if '+numa' in self.spec:
            # cmake/Modules/FindNuma.cmake
            env.set('NUMA_ROOT_DIR', self.spec['numactl'].prefix)

        # cmake/Modules/FindNumPy.cmake
        enable_or_disable('numpy')
        # cmake/Modules/FindOpenMP.cmake
        enable_or_disable('openmp', newer=True)
        enable_or_disable('qnnpack')
        enable_or_disable('qnnpack', var='PYTORCH_QNNPACK')
        enable_or_disable('valgrind')
        enable_or_disable('xnnpack')
        enable_or_disable('mkldnn')
        enable_or_disable('distributed')
        enable_or_disable('mpi')
        # cmake/Modules/FindGloo.cmake
        enable_or_disable('gloo', newer=True)
        enable_or_disable('tensorpipe')

        if '+debug' in self.spec:
            env.set('DEBUG', 'ON')
        else:
            env.set('DEBUG', 'OFF')

        if '+onnx_ml' in self.spec:
            env.set('ONNX_ML', 'ON')
        elif '~onnx_ml' in self.spec:
            env.set('ONNX_ML', 'OFF')

        if not self.spec.satisfies('@master'):
            env.set('PYTORCH_BUILD_VERSION', self.version)
            env.set('PYTORCH_BUILD_NUMBER', 0)

        # BLAS to be used by Caffe2
        # Options defined in cmake/Dependencies.cmake and cmake/Modules/FindBLAS.cmake
        if self.spec['blas'].name == 'atlas':
            env.set('BLAS', 'ATLAS')
            env.set('WITH_BLAS', 'atlas')
        elif self.spec['blas'].name in ['blis', 'amdblis']:
            env.set('BLAS', 'BLIS')
            env.set('WITH_BLAS', 'blis')
        elif self.spec['blas'].name == 'eigen':
            env.set('BLAS', 'Eigen')
        elif self.spec['lapack'].name in ['libflame', 'amdlibflame']:
            env.set('BLAS', 'FLAME')
            env.set('WITH_BLAS', 'FLAME')
        elif self.spec['blas'].name in [
                'intel-mkl', 'intel-parallel-studio', 'intel-oneapi-mkl'
        ]:
            env.set('BLAS', 'MKL')
            env.set('WITH_BLAS', 'mkl')
            # help find MKL
            if self.spec['mkl'].name == 'intel-oneapi-mkl':
                env.set('INTEL_MKL_DIR', self.spec['mkl'].prefix.mkl.latest)
            else:
                env.set('INTEL_MKL_DIR', self.spec['mkl'].prefix.mkl)
        elif self.spec['blas'].name == 'openblas':
            env.set('BLAS', 'OpenBLAS')
            env.set('WITH_BLAS', 'open')
        elif self.spec['blas'].name == 'veclibfort':
            env.set('BLAS', 'vecLib')
            env.set('WITH_BLAS', 'veclib')
        elif self.spec['blas'].name == 'fujitsu-ssl2':
            env.set('BLAS', 'SSL2')
            env.set('WITH_BLAS', 'ssl2')
        else:
            env.set('BLAS', 'Generic')
            env.set('WITH_BLAS', 'generic')

        # Don't use vendored third-party libraries when possible
        env.set('BUILD_CUSTOM_PROTOBUF', 'OFF')
        env.set('USE_SYSTEM_NCCL', 'ON')
        env.set('USE_SYSTEM_EIGEN_INSTALL', 'ON')
        env.set('pybind11_DIR', self.spec['py-pybind11'].prefix)
        env.set('pybind11_INCLUDE_DIR',
                self.spec['py-pybind11'].prefix.include)
        if self.spec.satisfies('@1.10:'):
            env.set('USE_SYSTEM_PYBIND11', 'ON')
        # https://github.com/pytorch/pytorch/issues/60334
        # if self.spec.satisfies('@1.8:'):
        #     env.set('USE_SYSTEM_SLEEF', 'ON')
        if self.spec.satisfies('@1.6:'):
            # env.set('USE_SYSTEM_LIBS', 'ON')
            # https://github.com/pytorch/pytorch/issues/60329
            # env.set('USE_SYSTEM_CPUINFO', 'ON')
            # https://github.com/pytorch/pytorch/issues/60270
            # env.set('USE_SYSTEM_GLOO', 'ON')
            # https://github.com/Maratyszcza/FP16/issues/18
            # env.set('USE_SYSTEM_FP16', 'ON')
            env.set('USE_SYSTEM_PTHREADPOOL', 'ON')
            env.set('USE_SYSTEM_PSIMD', 'ON')
            env.set('USE_SYSTEM_FXDIV', 'ON')
            env.set('USE_SYSTEM_BENCHMARK', 'ON')
            # https://github.com/pytorch/pytorch/issues/60331
            # env.set('USE_SYSTEM_ONNX', 'ON')
            # https://github.com/pytorch/pytorch/issues/60332
            # env.set('USE_SYSTEM_XNNPACK', 'ON')

    @run_before('install')
    def build_amd(self):
        if '+rocm' in self.spec:
            python(os.path.join('tools', 'amd_build', 'build_amd.py'))

    @run_after('install')
    @on_package_attributes(run_tests=True)
    def install_test(self):
        with working_dir('test'):
            python('run_test.py')
Пример #22
0
class Oce(Package):
    """Open CASCADE Community Edition:
    patches/improvements/experiments contributed by users over the official
    Open CASCADE library.
    """
    homepage = "https://github.com/tpaviot/oce"
    url = "https://github.com/tpaviot/oce/archive/OCE-0.18.tar.gz"

    version('0.18.3', '1686393c8493bbbb2f3f242330b33cba')
    version('0.18.2', '6dfd68e459e2c62387579888a867281f')
    version('0.18.1', '2a7597f4243ee1f03245aeeb02d00956')
    version(
        '0.18',
        '226e45e77c16a4a6e127c71fefcd171410703960ae75c7ecc7eb68895446a993')
    version('0.17.2', 'bf2226be4cd192606af677cf178088e5')
    version('0.17.1', '36c67b87093c675698b483454258af91')
    version('0.17', 'f1a89395c4b0d199bea3db62b85f818d')
    version('0.16.1', '4d591b240c9293e879f50d86a0cb2bb3')
    version('0.16', '7a4b4df5a104d75a537e25e7dd387eca')

    variant('tbb',
            default=True,
            description='Build with Intel Threading Building Blocks')
    variant('X11', default=False, description='Build with X11 enabled')

    depends_on('[email protected]:', type='build')
    depends_on('tbb', when='+tbb')

    # There is a bug in OCE which appears with Clang (version?) or GCC 6.0
    # and has to do with compiler optimization, see
    # https://github.com/tpaviot/oce/issues/576
    # http://tracker.dev.opencascade.org/view.php?id=26042
    # https://github.com/tpaviot/oce/issues/605
    # https://github.com/tpaviot/oce/commit/61cb965b9ffeca419005bc15e635e67589c421dd.patch
    patch('null.patch', when='@0.16:0.17.1')

    # OCE depends on xlocale.h from glibc-headers but it was removed in 2.26,
    # see https://github.com/tpaviot/oce/issues/675
    patch('xlocale.patch', level=0, when='@0.18.1:0.18.2')

    # fix build with Xcode 8 "previous definition of CLOCK_REALTIME"
    # reported 27 Sep 2016 https://github.com/tpaviot/oce/issues/643
    if (platform.system() == "Darwin") and (macos_version()
                                            == Version('10.12')):
        patch('sierra.patch', when='@0.17.2:0.18.0')

    def install(self, spec, prefix):
        options = []
        options.extend(std_cmake_args)
        options.extend([
            '-DOCE_INSTALL_PREFIX=%s' % prefix,
            '-DOCE_BUILD_SHARED_LIB:BOOL=ON',
            '-DCMAKE_BUILD_TYPE:STRING=Release', '-DOCE_DATAEXCHANGE:BOOL=ON',
            '-DOCE_DISABLE_X11:BOOL=%s' % ('OFF' if '+X11' in spec else 'ON'),
            '-DOCE_DRAW:BOOL=OFF', '-DOCE_MODEL:BOOL=ON',
            '-DOCE_MULTITHREAD_LIBRARY:STRING=%s' %
            ('TBB' if '+tbb' in spec else 'NONE'), '-DOCE_OCAF:BOOL=ON',
            '-DOCE_USE_TCL_TEST_FRAMEWORK:BOOL=OFF',
            '-DOCE_VISUALISATION:BOOL=OFF', '-DOCE_WITH_FREEIMAGE:BOOL=OFF',
            '-DOCE_WITH_GL2PS:BOOL=OFF', '-DOCE_WITH_OPENCL:BOOL=OFF'
        ])

        if platform.system() == 'Darwin':
            options.extend([
                '-DOCE_OSX_USE_COCOA:BOOL=ON',
            ])

        if platform.system() == 'Darwin' and (macos_version() >=
                                              Version('10.12')):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append('-DCMAKE_MACOSX_RPATH=ON')
        else:
            options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)

        cmake('.', *options)
        make("install/strip")
        if self.run_tests:
            make("test")
Пример #23
0
class Bison(AutotoolsPackage, GNUMirrorPackage):
    """Bison is a general-purpose parser generator that converts
    an annotated context-free grammar into a deterministic LR or
    generalized LR (GLR) parser employing LALR(1) parser tables."""

    homepage = "https://www.gnu.org/software/bison/"
    gnu_mirror_path = "bison/bison-3.6.4.tar.gz"

    executables = ['^bison$']

    version('3.7.6',
            sha256=
            '69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea')
    version('3.7.5',
            sha256=
            '151cb5f12716e3fe93a27a317cd44878329659f275b342779bfaef4a526bbf70')
    version('3.7.4',
            sha256=
            'fbabc7359ccd8b4b36d47bfe37ebbce44805c052526d5558b95eda125d1677e2')
    version('3.7.3',
            sha256=
            '104fe912f2212ab4e4a59df888a93b719a046ffc38d178e943f6c54b1f27b3c7')
    version('3.7.2',
            sha256=
            '415cd91044517bbfd8d135dea24e054501db238a5515edd9cdbb795ba3e82a84')
    version('3.7.1',
            sha256=
            '1dd952839cf0d5a8178c691eeae40dc48fa50d18dcce648b1ad9ae0195367d13')
    version('3.7',
            sha256=
            '492ad61202de893ca21a99b621d63fa5389da58804ad79d3f226b8d04b803998')
    version('3.6.4',
            sha256=
            '8183de64b5383f3634942c7b151bf2577f74273b2731574cdda8a8f3a0ab13e9')
    version('3.6.3',
            sha256=
            '4b4c4943931e811f1073006ce3d8ee022a02b11b501e9cbf4def3613b24a3e63')
    version('3.6.2',
            sha256=
            'e28ed3aad934de2d1df68be209ac0b454f7b6d3c3d6d01126e5cd2cbadba089a')
    version('3.6.1',
            sha256=
            '1120f8bfe2cc13e5e1e3f671dc41b1a535ca5a75a70d5b349c19da9d4389f74d')
    version('3.6',
            sha256=
            'f630645e330bde5847266cc5c8194f0135ced75cced150358d9abe572b95f81c')
    version('3.5.3',
            sha256=
            '34e201d963156618a0ea5bc87220f660a1e08403dd3c7c7903d4f38db3f40039')
    version('3.5.2',
            sha256=
            'b4dbb6dd080f4db7f344f16506502973ca2b15f15c7dbbd1c1c278a456d094fa')
    version('3.5.1',
            sha256=
            '4cef2322d96751be1c0d04f3e57adbb30e7fea83af9c00f98efa6e7509296f25')
    version('3.5',
            sha256=
            '0b36200b9868ee289b78cefd1199496b02b76899bbb7e84ff1c0733a991313d1')
    version('3.4.2',
            sha256=
            'ff3922af377d514eca302a6662d470e857bd1a591e96a2050500df5a9d59facf')
    version('3.4.1',
            sha256=
            '7007fc89c216fbfaff5525359b02a7e5b612694df5168c74673f67055f015095')
    version('3.3.2',
            sha256=
            '0fda1d034185397430eb7b0c9e140fb37e02fbfc53b90252fa5575e382b6dbd1')
    version('3.0.5',
            sha256=
            'cd399d2bee33afa712bac4b1f4434e20379e9b4099bce47189e09a7675a2d566')
    version('3.0.4',
            sha256=
            'b67fd2daae7a64b5ba862c66c07c1addb9e6b1b05c5f2049392cfd8a2172952e')
    version('2.7',
            sha256=
            '19bbe7374fd602f7a6654c131c21a15aebdc06cc89493e8ff250cb7f9ed0a831')

    # https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00008.html
    patch('parallel.patch', when='@3.4.2')

    provides('yacc')

    depends_on('diffutils', type='build')
    depends_on('m4', type=('build', 'run'))
    depends_on('perl', type='build')

    patch('pgi.patch', when='@3.0.4')
    # The NVIDIA compilers do not currently support some GNU builtins.
    # Detect this case and use the fallback path.
    patch('nvhpc-3.6.patch', when='@3.6.0:3.6.99 %nvhpc')
    patch('nvhpc-3.7.patch', when='@3.7.0:3.7.99 %nvhpc')

    conflicts('%intel@:14',
              when='@3.4.2:',
              msg="Intel 14 has immature C11 support")

    if sys.platform == 'darwin' and macos_version() >= Version('10.13'):
        patch('secure_snprintf.patch', level=0, when='@3.0.4')

    build_directory = 'spack-build'

    @classmethod
    def determine_version(cls, exe):
        output = Executable(exe)('--version', output=str, error=str)
        match = re.search(r'bison \(GNU Bison\)\s+(\S+)', output)
        return match.group(1) if match else None
Пример #24
0
    def cmake_args(self):
        options = []

        spec = self.spec
        define = CMakePackage.define
        define_from_variant = self.define_from_variant

        def _make_definer(prefix):
            def define_enable(suffix, value=None):
                key = prefix + suffix
                if value is None:
                    # Default to lower-case spec
                    value = suffix.lower()
                elif isinstance(value, bool):
                    # Explicit true/false
                    return define(key, value)
                return define_from_variant(key, value)
            return define_enable

        # Return "Trilinos_ENABLE_XXX" for spec "+xxx" or boolean value
        define_trilinos_enable = _make_definer("Trilinos_ENABLE_")
        # Same but for TPLs
        define_tpl_enable = _make_definer("TPL_ENABLE_")

        # #################### Base Settings #######################

        options.extend([
            define('Trilinos_VERBOSE_CONFIGURE', False),
            define_from_variant('BUILD_SHARED_LIBS', 'shared'),
            define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
            define_trilinos_enable('TESTS', False),
            define_trilinos_enable('EXAMPLES', False),
            define_trilinos_enable('CXX11', True),
            define_trilinos_enable('DEBUG', 'debug'),
            define_trilinos_enable('Fortran'),
            define_trilinos_enable('OpenMP'),
            define_trilinos_enable('EXPLICIT_INSTANTIATION',
                                   'explicit_template_instantiation')
            # The following can cause problems on systems that don't have
            # static libraries available for things like dl and pthreads
            # for example when trying to build static libs
            # define_from_variant('TPL_FIND_SHARED_LIBS', 'shared')
            # define('Trilinos_LINK_SEARCH_START_STATIC', '+shared' not in spec)
        ])

        # ################## Trilinos Packages #####################

        options.extend([
            define_trilinos_enable('Amesos'),
            define_trilinos_enable('Amesos2'),
            define_trilinos_enable('Anasazi'),
            define_trilinos_enable('AztecOO', 'aztec'),
            define_trilinos_enable('Belos'),
            define_trilinos_enable('Epetra'),
            define_trilinos_enable('EpetraExt'),
            define_trilinos_enable('FEI', False),
            define_trilinos_enable('Gtest', False),
            define_trilinos_enable('Ifpack'),
            define_trilinos_enable('Ifpack2'),
            define_trilinos_enable('Intrepid'),
            define_trilinos_enable('Intrepid2'),
            define_trilinos_enable('Isorropia'),
            define_trilinos_enable('Kokkos'),
            define_trilinos_enable('MiniTensor'),
            define_trilinos_enable('Mesquite'),
            define_trilinos_enable('ML'),
            define_trilinos_enable('MueLu'),
            define_trilinos_enable('NOX'),
            define_trilinos_enable('Pamgen', False),
            define_trilinos_enable('Panzer', False),
            define_trilinos_enable('Pike', False),
            define_trilinos_enable('Piro'),
            define_trilinos_enable('Phalanx'),
            define_trilinos_enable('PyTrilinos', 'python'),
            define_trilinos_enable('ROL'),
            define_trilinos_enable('Rythmos'),
            define_trilinos_enable('Sacado'),
            define_trilinos_enable('SCOREC'),
            define_trilinos_enable('Shards'),
            define_trilinos_enable('ShyLU'),
            define_trilinos_enable('STK'),
            define_trilinos_enable('Stokhos'),
            define_trilinos_enable('Stratimikos'),
            define_trilinos_enable('Teko'),
            define_trilinos_enable('Tempus'),
            define_trilinos_enable('Tpetra'),
            define_trilinos_enable('TrilinosCouplings'),
            define_trilinos_enable('Zoltan'),
            define_trilinos_enable('Zoltan2'),
            define_tpl_enable('Cholmod', False),
            define_from_variant('EpetraExt_BUILD_BTF', 'epetraextbtf'),
            define_from_variant('EpetraExt_BUILD_EXPERIMENTAL',
                                'epetraextexperimental'),
            define_from_variant('EpetraExt_BUILD_GRAPH_REORDERINGS',
                                'epetraextgraphreorderings'),
            define_from_variant('Amesos2_ENABLE_Basker', 'basker'),
        ])

        if '+dtk' in spec:
            options.extend([
                define('Trilinos_EXTRA_REPOSITORIES', 'DataTransferKit'),
                define_trilinos_enable('DataTransferKit', True),
            ])

        if '+exodus' in spec:
            options.extend([
                define_trilinos_enable('SEACAS', True),
                define_trilinos_enable('SEACASExodus', True),
                define_trilinos_enable('SEACASIoss', True),
                define_trilinos_enable('SEACASEpu', True),
                define_trilinos_enable('SEACASExodiff', True),
                define_trilinos_enable('SEACASNemspread', True),
                define_trilinos_enable('SEACASNemslice', True),
            ])
        else:
            options.extend([
                define_trilinos_enable('SEACASExodus', False),
                define_trilinos_enable('SEACASIoss', False),
            ])

        if '+chaco' in spec:
            options.extend([
                define_trilinos_enable('SEACAS', True),
                define_trilinos_enable('SEACASChaco', True),
            ])
        else:
            # don't disable SEACAS, could be needed elsewhere
            options.extend([
                define_trilinos_enable('SEACASChaco', False),
                define_trilinos_enable('SEACASNemslice', False)
            ])

        if '+stratimikos' in spec:
            # Explicitly enable Thyra (ThyraCore is required). If you don't do
            # this, then you get "NOT setting ${pkg}_ENABLE_Thyra=ON since
            # Thyra is NOT enabled at this point!" leading to eventual build
            # errors if using MueLu because `Xpetra_ENABLE_Thyra` is set to
            # off.
            options.append(define_trilinos_enable('Thyra', True))

            # Add thyra adapters based on package enables
            options.extend(
                define_trilinos_enable('Thyra' + pkg + 'Adapters', pkg.lower())
                for pkg in ['Epetra', 'EpetraExt', 'Tpetra'])

        # ######################### TPLs #############################

        # Enable TPLs based on whether they're in our spec, not whether they're
        # variant names: packages/features should disable availability
        tpl_dep_map = [
            ('ADIOS2', 'adios2'),
            ('BLAS', 'blas'),
            ('Boost', 'boost'),
            ('CGNS', 'cgns'),
            ('HDF5', 'hdf5'),
            ('HYPRE', 'hypre'),
            ('LAPACK', 'lapack'),
            ('Matio', 'matio'),
            ('METIS', 'metis'),
            ('MUMPS', 'mumps'),
            ('Netcdf', 'netcdf-c'),
            ('SCALAPACK', 'scalapack'),
            ('SuperLU', 'superlu'),
            ('SuperLUDist', 'superlu-dist'),
            ('UMFPACK', 'suite-sparse'),
            ('X11', 'libx11'),
            ('Zlib', 'zlib'),
        ]
        if spec.satisfies('@12.12.1:'):
            tpl_dep_map.append(('Pnetcdf', 'parallel-netcdf'))
        if spec.satisfies('@13:'):
            tpl_dep_map.append(('HWLOC', 'hwloc'))
        if spec.satisfies('@13.0.2:'):
            tpl_dep_map.append(('STRUMPACK', 'strumpack'))

        for tpl_name, dep_name in tpl_dep_map:
            have_dep = (dep_name in spec)
            options.append(define('TPL_ENABLE_' + tpl_name, have_dep))
            if not have_dep:
                continue
            depspec = spec[dep_name]
            libs = depspec.libs
            options.extend([
                define(tpl_name + '_INCLUDE_DIRS', depspec.prefix.include),
                define(tpl_name + '_ROOT', depspec.prefix),
                define(tpl_name + '_LIBRARY_NAMES', libs.names),
                define(tpl_name + '_LIBRARY_DIRS', libs.directories),
            ])

        # MPI settings
        options.append(define_tpl_enable('MPI'))
        if '+mpi' in spec:
            # Force Trilinos to use the MPI wrappers instead of raw compilers
            # to propagate library link flags for linkers that require fully
            # resolved symbols in shared libs (such as macOS and some newer
            # Ubuntu)
            options.extend([
                define('CMAKE_C_COMPILER', spec['mpi'].mpicc),
                define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx),
                define('CMAKE_Fortran_COMPILER', spec['mpi'].mpifc),
                define('MPI_BASE_DIR', spec['mpi'].prefix),
            ])

        # ParMETIS dependencies have to be transitive explicitly
        have_parmetis = 'parmetis' in spec
        options.append(define_tpl_enable('ParMETIS', have_parmetis))
        if have_parmetis:
            options.extend([
                define('ParMETIS_LIBRARY_DIRS', [
                    spec['parmetis'].prefix.lib, spec['metis'].prefix.lib
                ]),
                define('ParMETIS_LIBRARY_NAMES', ['parmetis', 'metis']),
                define('TPL_ParMETIS_INCLUDE_DIRS', [
                    spec['parmetis'].prefix.include,
                    spec['metis'].prefix.include
                ]),
            ])

        if spec.satisfies('^[email protected]:'):
            options.extend([
                define('HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG', True),
            ])

        if spec.satisfies('^parallel-netcdf'):
            options.extend([
                define('TPL_Netcdf_Enables_Netcdf4', True),
                define('TPL_Netcdf_PARALLEL', True),
                define('PNetCDF_ROOT', spec['parallel-netcdf'].prefix),
            ])

        # ################# Explicit template instantiation #################

        complex_s = spec.variants['complex'].value
        float_s = spec.variants['float'].value

        options.extend([
            define('Teuchos_ENABLE_COMPLEX', complex_s),
            define('Teuchos_ENABLE_FLOAT', float_s),
        ])

        if '+tpetra +explicit_template_instantiation' in spec:
            options.append(define_from_variant('Tpetra_INST_OPENMP', 'openmp'))
            options.extend([
                define('Tpetra_INST_DOUBLE', True),
                define('Tpetra_INST_COMPLEX_DOUBLE', complex_s),
                define('Tpetra_INST_COMPLEX_FLOAT', float_s and complex_s),
                define('Tpetra_INST_FLOAT', float_s),
                define('Tpetra_INST_SERIAL', True),
            ])

            gotype = spec.variants['gotype'].value
            if gotype == 'all':
                # default in older Trilinos versions to enable multiple GOs
                options.extend([
                    define('Tpetra_INST_INT_INT', True),
                    define('Tpetra_INST_INT_LONG', True),
                    define('Tpetra_INST_INT_LONG_LONG', True),
                ])
            else:
                options.extend([
                    define('Tpetra_INST_INT_INT', gotype == 'int'),
                    define('Tpetra_INST_INT_LONG', gotype == 'long'),
                    define('Tpetra_INST_INT_LONG_LONG', gotype == 'long_long'),
                ])

        # ################# Kokkos ######################

        if '+kokkos' in spec:
            arch = Kokkos.get_microarch(spec.target)
            if arch:
                options.append(define("Kokkos_ARCH_" + arch.upper(), True))

            define_kok_enable = _make_definer("Kokkos_ENABLE_")
            options.extend([
                define_kok_enable('CUDA'),
                define_kok_enable('OPENMP' if spec.version >= Version('13')
                                  else 'OpenMP'),
            ])
            if '+cuda' in spec:
                options.extend([
                    define_kok_enable('CUDA_UVM', True),
                    define_kok_enable('CUDA_LAMBDA', True),
                    define_kok_enable('CUDA_RELOCATABLE_DEVICE_CODE', 'cuda_rdc')
                ])
                arch_map = Kokkos.spack_cuda_arch_map
                options.extend(
                    define("Kokkos_ARCH_" + arch_map[arch].upper(), True)
                    for arch in spec.variants['cuda_arch'].value
                )

        # ################# System-specific ######################

        # Fortran lib (assumes clang is built with gfortran!)
        if ('+fortran' in spec
                and spec.compiler.name in ['gcc', 'clang', 'apple-clang']):
            fc = Executable(spec['mpi'].mpifc) if (
                '+mpi' in spec) else Executable(spack_fc)
            libgfortran = fc('--print-file-name',
                             'libgfortran.' + dso_suffix,
                             output=str).strip()
            # if libgfortran is equal to "libgfortran.<dso_suffix>" then
            # print-file-name failed, use static library instead
            if libgfortran == 'libgfortran.' + dso_suffix:
                libgfortran = fc('--print-file-name',
                                 'libgfortran.a',
                                 output=str).strip()
            # -L<libdir> -lgfortran required for OSX
            # https://github.com/spack/spack/pull/25823#issuecomment-917231118
            options.append(
                define('Trilinos_EXTRA_LINK_FLAGS',
                       '-L%s/ -lgfortran' % os.path.dirname(libgfortran)))

        if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
            # use @rpath on Sierra due to limit of dynamic loader
            options.append(define('CMAKE_MACOSX_RPATH', True))
        else:
            options.append(define('CMAKE_INSTALL_NAME_DIR', self.prefix.lib))

        return options