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
|
# Configures the build to use the GCC toolchain in /opt/mongodbtoolchain/v4
import os
import subprocess
import SCons.Defaults
toolchain_root = SCons.Script.Main.GetOption('toolchain-root')
if not toolchain_root:
toolchain_root = '/opt/mongodbtoolchain/v4'
toolchain_bindir = os.path.join(toolchain_root, 'bin')
# Get the default SCons path as a list
default_path = SCons.Defaults.DefaultEnvironment()['ENV']['PATH'].split(os.pathsep)
# Put the toolchain path first so we prefer all tools from there in subprocs
ENV = {
'PATH' : os.pathsep.join([toolchain_bindir] + default_path)
}
# TODO BUILD-16594
# This is temporary workaround so that gcc can find the LLVM lld from the toolchain
# until we can build this into the toolchain's default search paths
LINKFLAGS_COMPILER_EXEC_PREFIX = f'{toolchain_bindir}'
# Set any Variables for Tools from the toolchain here. Technically, we
# shouldn't need the full paths since SCons will find the toolchain
# ones first, but we don't want to accidentally get the system version
# if, say, the toolchain is missing. Also, it is clearer that we are
# getting the right toolchain in build log output when the path is
# printed for each compiler invocation.
CC = os.path.join(toolchain_bindir, 'clang')
CXX = os.path.join(toolchain_bindir, 'clang++')
DWP = os.path.join(toolchain_bindir, 'dwp')
READELF = os.path.join(toolchain_bindir, 'readelf')
try:
AR = subprocess.check_output([CXX, '-print-prog-name=ar']).decode('utf-8').strip()
AS = subprocess.check_output([CXX, '-print-prog-name=as']).decode('utf-8').strip()
OBJCOPY = subprocess.check_output([CXX, '-print-prog-name=objcopy']).decode('utf-8').strip()
LLVM_SYMBOLIZER = subprocess.check_output([CXX, '-print-prog-name=llvm-symbolizer']).decode('utf-8').strip()
except subprocess.CalledProcessError as e:
print("Failed while invoking toolchain binary " + CXX + ": " + e.output)
SCons.Script.Exit(-1)
except OSError as e:
print("Failed to invoke toolchain binary " + CXX + ": " + str(e))
SCons.Script.Exit(-1)
link_model = SCons.Script.Main.GetOption('link-model')
if link_model == 'dynamic':
DWARF_VERSION=4
else:
DWARF_VERSION=5
|