ghc 7.39 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               = '.'

thomie's avatar
thomie committed
17 18 19 20 21
# By default, the 'normal' and 'hpc' ways are enabled. In addition, certain
# ways are enabled automatically if this GHC supports them. Ways that fall in
# this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2',
# 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's
# default mode. Other ways should be set explicitly from .T files.
dterei's avatar
dterei committed
22 23
config.compile_ways       = ['normal', 'hpc']
config.run_ways           = ['normal', 'hpc']
24

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

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

38 39
config.compiler_debugged = ghc_debugged

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

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

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

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

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

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

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

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

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

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

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

82
config.in_tree_compiler = in_tree_compiler
83
config.clean_only       = clean_only
84

85
config.way_flags = lambda name : {
dterei's avatar
dterei committed
86 87
    'normal'       : [],
    'g1'           : [],
88
    'optasm'       : ['-O', '-fasm'],
dterei's avatar
dterei committed
89
    'llvm'         : ['-fllvm'],
90
    'optllvm'      : ['-O', '-fllvm'],
dterei's avatar
dterei committed
91
    'debugllvm'    : ['-fllvm', '-keep-llvm-files'],
92 93 94
    'prof'         : ['-prof', '-static', '-auto-all', '-fasm'],
    'profasm'      : ['-O', '-prof', '-static', '-auto-all'],
    'profthreaded' : ['-O', '-prof', '-static', '-auto-all', '-threaded'],
dterei's avatar
dterei committed
95 96 97 98 99
    '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'],
100
    'hpc'          : ['-O', '-fhpc', '-hpcdir', '.hpc.' + name ],
101 102 103 104 105
    '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'],
106
    'dyn'          : ['-O', '-dynamic'],
107
    'static'       : ['-O', '-static'],
108
    'debug'        : ['-O', '-g', '-dannot-lint'],
109
    # llvm variants...
110 111 112
    'profllvm'         : ['-prof', '-static', '-auto-all', '-fllvm'],
    'profoptllvm'      : ['-O', '-prof', '-static', '-auto-all', '-fllvm'],
    'profthreadedllvm' : ['-O', '-prof', '-static', '-auto-all', '-threaded', '-fllvm'],
dterei's avatar
dterei committed
113
   }
114 115

config.way_rts_flags = { 
dterei's avatar
dterei committed
116 117 118 119 120 121
    'normal'       : [],
    'g1'           : ['-G1'],
    'optasm'       : [],
    'llvm'         : [],
    'optllvm'      : [],
    'debugllvm'    : [],
122 123
    'prof'         : ['-p'],
    'profasm'      : ['-hc', '-p'], # test heap profiling too
dterei's avatar
dterei committed
124 125 126 127 128 129 130 131 132 133 134 135
    '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'],
136
    'dyn'          : [],
137
    'static'       : [],
138
    'debug'        : [],
139 140 141 142
    # llvm variants...
    'profllvm'         : ['-p'],
    'profoptllvm'      : ['-hc', '-p'],
    'profthreadedllvm' : ['-p'],
dterei's avatar
dterei committed
143
   }
144

145 146
# Useful classes of ways that can be used with only_ways() and
# expect_broken_for().
147

148 149
prof_ways     = [x[0] for x in config.way_flags('dummy_name').items()
                      if '-prof' in x[1]]
150

151 152
threaded_ways = [x[0] for x in config.way_flags('dummy_name').items()
                      if '-threaded' in x[1] or 'ghci' == x[0]]
153

154 155
opt_ways      = [x[0] for x in config.way_flags('dummy_name').items()
                      if '-O' in x[1]]
rwbarton's avatar
rwbarton committed
156

157 158
llvm_ways     = [x[0] for x in config.way_flags('dummy_name').items()
                      if '-fflvm' in x[1]]
159

160
def get_compiler_info():
dterei's avatar
dterei committed
161
# This should really not go through the shell
162
    h = os.popen(config.compiler + ' --info', 'r')
163
    s = h.read()
164
    s = re.sub('[\r\n]', '', s)
165
    h.close()
166
    compilerInfoDict = dict(eval(s))
167
    h = os.popen(config.compiler + ' +RTS --info', 'r')
168
    s = h.read()
169
    s = re.sub('[\r\n]', '', s)
170 171 172
    h.close()
    rtsInfoDict = dict(eval(s))

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

176
    v = compilerInfoDict["Project version"].split('-')
177
    config.compiler_version = v[0]
178
    config.compiler_maj_version = re.sub('^([0-9]+\.[0-9]+).*',r'\1', v[0])
179
    config.compiler_tags = v[1:]
180

181 182 183 184 185
    # -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']

186 187
    if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]):
        config.compiler_profiled = True
188
        config.run_ways = [x for x in config.run_ways if x != 'ghci']
189 190 191
    else:
        config.compiler_profiled = False

192
    try:
dterei's avatar
dterei committed
193
        config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache'
194
    except:
dterei's avatar
dterei committed
195
        config.package_conf_cache_file = ''
dterei's avatar
dterei committed
196

197 198 199 200 201 202 203 204 205 206 207 208
    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
209 210 211 212
        config.ghc_th_way_flags = "-dynamic"
        config.ghci_way_flags   = "-dynamic"
        config.ghc_th_way       = "dyn"
        config.ghc_plugin_way   = "dyn"
213
    else:
ian@well-typed.com's avatar
ian@well-typed.com committed
214 215
        config.ghc_th_way_flags = "-static"
        config.ghci_way_flags   = "-static"
216
        config.ghc_th_way       = "normal"
ian@well-typed.com's avatar
ian@well-typed.com committed
217 218
        config.ghc_plugin_way   = "normal"