-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
98 lines (79 loc) · 3.5 KB
/
SConstruct
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# $lic$
# Copyright (C) 2015-2020 by Massachusetts Institute of Technology
#
# This file is part of libspin.
#
# libspin is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.
#
# libspin was developed as part of the Swarm architecture simulator. If you
# use this software in your research, we request that you reference the Swarm
# paper ("A Scalable Architecture for Ordered Parallelism", Jeffrey et al.,
# MICRO-48, 2015) as the source of libspin in any publications that use this
# software, and that you send us a citation of your work.
#
# libspin 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 GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
import os
AddOption('--libspinMode', type='choice', choices=['debug', 'opt', 'release'], default='opt')
mode = GetOption('libspinMode')
env = Environment(ENV = os.environ)
env['CPPFLAGS'] = ['-std=c++11', '-Wall', '-Werror', '-Wno-unknown-pragmas',
'-fomit-frame-pointer', '-fno-stack-protector',
'-fabi-version=2', '-D_GLIBCXX_USE_CXX11_ABI=0']
env['CPPPATH'] = [os.path.abspath('include/')]
modeFlags = {
'opt' : ['-O3','-gdwarf-3'],
'release' : ['-O3', '-DNDEBUG', '-DNASSERT', '-gdwarf-3', '-Wno-unused-variable'],
'debug' : ['-O0', '-gdwarf-3'],
}
archFlags = ['-march=core2']
env.Append(CPPFLAGS = modeFlags[mode] + archFlags)
# Environment for library (paths assume Pin 2.14)
pinEnv = env.Clone()
pinEnv.Append(CPPFLAGS = ['-fPIC', '-MMD'])
pinEnv.Append(CPPDEFINES = [('BIGARRAY_MULTIPLIER',1), 'USING_XED',
'TARGET_IA32E', 'HOST_IA32E', 'TARGET_LINUX'])
PINPATH = os.environ['PIN_HOME'] if 'PIN_HOME' in os.environ \
else os.environ['PINPATH']
pinEnv.Append(CPPPATH =
[os.path.join(PINPATH, dir) for dir in (
'extras/xed-intel64/include',
'source/include',
# [mcj] the following directory is only needed because pin doesn't use
# relative paths correctly... weird
'source/include/pin/gen',
'extras/components/include')])
pinEnv.Append(LIBPATH = [os.path.join(PINPATH, dir) for dir in (
'extras/xed-intel64/lib', 'intel64/lib', 'intel64/lib-ext')])
pinEnv.Append(LIBS = ['pin', 'xed', 'dl', 'rt', 'pindwarf'])
pinverspath = os.path.join(PINPATH, 'source/include/pin/pintool.ver')
assert os.path.exists(pinverspath), pinverspath
pinEnv.Append(LINKFLAGS = ['-Wl,--hash-style=sysv',
'-Wl,--version-script=' + pinverspath, '-Wl,-Bsymbolic', '-shared'])
slowLib, fastLib = SConscript('lib/SConscript',
variant_dir = os.path.join('build', mode, 'lib'),
exports = {'env' : pinEnv},
duplicate = 0)
for spinLib, speed in [(slowLib, 'slow'), (fastLib, 'fast')]:
toolEnv = pinEnv.Clone()
toolEnv.Prepend(LIBS = [spinLib])
if speed == 'slow':
toolEnv.Append(CPPDEFINES = 'SPIN_SLOW')
SConscript('tools/SConscript',
variant_dir = os.path.join('build', mode, 'tools_{}'.format(speed)),
exports = {'env' : toolEnv},
duplicate = 0)
testEnv = env.Clone()
testEnv.Append(LIBS = ['pthread'])
SConscript('tests/SConscript',
variant_dir = os.path.join('build', mode, 'tests'),
exports = {'env' : testEnv},
duplicate = 0)