ghc 4.78 KB
Newer Older
1 2 3 4

import os
import re

5 6 7 8 9 10
# Testsuite configuration setup for GHC
#
# This file is Python source
#
config.compiler_type         = 'ghc'
config.compiler              = 'ghc'
11
config.compiler_always_flags = ['-fforce-recomp', '-dcore-lint', '-dcmm-lint', '-dno-debug-output', '-no-user-package-conf', '-rtsopts']
12

13
config.hp2ps		     = 'hp2ps'
14
config.hpc		     = 'hpc'
15 16 17
config.gs		     = 'gs'
config.confdir               = '.'

andy@galois.com's avatar
andy@galois.com committed
18
# By default, we test the 'normal', 'opt' and 'hpc' ways.
19 20
# '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.
Ian Lynagh's avatar
Ian Lynagh committed
21 22
config.compile_ways	     = ['normal', 'hpc']
config.run_ways		     = ['normal', 'hpc']
23

krc's avatar
krc committed
24
# ways that are not enabled by default, but can always be invoked explicitly
25 26
config.other_ways            = ['extcore','optextcore',
                                'prof_hc_hb','prof_hb',
27
                                'prof_hd','prof_hy','prof_hr',
28
                                'threaded1_ls',
29
                                'threaded2_hT',
dterei's avatar
dterei committed
30
                                'llvm', 'debugllvm']
krc's avatar
krc committed
31

32 33 34 35 36
if (ghc_with_native_codegen == 1):
	config.compile_ways.append('optasm')
	config.run_ways.append('optasm')

if (ghc_with_profiling == 1):
37
	config.have_profiling = True
38 39 40
	if (ghc_with_native_codegen == 1):
		config.compile_ways.append('profasm')
		config.run_ways.append('profasm')
41

42
if (ghc_with_interpreter == 1):
Ian Lynagh's avatar
Ian Lynagh committed
43
	config.have_interp = True
44 45
	config.run_ways.append('ghci')

46 47
config.unregisterised = (ghc_unregisterised == 1)

48
if (ghc_with_threaded_rts == 1):
49
	config.run_ways.append('threaded1')
50 51
	if (ghc_with_smp == 1):
		config.run_ways.append('threaded2')
52

53
if (ghc_with_dynamic_rts == 1):
Simon Marlow's avatar
Simon Marlow committed
54
        config.have_shared_libs = True
55 56
	config.run_ways.append('dyn')

57 58 59
if (ghc_with_profiling == 1 and ghc_with_threaded_rts == 1):
        config.run_ways.append('profthreaded')

60 61 62
if (ghc_with_llvm == 1):
        config.run_ways.append('optllvm')

63 64
config.in_tree_compiler = in_tree_compiler

65 66
config.way_flags = {
	'normal'     : [],
67 68
        'g1'         : [],
        'optasm'     : ['-O -fasm'],
69 70
	'llvm'       : ['-fllvm'],
	'optllvm'    : ['-O -fllvm'],
dterei's avatar
dterei committed
71
	'debugllvm'    : ['-fllvm -keep-llvm-files'],
72
	'profasm'    : ['-O -prof -auto-all -fasm'],
Simon Marlow's avatar
Simon Marlow committed
73
	'profthreaded' : ['-O -prof -auto-all -fasm -threaded'],
74
	'ghci'       : ['--interactive', '-v0', '-ignore-dot-ghci', '+RTS', '-I0.1', '-RTS'],
75 76
	'extcore'    : ['-fext-core'],
	'optextcore' : ['-O -fext-core'],
77 78 79
        'threaded1'  : ['-threaded', '-debug'],
        'threaded1_ls'  : ['-threaded', '-debug'],
        'threaded2'  : ['-O', '-threaded', '-eventlog'],
80 81
        'threaded2_hT'  : ['-O', '-threaded'],
        'hpc'        : ['-O', '-fhpc' ],
82 83 84 85
        'prof_hc_hb' : ['-O -prof -auto-all'],
        'prof_hb'    : ['-O -prof -auto-all'],
        'prof_hd'    : ['-O -prof -auto-all'],
        'prof_hy'    : ['-O -prof -auto-all'],
86 87
        'prof_hr'    : ['-O -prof -auto-all'],
        'dyn'        : ['-O -dynamic']
88 89 90
	}

config.way_rts_flags = { 
91 92 93
        'normal'     : [],
        'g1'         : ['-G1'],
        'optasm'     : [],
94 95
	'llvm'       : [],
	'optllvm'    : [],
dterei's avatar
dterei committed
96
	'debugllvm'  : [],
97
	'profasm'    : ['-hc'], # test heap profiling too
Simon Marlow's avatar
Simon Marlow committed
98
	'profthreaded' : ['-p'],
99 100
	'ghci'       : [],
	'extcore'    : [],
101
        'optextcore' : [],
102
	'threaded1'  : [],
103 104
        'threaded1_ls'  : ['-ls'],
        'threaded2'  : ['-N2 -ls'],
105 106
        'threaded2_hT'  : ['-N2', '-hT'],
        'hpc'        : [],
107 108 109 110
        'prof_hc_hb' : ['-hc -hbvoid'],
        'prof_hb'    : ['-hb'],
        'prof_hd'    : ['-hd'],
        'prof_hy'    : ['-hy'],
111 112
        'prof_hr'    : ['-hr'],
        'dyn'        : []
113
    	}
114

115 116 117
# Useful classes of ways:

prof_ways = filter(lambda x: x in config.run_ways, 
Ian Lynagh's avatar
Ian Lynagh committed
118
                   ['profasm','profthreaded'])
119 120 121 122

threaded_ways = filter(lambda x: x in config.run_ways, 
                       ['threaded1','threaded2','ghci','profthreaded'])

123
def get_compiler_info():
Ian Lynagh's avatar
Ian Lynagh committed
124
    # This should really not go through the shell
125 126
    h = os.popen('"' + config.compiler + '" --info', 'r')
    s = h.read()
127
    s = re.sub('[\r\n]', '', s)
128
    h.close()
129 130 131
    compilerInfoDict = dict(eval(s))
    h = os.popen('"' + config.compiler + '" +RTS --info', 'r')
    s = h.read()
132
    s = re.sub('[\r\n]', '', s)
133 134 135 136
    h.close()
    rtsInfoDict = dict(eval(s))

    v = compilerInfoDict["Project version"].split('-')
137
    config.compiler_version = v[0]
138
    config.compiler_maj_version = re.sub('^([0-9]+\.[0-9]+).*',r'\1', v[0])
139
    config.compiler_tags = v[1:]
140

141 142
    if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]):
        config.compiler_profiled = True
143
        config.run_ways = filter(lambda x: x != 'ghci', config.run_ways)
144 145 146
    else:
        config.compiler_profiled = False

147 148 149 150
    try:
            config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache'
    except:
            config.package_conf_cache_file = ''