Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-llvm.py: Add '--build-targets' #247

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions build-llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@

'''),
type=str)
parser.add_argument('--build-targets',
default=['all'],
help=textwrap.dedent('''\
By default, the 'all' target is used as the build target for the final stage. With
this option, targets such as 'distribution' could be used to generate a slimmer
toolchain or targets such as 'clang' or 'llvm-ar' could be used to just test building
individual tools for a bisect.

NOTE: This only applies to the final stage build to avoid complicating tc-build internals.
'''),
nargs='+')
parser.add_argument('--bolt',
help=textwrap.dedent('''\
Optimize the final clang binary with BOLT (Binary Optimization and Layout Tool), which can
Expand Down Expand Up @@ -526,6 +537,7 @@
tc_build.utils.print_header('Building LLVM (bootstrap)')

bootstrap = LLVMBootstrapBuilder()
bootstrap.build_targets = ['distribution']
bootstrap.ccache = not args.no_ccache
bootstrap.cmake_defines.update(common_cmake_defines)
bootstrap.folders.build = Path(build_folder, 'bootstrap')
Expand All @@ -540,7 +552,7 @@

bootstrap.check_dependencies()
bootstrap.configure()
bootstrap.build('distribution')
bootstrap.build()

# If the user did not specify CMAKE_C_FLAGS or CMAKE_CXX_FLAGS, add them as empty
# to paste stage 2 to ensure there are no environment issues (since CFLAGS and CXXFLAGS
Expand All @@ -558,6 +570,7 @@
instrumented = LLVMInstrumentedBuilder()
else:
instrumented = LLVMSlimInstrumentedBuilder()
instrumented.build_targets = ['all' if args.full_toolchain else 'distribution']
instrumented.cmake_defines.update(common_cmake_defines)
# We run the tests on the instrumented stage if the LLVM benchmark was enabled
instrumented.check_targets = args.check_targets if 'llvm' in args.pgo else None
Expand All @@ -571,7 +584,7 @@

tc_build.utils.print_header('Building LLVM (instrumented)')
instrumented.configure()
instrumented.build('all' if args.full_toolchain else 'distribution')
instrumented.build()

tc_build.utils.print_header('Generating PGO profiles')
pgo_builders = []
Expand Down Expand Up @@ -648,6 +661,7 @@
instrumented.generate_profdata()

# Final build
final.build_targets = args.build_targets
final.check_targets = args.check_targets
final.cmake_defines.update(common_cmake_defines)
final.folders.build = Path(build_folder, 'final')
Expand Down
5 changes: 3 additions & 2 deletions tc_build/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self):

self.bolt = False
self.bolt_builder = None
self.build_targets = ['all']
self.ccache = False
self.check_targets = []
# Removes system dependency on terminfo to keep the dynamic library
Expand Down Expand Up @@ -133,7 +134,7 @@ def bolt_clang(self):
if mode == 'instrumentation':
clang_inst.unlink()

def build(self, build_target='all'):
def build(self):
if not self.folders.build:
raise RuntimeError('No build folder set for build()?')
if not Path(self.folders.build, 'build.ninja').exists():
Expand All @@ -142,7 +143,7 @@ def build(self, build_target='all'):
raise RuntimeError('BOLT requested without a builder?')

build_start = time.time()
ninja_cmd = ['ninja', '-C', self.folders.build, build_target]
ninja_cmd = ['ninja', '-C', self.folders.build, *self.build_targets]
self.run_cmd(ninja_cmd)

if self.check_targets:
Expand Down