ghc 6.82 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
dterei's avatar
dterei committed
24
config.other_ways         = ['extcore','optextcore',
25
                             'prof',
dterei's avatar
dterei committed
26 27 28
                             'prof_hc_hb','prof_hb',
                             'prof_hd','prof_hy','prof_hr',
                             'threaded1_ls', 'threaded2_hT',
29 30 31 32
                             'llvm', 'debugllvm',
                             'profllvm', 'profoptllvm', 'profthreadedllvm',
                             'threaded1llvm', 'threaded2llvm',
                             'dynllvm']
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
if (ghc_with_profiling == 1):
dterei's avatar
dterei committed
44
    config.have_profiling = True
45 46
    config.compile_ways.append('profasm')
    config.run_ways.append('profasm')
47

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

52 53
config.unregisterised = (ghc_unregisterised == 1)

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

60 61 62
if (ghc_with_dynamic_rts == 1):
    config.have_shared_libs = True

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

70
if (ghc_with_profiling == 1 and ghc_with_threaded_rts == 1):
dterei's avatar
dterei committed
71
    config.run_ways.append('profthreaded')
72

73
if (ghc_with_llvm == 1):
dterei's avatar
dterei committed
74
    config.compile_ways.append('optllvm')
dterei's avatar
dterei committed
75
    config.run_ways.append('optllvm')
76

77
config.in_tree_compiler = in_tree_compiler
78
config.clean_only       = clean_only
79

80
config.way_flags = {
dterei's avatar
dterei committed
81 82
    'normal'       : [],
    'g1'           : [],
83
    'optasm'       : ['-O', '-fasm'],
dterei's avatar
dterei committed
84
    'llvm'         : ['-fllvm'],
85
    'optllvm'      : ['-O', '-fllvm'],
dterei's avatar
dterei committed
86
    'debugllvm'    : ['-fllvm', '-keep-llvm-files'],
87 88 89
    'prof'         : ['-prof', '-static', '-auto-all', '-fasm'],
    'profasm'      : ['-O', '-prof', '-static', '-auto-all'],
    'profthreaded' : ['-O', '-prof', '-static', '-auto-all', '-threaded'],
dterei's avatar
dterei committed
90 91
    'ghci'         : ['--interactive', '-v0', '-ignore-dot-ghci', '+RTS', '-I0.1', '-RTS'],
    'extcore'      : ['-fext-core'],
92
    'optextcore'   : ['-O', '-fext-core'],
dterei's avatar
dterei committed
93 94 95 96 97
    'threaded1'    : ['-threaded', '-debug'],
    'threaded1_ls' : ['-threaded', '-debug'],
    'threaded2'    : ['-O', '-threaded', '-eventlog'],
    'threaded2_hT' : ['-O', '-threaded'],
    'hpc'          : ['-O', '-fhpc' ],
98 99 100 101 102
    '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'],
103
    'dyn'          : ['-O', '-dynamic'],
104
    'static'       : ['-O', '-static'],
105
    # llvm variants...
106 107 108
    'profllvm'         : ['-prof', '-static', '-auto-all', '-fllvm'],
    'profoptllvm'      : ['-O', '-prof', '-static', '-auto-all', '-fllvm'],
    'profthreadedllvm' : ['-O', '-prof', '-static', '-auto-all', '-threaded', '-fllvm'],
109 110 111
    'threaded1llvm'    : ['-threaded', '-debug', '-fllvm'],
    'threaded2llvm'    : ['-O', '-threaded', '-eventlog', '-fllvm'],
    'dynllvm'          : ['-O', '-dynamic', '-fllvm']
dterei's avatar
dterei committed
112
   }
113 114

config.way_rts_flags = { 
dterei's avatar
dterei committed
115 116 117 118 119 120
    'normal'       : [],
    'g1'           : ['-G1'],
    'optasm'       : [],
    'llvm'         : [],
    'optllvm'      : [],
    'debugllvm'    : [],
121 122
    'prof'         : ['-p'],
    'profasm'      : ['-hc', '-p'], # test heap profiling too
dterei's avatar
dterei committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136
    'profthreaded' : ['-p'],
    'ghci'         : [],
    'extcore'      : [],
    'optextcore'   : [],
    '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 153
prof_ways = map (lambda x: x[0], \
                 filter(lambda x: '-prof' in x[1], \
                        config.way_flags.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 158 159 160 161
                        config.way_flags.items()))

opt_ways = map (lambda x: x[0], \
                 filter(lambda x: '-O' in x[1], \
                        config.way_flags.items()))
162

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

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

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

184 185 186 187 188
    # -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']

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

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