Skip to content

Commit 88da17f

Browse files
committed
[build-script] If we are not testing Swift as well as not testing LLVM, disable
all parts of LLVM that are not needed for compiling Swift.
1 parent bca0802 commit 88da17f

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

utils/build-script-impl

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,13 @@ function set_build_options_for_host() {
675675
# *NOTE* Currently we do not support testing LLVM via build-script. But in a
676676
# future commit we will.
677677
if [[ $(false_true "${LLVM_INCLUDE_TESTS}") == "TRUE" ]]; then
678-
llvm_cmake_options+=(
678+
EXTRA_LLVM_CMAKE_OPTIONS=(
679679
# Do not include LLVM tests.
680680
-DLLVM_INCLUDE_TESTS:BOOL=NO
681681
-DCLANG_INCLUDE_TESTS:BOOL=NO
682682
)
683683

684-
# Disable LLVM Tools that we do not use.
684+
# Disable LLVM Tools that Swift does not use for testing.
685685
LLVM_TOOLS_TO_DISABLE=(
686686
BUGPOINT BUGPOINT_PASSES GOLD LLI LLVM_AS_FUZZER LLVM_C_TEST
687687
LLVM_CXXDUMP LLVM_DIFF LLVM_DIS LLVM_DWP LLVM_EXTRACT LLVM_GO
@@ -690,21 +690,58 @@ function set_build_options_for_host() {
690690
LLVM_STRESS LLVM_SYMBOLIZER MSBUILD OBJ2YAML OPT SANCOV SANSTATS
691691
VERIFY_USELISTORDER XCODE_TOOLCHAIN YAML2OBJ
692692
)
693+
694+
# Disable Clang Tools that Swift does not use for testing.
695+
CLANG_TOOLS_TO_DISABLE=(
696+
CLANG_CHECK DIAGTOOL SCAN_BUILD SCAN_VIEW CLANG_FORMAT
697+
)
698+
699+
# If in addition we are asked to not generate targets for swift tests,
700+
# then we can disable the building of even more of LLVM.
701+
if [[ $(false_true "${SWIFT_INCLUDE_TESTS}") == "TRUE" ]]; then
702+
EXTRA_LLVM_CMAKE_OPTIONS+=(
703+
# We do not need gtest/FileCheck and friends since we are not
704+
# running any tests.
705+
-DLLVM_INCLUDE_UTILS:BOOL=NO
706+
)
707+
708+
# Disable the rest of the LLVM tools. We do not need any of them.
709+
LLVM_TOOLS_TO_DISABLE+=(
710+
DSYMUTIL LLC LLVM_AR LLVM_AS LLVM_BCANALYZER LLVM_COV
711+
LLVM_DWARFDUMP LLVM_LINK LLVM_NM LLVM_OBJDUMP LLVM_PROFDATA
712+
)
713+
714+
# Disable the rest of the Clang tools. We do not need them.
715+
CLANG_TOOLS_TO_DISABLE+=(
716+
ARCMT_TEST C_ARCMT_TEST C_INDEX_TEST
717+
)
718+
719+
# If in addition, we are not building compiler-rt, then we do not
720+
# even need to build clang.
721+
#
722+
# *NOTE* This may change once we start building the standard library
723+
# *with the just built clang.
724+
if [[ $(true_false "${SKIP_BUILD_COMPILER_RT}") == "TRUE" ]]; then
725+
CLANG_TOOLS_TO_DISABLE+=(
726+
DRIVER
727+
)
728+
fi
729+
fi
730+
731+
for arg in "${EXTRA_LLVM_CMAKE_ARGS[@]}"; do
732+
llvm_cmake_options+=( "${arg}" )
733+
done
693734
for tool in "${LLVM_TOOLS_TO_DISABLE[@]}"; do
694735
llvm_cmake_options+=(
695736
-DLLVM_TOOL_${tool}_BUILD:BOOL=NO
696737
)
697738
done
698739

699-
# Disable Clang Tools that we do not use.
700-
CLANG_TOOLS_TO_DISABLE=(
701-
CLANG_CHECK DIAGTOOL SCAN_BUILD SCAN_VIEW CLANG_FORMAT
702-
)
703740
for tool in "${CLANG_TOOLS_TO_DISABLE[@]}"; do
704741
llvm_cmake_options+=(
705742
-DCLANG_TOOL_${tool}_BUILD:BOOL=NO
706743
)
707-
done
744+
done
708745
fi
709746

710747
if [[ "${llvm_target_arch}" ]] ; then

0 commit comments

Comments
 (0)