From 865f1bf5bbfeb5441eeb1e20ee0b0a52eec74d03 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Mon, 8 Jun 2020 12:05:15 -0700 Subject: [PATCH 1/2] [build-script] Add test for --skip-build-* options and a lit variable for cmake This was backported from a313f62522c00e8327084820bd22dc3d2870610e with all the --infer and --install-all work there left out, bringing back a single test and the lit variable for cmake that it used. One note describing that from the original commit: 2. I added %cmake as a lit variable. I did this so I could specify in my build-system unit tests that on Linux they should use the just built cmake (if we built cmake due to an old cmake being on the system). Otherwise, the build system unit tests took way too long. These are meant to be dry-runs, so building this cmake again is just wasteful and doesn't make sense. --- test/lit.cfg | 5 ++++ test/lit.site.cfg.in | 1 + .../swift_build_support/cmake.py | 2 +- .../BuildSystem/skip_cmark_swift_llvm.test-sh | 24 +++++++++++++++++++ validation-test/lit.site.cfg.in | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh diff --git a/test/lit.cfg b/test/lit.cfg index 64cbffc02b4e1..3abddcbe7714d 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -199,6 +199,11 @@ config.test_source_root = os.path.dirname(__file__) # test_exec_root: The root path where tests should be run. swift_obj_root = getattr(config, 'swift_obj_root', None) +# cmake. The path to the cmake executable we used to configure swift. +assert(config.cmake) +config.substitutions.append( ('%cmake', config.cmake) ) +lit_config.note('Using cmake: ' + config.cmake) + # Set llvm_{src,obj}_root for use by others. config.llvm_src_root = getattr(config, 'llvm_src_root', None) config.llvm_obj_root = getattr(config, 'llvm_obj_root', None) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 69107930747b0..4be337fc688df 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -14,6 +14,7 @@ import os import platform import sys +config.cmake = "@CMAKE_COMMAND@" config.llvm_src_root = "@LLVM_MAIN_SRC_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" diff --git a/utils/swift_build_support/swift_build_support/cmake.py b/utils/swift_build_support/swift_build_support/cmake.py index 876caf175392a..85a97dfa747e2 100644 --- a/utils/swift_build_support/swift_build_support/cmake.py +++ b/utils/swift_build_support/swift_build_support/cmake.py @@ -272,7 +272,7 @@ def check_cmake_version(self, source_root, build_root): cmake_binary = 'cmake' installed_ver = self.installed_cmake_version(cmake_binary) - if installed_ver > self.cmake_source_version(cmake_source_dir): + if installed_ver >= self.cmake_source_version(cmake_source_dir): return else: # Build CMake from source and return the path to the executable. diff --git a/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh b/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh new file mode 100644 index 0000000000000..1702d5d7d565d --- /dev/null +++ b/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh @@ -0,0 +1,24 @@ +# RUN: %empty-directory(%t) +# RUN: mkdir -p %t +# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --skip-build-cmark 2>&1 | %FileCheck --check-prefix=SKIP-CMARK-CHECK %s + +# RUN: %empty-directory(%t) +# RUN: mkdir -p %t +# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --skip-build-llvm 2>&1 | %FileCheck --check-prefix=SKIP-LLVM-CHECK %s + +# RUN: %empty-directory(%t) +# RUN: mkdir -p %t +# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --skip-build-swift 2>&1 | %FileCheck --check-prefix=SKIP-SWIFT-CHECK %s + +# SKIP-CMARK-CHECK-NOT: cmake --build {{.*}}cmark- +# SKIP-CMARK-CHECK: cmake --build {{.*}}llvm- +# SKIP-CMARK-CHECK: cmake --build {{.*}}swift- + +# SKIP-LLVM-CHECK: cmake --build {{.*}}cmark- +# SKIP-LLVM-CHECK-NOT: cmake --build {{.*}}llvm- +# SKIP-LLVM-CHECK: cmake --build {{.*}}swift- + +# SKIP-SWIFT-CHECK: cmake --build {{.*}}cmark- +# SKIP-SWIFT-CHECK: cmake --build {{.*}}llvm- +# SKIP-SWIFT-CHECK-NOT: cmake --build {{.*}}swift- + diff --git a/validation-test/lit.site.cfg.in b/validation-test/lit.site.cfg.in index 6a00ee3ab5ef7..952fcedc65db8 100644 --- a/validation-test/lit.site.cfg.in +++ b/validation-test/lit.site.cfg.in @@ -13,6 +13,7 @@ import sys import platform +config.cmake = "@CMAKE_COMMAND@" config.llvm_src_root = "@LLVM_MAIN_SRC_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" From e0716a6dfa02f2eea7d6c303996e5669b8a0d611 Mon Sep 17 00:00:00 2001 From: Butta Date: Tue, 21 Jul 2020 12:03:51 +0530 Subject: [PATCH 2/2] [build] Fix --skip-build-llvm so that its minimal targets, like tblgen, are still built Backported from commit c969814a114e99e9caba35fe3db53d3f3d0982cb, resolves SR-13267 --- utils/build-script-impl | 8 ++++++-- validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 60d46cdf6dc48..c8f09b103a6f7 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -1141,10 +1141,14 @@ LIBDISPATCH_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch" LIBICU_SOURCE_DIR="${WORKSPACE}/icu" LIBCXX_SOURCE_DIR="${WORKSPACE}/llvm-project/libcxx" +# We cannot currently apply the normal rules of skipping here for LLVM. Even if +# we are skipping building LLVM, we still need to at least build a few tools +# like tblgen that Swift relies on for building and testing. See the LLVM +# configure rules. +PRODUCTS=(llvm) [[ "${SKIP_BUILD_CMARK}" ]] || PRODUCTS+=(cmark) [[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx) [[ "${SKIP_BUILD_LIBICU}" ]] || PRODUCTS+=(libicu) -[[ "${SKIP_BUILD_LLVM}" ]] || PRODUCTS+=(llvm) [[ "${SKIP_BUILD_SWIFT}" ]] || PRODUCTS+=(swift) [[ "${SKIP_BUILD_LLDB}" ]] || PRODUCTS+=(lldb) [[ "${SKIP_BUILD_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch) @@ -1534,7 +1538,7 @@ for host in "${ALL_HOSTS[@]}"; do if [ "${BUILD_LLVM}" == "0" ] ; then build_targets=(clean) fi - if [ "${SKIP_BUILD}" ] ; then + if [[ "${SKIP_BUILD}" || "${SKIP_BUILD_LLVM}" ]] ; then # We can't skip the build completely because the standalone # build of Swift depend on these for building and testing. build_targets=(llvm-tblgen clang-resource-headers intrinsics_gen clang-tablegen-targets) diff --git a/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh b/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh index 1702d5d7d565d..c8b3cd8b118c0 100644 --- a/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh +++ b/validation-test/BuildSystem/skip_cmark_swift_llvm.test-sh @@ -15,7 +15,7 @@ # SKIP-CMARK-CHECK: cmake --build {{.*}}swift- # SKIP-LLVM-CHECK: cmake --build {{.*}}cmark- -# SKIP-LLVM-CHECK-NOT: cmake --build {{.*}}llvm- +# SKIP-LLVM-CHECK: cmake --build {{.*}}llvm-tblgen # SKIP-LLVM-CHECK: cmake --build {{.*}}swift- # SKIP-SWIFT-CHECK: cmake --build {{.*}}cmark-