summaryrefslogtreecommitdiff
path: root/lib/spack/spack/compilers/arm.py
blob: 9b4648ec1b3e27b887b874df98aaea9c2c847e32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 2013-2023 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 os

import spack.compiler


class Arm(spack.compiler.Compiler):
    # Subclasses use possible names of C compiler
    cc_names = ["armclang"]

    # Subclasses use possible names of C++ compiler
    cxx_names = ["armclang++"]

    # Subclasses use possible names of Fortran 77 compiler
    f77_names = ["armflang"]

    # Subclasses use possible names of Fortran 90 compiler
    fc_names = ["armflang"]

    # Named wrapper links within lib/spack/env
    link_paths = {
        "cc": os.path.join("arm", "armclang"),
        "cxx": os.path.join("arm", "armclang++"),
        "f77": os.path.join("arm", "armflang"),
        "fc": os.path.join("arm", "armflang"),
    }

    # The ``--version`` option seems to be the most consistent one for
    # arm compilers. Output looks like this:
    #
    # $ arm<c/f>lang --version
    # Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2)
    # Target: aarch64--linux-gnu
    # Thread model: posix
    # InstalledDir:
    # /opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin
    version_argument = "--version"
    version_regex = r"Arm C\/C\+\+\/Fortran Compiler version ([\d\.]+) "

    @property
    def verbose_flag(self):
        return "-v"

    @property
    def opt_flags(self):
        return ["-O", "-O0", "-O1", "-O2", "-O3", "-Ofast"]

    @property
    def openmp_flag(self):
        return "-fopenmp"

    @property
    def cxx11_flag(self):
        return "-std=c++11"

    @property
    def cxx14_flag(self):
        return "-std=c++14"

    @property
    def cxx17_flag(self):
        return "-std=c++1z"

    @property
    def c99_flag(self):
        return "-std=c99"

    @property
    def c11_flag(self):
        return "-std=c11"

    @property
    def cc_pic_flag(self):
        return "-fPIC"

    @property
    def cxx_pic_flag(self):
        return "-fPIC"

    @property
    def f77_pic_flag(self):
        return "-fPIC"

    @property
    def fc_pic_flag(self):
        return "-fPIC"

    required_libs = ["libclang", "libflang"]

    @classmethod
    def fc_version(cls, fc):
        return cls.default_version(fc)

    @classmethod
    def f77_version(cls, f77):
        return cls.fc_version(f77)