ghc 7.66 KB
Newer Older
1 2 3
import os
import re

4 5 6 7 8 9
# Testsuite configuration setup for GHC
#
# This file is Python source
#
config.compiler_type         = 'ghc'
config.compiler              = 'ghc'
10
config.compiler_always_flags = ghc_compiler_always_flags.split()
11

dterei's avatar
dterei committed
12 13 14
config.hp2ps                 = 'hp2ps'
config.hpc                   = 'hpc'
config.gs                    = 'gs'
15 16
config.confdir               = '.'

andy@galois.com's avatar
andy@galois.com committed
17
# By default, we test the 'normal', 'opt' and 'hpc' ways.
18 19
# 'optasm' is added by mk/test.mk if the compiler has a native code gen,
# 'prof'   is added by mk/test.mk if the profiling way is enabled.
dterei's avatar
dterei committed
20 21
config.compile_ways       = ['normal', 'hpc']
config.run_ways           = ['normal', 'hpc']
22

krc's avatar
krc committed
23
# ways that are not enabled by default, but can always be invoked explicitly
Austin Seipp's avatar
Austin Seipp committed
24
config.other_ways         = ['prof',
dterei's avatar
dterei committed
25 26 27
                             'prof_hc_hb','prof_hb',
                             'prof_hd','prof_hy','prof_hr',
                             'threaded1_ls', 'threaded2_hT',
28 29 30 31
                             'llvm', 'debugllvm',
                             'profllvm', 'profoptllvm', 'profthreadedllvm',
                             'threaded1llvm', 'threaded2llvm',
                             'dynllvm']
krc's avatar
krc committed
32

33
if (ghc_with_native_codegen == 1):
dterei's avatar
dterei committed
34 35
    config.compile_ways.append('optasm')
    config.run_ways.append('optasm')
36

37 38
config.compiler_debugged = ghc_debugged

39 40 41
if (ghc_with_vanilla == 1):
    config.have_vanilla = True

42 43 44
if (ghc_with_dynamic == 1):
    config.have_dynamic = True

45
if (ghc_with_profiling == 1):
dterei's avatar
dterei committed
46
    config.have_profiling = True
47 48
    config.compile_ways.append('profasm')
    config.run_ways.append('profasm')
49

50
if (ghc_with_interpreter == 1):
dterei's avatar
dterei committed
51 52
    config.have_interp = True
    config.run_ways.append('ghci')
53

54 55
config.unregisterised = (ghc_unregisterised == 1)

56
if (ghc_with_threaded_rts == 1):
dterei's avatar
dterei committed
57 58
    config.run_ways.append('threaded1')
    if (ghc_with_smp == 1):
Simon Marlow's avatar
Simon Marlow committed
59
        config.have_smp = True
dterei's avatar
dterei committed
60
        config.run_ways.append('threaded2')
61

62 63 64
if (ghc_with_dynamic_rts == 1):
    config.have_shared_libs = True

65
config.ghc_dynamic_by_default = ghc_dynamic_by_default
66
if ghc_dynamic_by_default and ghc_with_vanilla == 1:
67
    config.run_ways.append('static')
68 69 70
else:
    if (ghc_with_dynamic_rts == 1):
        config.run_ways.append('dyn')
71

ian@well-typed.com's avatar
ian@well-typed.com committed
72 73
config.ghc_dynamic = ghc_dynamic

74
if (ghc_with_profiling == 1 and ghc_with_threaded_rts == 1):
dterei's avatar
dterei committed
75
    config.run_ways.append('profthreaded')
76

77
if (ghc_with_llvm == 1):
dterei's avatar
dterei committed
78
    config.compile_ways.append('optllvm')
dterei's avatar
dterei committed
79
    config.run_ways.append('optllvm')
80

81
config.in_tree_compiler = in_tree_compiler
82
config.clean_only       = clean_only
83

84
config.way_flags = lambda name : {
dterei's avatar
dterei committed
85 86
    'normal'       : [],
    'g1'           : [],
87
    'optasm'       : ['-O', '-fasm'],
dterei's avatar
dterei committed
88
    'llvm'         : ['-fllvm'],
89
    'optllvm'      : ['-O', '-fllvm'],
dterei's avatar
dterei committed
90
    'debugllvm'    : ['-fllvm', '-keep-llvm-files'],
91 92 93
    'prof'         : ['-prof', '-static', '-auto-all', '-fasm'],
    'profasm'      : ['-O', '-prof', '-static', '-auto-all'],
    'profthreaded' : ['-O', '-prof', '-static', '-auto-all', '-threaded'],
dterei's avatar
dterei committed
94 95 96 97 98
    'ghci'         : ['--interactive', '-v0', '-ignore-dot-ghci', '+RTS', '-I0.1', '-RTS'],
    'threaded1'    : ['-threaded', '-debug'],
    'threaded1_ls' : ['-threaded', '-debug'],
    'threaded2'    : ['-O', '-threaded', '-eventlog'],
    'threaded2_hT' : ['-O', '-threaded'],
99
    'hpc'          : ['-O', '-fhpc', '-hpcdir', '.hpc.' + name ],
100 101 102 103 104
    'prof_hc_hb'   : ['-O', '-prof', '-static', '-auto-all'],
    'prof_hb'      : ['-O', '-prof', '-static', '-auto-all'],
    'prof_hd'      : ['-O', '-prof', '-static', '-auto-all'],
    'prof_hy'      : ['-O', '-prof', '-static', '-auto-all'],
    'prof_hr'      : ['-O', '-prof', '-static', '-auto-all'],
105
    'dyn'          : ['-O', '-dynamic'],
106
    'static'       : ['-O', '-static'],
107
    # llvm variants...
108 109 110
    'profllvm'         : ['-prof', '-static', '-auto-all', '-fllvm'],
    'profoptllvm'      : ['-O', '-prof', '-static', '-auto-all', '-fllvm'],
    'profthreadedllvm' : ['-O', '-prof', '-static', '-auto-all', '-threaded', '-fllvm'],
111 112 113
    'threaded1llvm'    : ['-threaded', '-debug', '-fllvm'],
    'threaded2llvm'    : ['-O', '-threaded', '-eventlog', '-fllvm'],
    'dynllvm'          : ['-O', '-dynamic', '-fllvm']
dterei's avatar
dterei committed
114
   }
