Skip to content

Commit

Permalink
build-llvm.py: Convert '--debug' into '--build-type'
Browse files Browse the repository at this point in the history
Right now, the LLVM tests are only runnable when specifying '--debug'.
However, some users want to be able to run the LLVM tests on a release
build so they don't have to suffer with slower build times. The real
intention behind '--debug' was just the changing of CMAKE_BUILD_TYPE so
convert '--debug' into '--build-type' and unhook the LLVM tests from
that option.

We only save 29 targets (3783 -> 3752) by turning off LLVM_INCLUDE_TESTS
(tested with '--build-stage1-only') so there is no point in adding an
option to enable/disable that option.

LLVM_BUILD_TESTS is not needed to run tests so omit setting a value for
it.

Closes: ClangBuiltLinux#42
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
  • Loading branch information
nathanchance committed Jul 29, 2019
1 parent d61dec9 commit 4b6b278
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions build-llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ def parse_parameters(root_folder):
"""),
action="store_true")
parser.add_argument("--build-type",
help=textwrap.dedent("""\
By default, the script does a Release build; Debug may be useful for tracking down
particularly nasty bugs.
See https://llvm.org/docs/GettingStarted.html#compiling-the-llvm-suite-source-code for
more information.
"""),
type=str,
default="Release")
parser.add_argument("--clang-vendor",
help=textwrap.dedent("""\
Add this value to the clang version string (like "Apple clang version..." or
Expand All @@ -101,17 +112,6 @@ def parse_parameters(root_folder):
"""),
type=str,
default="ClangBuiltLinux")
parser.add_argument("-d",
"--debug",
help=textwrap.dedent("""\
By default, the script builds LLVM in the release configuration with all of
the tests turned off and optimization at O2. This disables that optimization,
builds the tests, and changes the configuration to debug. This can help with
reporting problems to LLVM developers but will make compilation of both LLVM
and the kernel go slower.
"""),
action="store_true")
parser.add_argument("-i",
"--incremental",
help=textwrap.dedent("""\
Expand Down Expand Up @@ -588,19 +588,17 @@ def stage_specific_cmake_defines(args, dirs, stage):
defines['LLVM_INCLUDE_TESTS'] = 'OFF'
defines['LLVM_INCLUDE_UTILS'] = 'OFF'
else:
# If a debug build was requested
if args.debug:
defines['CMAKE_BUILD_TYPE'] = 'Debug'
defines['LLVM_BUILD_TESTS'] = 'ON'
# If a release build was requested
else:
defines['CMAKE_BUILD_TYPE'] = 'Release'
# https://llvm.org/docs/CMake.html#frequently-used-cmake-variables
defines['CMAKE_BUILD_TYPE'] = args.build_type.capitalize()

# We don't care about warnings if we are building a release build
if args.build_type.lower() == "release":
defines['LLVM_ENABLE_WARNINGS'] = 'OFF'
defines['LLVM_INCLUDE_TESTS'] = 'OFF'
# Build with assertions enabled if requested (will slow down compilation
# so it is not on by default)
if args.assertions:
defines['LLVM_ENABLE_ASSERTIONS'] = 'ON'

# Build with assertions enabled if requested (will slow down compilation
# so it is not on by default)
if args.assertions:
defines['LLVM_ENABLE_ASSERTIONS'] = 'ON'

# Where the toolchain should be installed
defines['CMAKE_INSTALL_PREFIX'] = dirs.install_folder.as_posix()
Expand Down

0 comments on commit 4b6b278

Please sign in to comment.