-
Notifications
You must be signed in to change notification settings - Fork 0
/
lts
executable file
·96 lines (84 loc) · 2.96 KB
/
lts
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import argparse
import shutil
import subprocess
import logging
import shlex
class Builder(object):
def __init__(self, config):
self.config = config
def FindTool(self, name):
return os.path.abspath(
shutil.which(name,
path=os.path.join(self.config.llvm_build_dir, 'bin')))
def ConfigAndBuild(self):
err = self.Config()
if err != 0:
return
return self.Build()
def Config(self):
cflags = [
'-pipe',
'-march=native',
]
cxxflags = cflags[:]
if self.config.cflags:
cflags.extend(shlex.split(self.config.cflags))
if self.config.cxxflags:
cxxflags.extend(shlex.split(self.config.cxxflags))
ldflags = [
'--ld-path={}'.format(self.FindTool('ld.lld')),
]
cmd = [
self.config.cmake_binary,
'-GNinja',
'-DCMAKE_BUILD_TYPE=Release',
'-DTEST_SUITE_USE_PERF=ON',
'-DCMAKE_C_COMPILER={}'.format(self.FindTool('clang')),
'-DCMAKE_CXX_COMPILER={}'.format(self.FindTool('clang++')),
'-DCMAKE_C_FLAGS={}'.format(shlex.join(cflags)),
'-DCMAKE_CXX_FLAGS={}'.format(shlex.join(cxxflags)),
'-DCMAKE_EXE_LINKER_FLAGS={}'.format(shlex.join(ldflags)),
'-S',
os.path.abspath(self.config.src_dir),
'-B',
os.path.abspath(self.config.build_dir),
]
if self.config.benchmarks_only:
cmd.append('-DTEST_SUITE_BENCHMARKING_ONLY=ON')
cmd.append('-DTEST_SUITE_SUBDIRS=SingleSource;MultiSource')
err = subprocess.call(cmd)
if err != 0:
logging.error('cmake failed: {}'.format(cmd))
return err
def Build(self):
cmd = [
self.config.ninja_binary,
'-C',
os.path.abspath(self.config.build_dir),
'-j{}'.format(self.config.njobs),
]
err = subprocess.call(cmd)
if err != 0:
logging.error('ninja failed: {}'.format(cmd))
return err
def main():
parser = argparse.ArgumentParser(description='Build LLVM test suite')
parser.add_argument('--src_dir', required=True)
parser.add_argument('--build_dir', required=True)
parser.add_argument('--llvm_build_dir', required=True)
parser.add_argument('--benchmarks_only',
action='store_true',
default=False)
parser.add_argument('--cmake_binary', default=shutil.which('cmake'))
parser.add_argument('--ninja_binary', default=shutil.which('ninja'))
parser.add_argument('--cflags')
parser.add_argument('--cxxflags')
parser.add_argument('-j', dest='njobs', type=int, default=os.cpu_count())
config = parser.parse_args()
return Builder(config).ConfigAndBuild()
if __name__ == '__main__':
sys.exit(main())