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
|
##############################################################################
# Copyright (c) 2017, Los Alamos National Security, LLC
# Produced at the Los Alamos National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/spack/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
import os
class Flang(CMakePackage):
"""Flang is a Fortran compiler targeting LLVM."""
homepage = "https://github.com/flang-compiler/flang"
url = "https://github.com/flang-compiler/flang/flecsi/tarball/v1.0"
version('develop', git='https://github.com/flang-compiler/flang', branch='master')
depends_on(
"llvm+clang@4.0.1,5.0.0",
patches=[
patch('https://github.com/llvm-mirror/clang/pull/33.diff',
sha256='e46d7ab305e5e95c51f4656d9b52058143cd85d859b312b3c80e93a02d54b4a5',
when='@4.0.1', level=1, working_dir='tools/clang'),
patch('https://github.com/llvm-mirror/clang/pull/35.diff',
sha256='7f39555783993f78b75c380ca5ef167c1d8b88cc75c6542f6c94e0b6acfb7c5d',
when='@5.0.0', level=1, working_dir='tools/clang')
]
)
def cmake_args(self):
options = [
'-DWITH_WERROR=OFF',
'-DCMAKE_C_COMPILER=%s' % os.path.join(
self.spec['llvm'].prefix.bin, 'clang'),
'-DCMAKE_CXX_COMPILER=%s' % os.path.join(
self.spec['llvm'].prefix.bin, 'clang++'),
'-DCMAKE_Fortran_COMPILER=%s' % os.path.join(
self.spec['llvm'].prefix.bin, 'flang'),
'-DFLANG_LIBOMP=%s' % find_libraries(
'libomp', root=self.spec['llvm'].prefix.lib)
]
return options
@run_after('install')
def post_install(self):
# we are installing flang in a path different from llvm, so we
# create a wrapper with -L for e.g. libflangrti.so and -I for
# e.g. iso_c_binding.mod. -B is needed to help flang to find
# flang1 and flang2. rpath_arg is needed so that executables
# generated by flang can find libflang later.
flang = os.path.join(self.spec.prefix.bin, 'flang')
with open(flang, 'w') as out:
out.write('#!/bin/bash\n')
out.write(
'{0} -I{1} -L{2} {3}{4} -B{5} "$@"\n'.format(
os.path.join(self.spec['llvm'].prefix.bin, 'flang'),
self.prefix.include, self.prefix.lib,
self.compiler.fc_rpath_arg, self.prefix.lib,
self.spec.prefix.bin))
out.close()
chmod = which('chmod')
chmod('+x', flang)
|