-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcc-lto-stream-version.py
executable file
·57 lines (48 loc) · 1.9 KB
/
gcc-lto-stream-version.py
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
#!/usr/bin/env python3
import os
import shutil
import subprocess
import sys
from pathlib import Path
from git import Repo
git = Path(sys.argv[1]).resolve()
repo = Repo(git)
branches = [11, 12, 13]
objdir = '/dev/shm/buildbot-lto-stream'
source = '/home/marxin/Programming/tramp3d/tramp3d-v4.ii'
obj = '/dev/shm/tramp3d-v4.o'
pwd = os.getcwd()
def clean_temp():
shutil.rmtree(objdir, ignore_errors=True)
def build_compiler(revision):
print(f'Building {revision}', flush=True)
repo.git.checkout(revision)
clean_temp()
os.mkdir(objdir)
os.chdir(objdir)
subprocess.check_output(f'{git}/configure --enable-languages=c,c++,lto '
'--disable-multilib --disable-libsanitizer --disable-bootstrap',
shell=True,
stderr=subprocess.DEVNULL)
subprocess.check_output('make -j`nproc`', shell=True, stderr=subprocess.DEVNULL)
for branch in reversed(branches):
tip = f'origin/releases/gcc-{branch}'
basepoint = f'basepoints/gcc-{branch + 1}'
interval = f'{basepoint}..{tip}'
changes = repo.blame(interval, 'gcc/lto-streamer.h')
last_bump = None
for change in changes:
for line in change[1]:
if line.startswith('#define LTO_minor_version') or line.startswith('#define LTO_major_version'):
commit = change[0]
if not last_bump or commit.committed_datetime > last_bump.committed_datetime:
last_bump = commit
print(f'gcc-{branch} last time bumped in {last_bump}', flush=True)
build_compiler(last_bump)
subprocess.check_output(f'./gcc/xg++ -Bgcc -O2 -c -std=c++98 -flto=16 {source} -o {obj}', shell=True)
build_compiler(tip)
try:
subprocess.check_output(f'./gcc/xg++ -Bgcc -O2 -flto=16 {obj} -L ./x86_64-pc-linux-gnu/libstdc++-v3/src/.libs',
shell=True)
finally:
clean_temp()