Skip to content

Commit b07fd4b

Browse files
authored
Merge pull request #3697 from gottesmm/disabling-of-most-llvm-tools-when-not-testing-swift
2 parents 8e2597b + 907f73d commit b07fd4b

File tree

2 files changed

+89
-42
lines changed

2 files changed

+89
-42
lines changed

utils/build-presets.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ lit-args=-v
456456

457457
dash-dash
458458

459-
skip-test-llvm=0
459+
llvm-include-tests
460460
reconfigure
461461
verbose-build
462462
build-ninja
@@ -715,8 +715,7 @@ dash-dash
715715

716716
skip-build-swift
717717
skip-build-cmark
718-
skip-test-llvm=0
719-
718+
llvm-include-tests
720719

721720
#===------------------------------------------------------------------------===#
722721
# OS X Package Builders
@@ -928,7 +927,7 @@ build-swift-static-stdlib=0
928927
build-swift-dynamic-stdlib=0
929928
build-swift-static-sdk-overlay=0
930929
build-swift-dynamic-sdk-overlay=0
931-
source-tree-includes-tests=0
930+
swift-include-tests=0
932931

933932
[preset: remote_mirror_ios_customization]
934933

utils/build-script-impl

Lines changed: 86 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ KNOWN_SETTINGS=(
123123
skip-test-cmark "" "set to skip testing CommonMark"
124124
skip-test-lldb "" "set to skip testing lldb"
125125
skip-test-swift "" "set to skip testing Swift"
126-
skip-test-llvm "" "set to skip testing LLVM. Set to true by default"
127126
skip-test-llbuild "" "set to skip testing llbuild"
128127
skip-test-swiftpm "" "set to skip testing swiftpm"
129128
skip-test-xctest "" "set to skip testing xctest"
@@ -161,7 +160,8 @@ KNOWN_SETTINGS=(
161160
build-serialized-stdlib-unittest "0" "set to 1 to build the StdlibUnittest module with -sil-serialize-all"
162161
build-sil-debugging-stdlib "0" "set to 1 to build the Swift standard library with -gsil to enable debugging and profiling on SIL level"
163162
check-incremental-compilation "0" "set to 1 to compile swift libraries multiple times to check if incremental compilation works"
164-
source-tree-includes-tests "1" "set to 0 to allow the build to proceed when 'test' directory is missing (required for B&I builds)"
163+
llvm-include-tests "1" "Set to true to generate testing targets for LLVM. Set to true by default."
164+
swift-include-tests "1" "Set to true to generate testing targets for Swift. This allows the build to proceed when 'test' directory is missing (required for B&I builds)"
165165
native-llvm-tools-path "" "directory that contains LLVM tools that are executable on the build machine"
166166
native-clang-tools-path "" "directory that contains Clang tools that are executable on the build machine"
167167
native-swift-tools-path "" "directory that contains Swift tools that are executable on the build machine"
@@ -315,6 +315,83 @@ function is_swift_lto_enabled() {
315315
fi
316316
}
317317

318+
# Compute the cmake flags related to disabling llvm tools as a result of our
319+
# needs for testing LLVM/Swift.
320+
function compute_cmake_llvm_tool_disable_flags() {
321+
if [[ $(false_true "${LLVM_INCLUDE_TESTS}") == "FALSE" ]]; then
322+
return
323+
fi
324+
325+
local OUTPUT=()
326+
local EXTRA_LLVM_CMAKE_OPTIONS=(
327+
# Do not include LLVM tests.
328+
-DLLVM_INCLUDE_TESTS:BOOL=NO
329+
-DCLANG_INCLUDE_TESTS:BOOL=NO
330+
)
331+
332+
# Disable LLVM Tools that Swift does not use for testing.
333+
local LLVM_TOOLS_TO_DISABLE=(
334+
BUGPOINT BUGPOINT_PASSES GOLD LLI LLVM_AS_FUZZER LLVM_C_TEST
335+
LLVM_CXXDUMP LLVM_DIFF LLVM_DIS LLVM_DWP LLVM_EXTRACT LLVM_GO
336+
LLVM_JITLISTENER LLVM_LTO LLVM_MC LLVM_MC_FUZZER LLVM_MCMARKUP
337+
LLVM_PDBDUMP LLVM_READOBJ LLVM_RTDYLD LLVM_SHLIB LLVM_SIZE LLVM_SPLIT
338+
LLVM_STRESS LLVM_SYMBOLIZER MSBUILD OBJ2YAML OPT SANCOV SANSTATS
339+
VERIFY_USELISTORDER XCODE_TOOLCHAIN YAML2OBJ
340+
)
341+
342+
# Disable Clang Tools that Swift does not use for testing.
343+
local CLANG_TOOLS_TO_DISABLE=(
344+
CLANG_CHECK DIAGTOOL SCAN_BUILD SCAN_VIEW CLANG_FORMAT
345+
)
346+
347+
# If in addition we are asked to not generate targets for swift tests,
348+
# then we can disable the building of even more of LLVM.
349+
if [[ $(false_true "${SWIFT_INCLUDE_TESTS}") == "TRUE" ]]; then
350+
EXTRA_LLVM_CMAKE_OPTIONS+=(
351+
# We do not need gtest/FileCheck and friends since we are not
352+
# running any tests.
353+
-DLLVM_INCLUDE_UTILS:BOOL=NO
354+
)
355+
356+
# Disable the rest of the LLVM tools. We do not need any of them.
357+
LLVM_TOOLS_TO_DISABLE+=(
358+
DSYMUTIL LLC LLVM_AR LLVM_AS LLVM_BCANALYZER LLVM_COV
359+
LLVM_DWARFDUMP LLVM_LINK LLVM_NM LLVM_OBJDUMP LLVM_PROFDATA
360+
)
361+
362+
# Disable the rest of the Clang tools. We do not need them.
363+
CLANG_TOOLS_TO_DISABLE+=(
364+
ARCMT_TEST C_ARCMT_TEST C_INDEX_TEST
365+
)
366+
367+
# If in addition, we are not building compiler-rt, then we do not
368+
# even need to build clang.
369+
#
370+
# *NOTE* This may change once we start building the standard library
371+
# *with the just built clang.
372+
if [[ $(true_false "${SKIP_BUILD_COMPILER_RT}") == "TRUE" ]]; then
373+
CLANG_TOOLS_TO_DISABLE+=(
374+
DRIVER
375+
)
376+
fi
377+
fi
378+
379+
for arg in "${EXTRA_LLVM_CMAKE_ARGS[@]}"; do
380+
OUTPUT+=( ${arg} )
381+
done
382+
for tool in "${LLVM_TOOLS_TO_DISABLE[@]}"; do
383+
OUTPUT+=(
384+
-DLLVM_TOOL_${tool}_BUILD:BOOL=NO
385+
)
386+
done
387+
for tool in "${CLANG_TOOLS_TO_DISABLE[@]}"; do
388+
OUTPUT+=(
389+
-DCLANG_TOOL_${tool}_BUILD:BOOL=NO
390+
)
391+
done
392+
echo "${OUTPUT[@]}"
393+
}
394+
318395
# Support for performing isolated actions.
319396
#
320397
# This is part of refactoring more work to be done or controllable via
@@ -669,43 +746,15 @@ function set_build_options_for_host() {
669746
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
670747
)
671748

672-
# If we are asked to not test LLVM, do not include tools that are not used
673-
# to test Swift.
749+
# If we are asked to not generate test targets for LLVM and or Swift,
750+
# disable as many LLVM tools as we can. This improves compile time when
751+
# compiling with LTO.
674752
#
675753
# *NOTE* Currently we do not support testing LLVM via build-script. But in a
676754
# future commit we will.
677-
if [[ $(true_false "${SKIP_TEST_LLVM}") == "TRUE" ]]; then
678-
llvm_cmake_options+=(
679-
# Do not include LLVM tests.
680-
-DLLVM_INCLUDE_TESTS:BOOL=NO
681-
-DCLANG_INCLUDE_TESTS:BOOL=NO
682-
)
683-
684-
# Disable LLVM Tools that we do not use.
685-
LLVM_TOOLS_TO_DISABLE=(
686-
BUGPOINT BUGPOINT_PASSES GOLD LLI LLVM_AS_FUZZER LLVM_C_TEST
687-
LLVM_CXXDUMP LLVM_DIFF LLVM_DIS LLVM_DWP LLVM_EXTRACT LLVM_GO
688-
LLVM_JITLISTENER LLVM_LTO LLVM_MC LLVM_MC_FUZZER LLVM_MCMARKUP
689-
LLVM_PDBDUMP LLVM_READOBJ LLVM_RTDYLD LLVM_SHLIB LLVM_SIZE LLVM_SPLIT
690-
LLVM_STRESS LLVM_SYMBOLIZER MSBUILD OBJ2YAML OPT SANCOV SANSTATS
691-
VERIFY_USELISTORDER XCODE_TOOLCHAIN YAML2OBJ
692-
)
693-
for tool in "${LLVM_TOOLS_TO_DISABLE[@]}"; do
694-
llvm_cmake_options+=(
695-
-DLLVM_TOOL_${tool}_BUILD:BOOL=NO
696-
)
697-
done
698-
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-
)
703-
for tool in "${CLANG_TOOLS_TO_DISABLE[@]}"; do
704-
llvm_cmake_options+=(
705-
-DCLANG_TOOL_${tool}_BUILD:BOOL=NO
706-
)
707-
done
708-
fi
755+
for arg in "$(compute_cmake_llvm_tool_disable_flags)"; do
756+
llvm_cmake_options+=( ${arg} )
757+
done
709758

710759
if [[ "${llvm_target_arch}" ]] ; then
711760
llvm_cmake_options+=(
@@ -1898,7 +1947,6 @@ for host in "${ALL_HOSTS[@]}"; do
18981947
-DLLVM_ENABLE_ASSERTIONS:BOOL=$(true_false "${LLVM_ENABLE_ASSERTIONS}")
18991948
-DLLVM_TOOL_SWIFT_BUILD:BOOL=NO
19001949
-DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS_TO_BUILD}"
1901-
-DLLVM_INCLUDE_TESTS:BOOL=$(true_false "${SOURCE_TREE_INCLUDES_TESTS}")
19021950
-DLLVM_INCLUDE_DOCS:BOOL=TRUE
19031951
-DLLVM_ENABLE_LTO:STRING="${LLVM_ENABLE_LTO}"
19041952
"${llvm_cmake_options[@]}"
@@ -1955,7 +2003,7 @@ for host in "${ALL_HOSTS[@]}"; do
19552003
native_swift_tools_path="$(build_directory "${LOCAL_HOST}" swift)/bin"
19562004
else
19572005
build_perf_testsuite_this_time=$(true_false "$(not ${SKIP_BUILD_BENCHMARKS})")
1958-
build_tests_this_time=${SOURCE_TREE_INCLUDES_TESTS}
2006+
build_tests_this_time=${SWIFT_INCLUDE_TESTS}
19592007
fi
19602008

19612009
# Command-line parameters override any autodetection that we

0 commit comments

Comments
 (0)