115 116

config.way_rts_flags = { 
dterei's avatar
dterei committed
117 118 119 120 121 122
    'normal'       : [],
    'g1'           : ['-G1'],
    'optasm'       : [],
    'llvm'         : [],
    'optllvm'      : [],
    'debugllvm'    : [],
123 124
    'prof'         : ['-p'],
    'profasm'      : ['-hc', '-p'], # test heap profiling too
dterei's avatar
dterei committed
125 126 127 128 129 130 131 132 133 134 135 136
    'profthreaded' : ['-p'],
    'ghci'         : [],
    'threaded1'    : [],
    'threaded1_ls' : ['-ls'],
    'threaded2'    : ['-N2 -ls'],
    'threaded2_hT' : ['-N2', '-hT'],
    'hpc'          : [],
    'prof_hc_hb'   : ['-hc -hbvoid'],
    'prof_hb'      : ['-hb'],
    'prof_hd'      : ['-hd'],
    'prof_hy'      : ['-hy'],
    'prof_hr'      : ['-hr'],
137
    'dyn'          : [],
138
    'static'       : [],
139 140 141 142 143 144 145
    # llvm variants...
    'profllvm'         : ['-p'],
    'profoptllvm'      : ['-hc', '-p'],
    'profthreadedllvm' : ['-p'],
    'threaded1llvm'    : [],
    'threaded2llvm'    : ['-N2 -ls'],
    'dynllvm'          : []
dterei's avatar
dterei committed
146
   }
147

148 149
# Useful classes of ways that can be used with only_ways() and
# expect_broken_for().
150

151 152
prof_ways = map (lambda x: x[0], \
                 filter(lambda x: '-prof' in x[1], \
153
                        config.way_flags('dummy_name').items()))
154

155
threaded_ways = map (lambda x: x[0], \
Simon Marlow's avatar
Simon Marlow committed
156
                 filter(lambda x: '-threaded' in x[1] or 'ghci' == x[0], \
157
                        config.way_flags('dummy_name').items()))
158 159 160

opt_ways = map (lambda x: x[0], \
                 filter(lambda x: '-O' in x[1], \
161
                        config.way_flags('dummy_name').items()))
rwbarton's avatar
rwbarton committed
162 163 164 165

llvm_ways = map (lambda x: x[0], \
                 filter(lambda x: '-fllvm' in x[1], \
                        config.way_flags('dummy_name').items()))
166

167
def get_compiler_info():
dterei's avatar
dterei committed
168
# This should really not go through the shell
169 170
    h = os.popen('"' + config.compiler + '" --info', 'r')
    s = h.read()
171
    s = re.sub('[\r\n]', '', s)
172
    h.close()
173 174 175
    compilerInfoDict = dict(eval(s))
    h = os.popen('"' + config.compiler + '" +RTS --info', 'r')
    s = h.read()
176
    s = re.sub('[\r\n]', '', s)
177 178 179
    h.close()
    rtsInfoDict = dict(eval(s))

180 181 182
    # We use a '/'-separated path for libdir, even on Windows
    config.libdir = re.sub('\\\\','/',compilerInfoDict['LibDir'])

183
    v = compilerInfoDict["Project version"].split('-')
184
    config.compiler_version = v[0]
185
    config.compiler_maj_version = re.sub('^([0-9]+\.[0-9]+).*',r'\1', v[0])
186
    config.compiler_tags = v[1:]
187

188 189 190 191 192
    # -fno-ghci-history was added in 7.3
    if version_ge(config.compiler_version, '7.3'):
       config.compiler_always_flags = \
          config.compiler_always_flags + ['-fno-ghci-history']

193 194
    if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]):
        config.compiler_profiled = True
195
        config.run_ways = filter(lambda x: x != 'ghci', config.run_ways)
196 197 198
    else:
        config.compiler_profiled = False

199
    try:
dterei's avatar
dterei committed
200
        config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache'
201
    except:
dterei's avatar
dterei committed
202
        config.package_conf_cache_file = ''
dterei's avatar
dterei committed
203

204 205 206 207 208 209 210 211 212 213 214 215
    try:
        if compilerInfoDict["GHC Dynamic"] == "YES":
            ghcDynamic = True
        elif compilerInfoDict["GHC Dynamic"] == "NO":
            ghcDynamic = False
        else:
            raise 'Bad value for "GHC Dynamic"'
    except KeyError:
        # GHC < 7.7 doesn't have a "GHC Dynamic" field
        ghcDynamic = False

    if ghcDynamic:
ian@well-typed.com's avatar
ian@well-typed.com committed
216 217 218 219
        config.ghc_th_way_flags = "-dynamic"
        config.ghci_way_flags   = "-dynamic"
        config.ghc_th_way       = "dyn"
        config.ghc_plugin_way   = "dyn"
220
    else:
ian@well-typed.com's avatar
ian@well-typed.com committed
221 222
        config.ghc_th_way_flags = "-static"
        config.ghci_way_flags   = "-static"
223
        config.ghc_th_way       = "normal"
ian@well-typed.com's avatar
ian@well-typed.com committed
224 225
        config.ghc_plugin_way   = "normal"