MCPcopy Create free account
hub / github.com/ClangBuiltLinux/tc-build / BinutilsBuilder

Class BinutilsBuilder

tc_build/binutils.py:12–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class BinutilsBuilder(Builder):
13 def __init__(self) -> None:
14 super().__init__()
15
16 self.cflags: list[str] = ['-O2']
17 self.configure_flags: tc_build.utils.CmdList = [
18 '--disable-compressed-debug-sections',
19 '--disable-gdb',
20 '--disable-gprofng',
21 '--disable-nls',
22 '--disable-werror',
23 '--enable-deterministic-archives',
24 '--enable-new-dtags',
25 '--enable-plugins',
26 '--enable-threads',
27 '--quiet',
28 '--with-system-zlib',
29 ]
30
31 self.configure_vars: dict[str, str] = {
32 'CC': 'gcc',
33 'CXX': 'g++',
34 }
35 self.extra_targets: list[str] = []
36 self.native_arch: str = ''
37 self.target: str = ''
38
39 def build(self) -> None:
40 if tc_build.utils.path_is_set(self.folders.install):
41 self.configure_flags.append(f"--prefix={self.folders.install}")
42 if platform.machine() != self.native_arch:
43 self.configure_flags += [
44 f"--program-prefix={self.target}-",
45 f"--target={self.target}",
46 ]
47 if self.extra_targets:
48 self.configure_flags.append(f"--enable-targets={','.join(self.extra_targets)}")
49
50 self.configure_vars['CFLAGS'] = ' '.join(self.cflags)
51 self.configure_vars['CXXFLAGS'] = ' '.join(self.cflags)
52
53 # Avoid "input SFrame sections with different format versions prevent
54 # .sframe generation" error by discarding .sframe altogether if
55 # possible, as we may be linking against libraries with their own
56 # .sframe sections and versions.
57 ld_help = subprocess.run(
58 ['ld', '--help'], capture_output=True, check=True, text=True
59 ).stdout
60 if '--discard-sframe' in ld_help:
61 self.configure_vars['LDFLAGS'] = '-Wl,--discard-sframe'
62
63 self.clean_build_folder()
64 self.folders.build.mkdir(exist_ok=True, parents=True)
65 tc_build.utils.print_header(f"Building {self.target} binutils")
66
67 # Binutils does not provide a configuration flag to disable installation of documentation directly.
68 # Instead, we redirect generated docs to a temporary directory, deleting them after installation.
69 with TemporaryDirectory() as tmpdir:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected