From 17fc2d200e543fd6af5611beac02755cead6ae76 Mon Sep 17 00:00:00 2001 From: Anthony Latsis Date: Sat, 23 Sep 2023 01:41:08 +0300 Subject: [PATCH 1/3] build-script: Don't emit build commands for LLVM when `--build-llvm` set to false --- .../products/cmake_product.py | 5 +++- .../swift_build_support/products/llvm.py | 25 +++++++++---------- .../BuildSystem/llvm-targets-options.test | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/products/cmake_product.py b/utils/swift_build_support/swift_build_support/products/cmake_product.py index 5e119e366c28e..18b5e3b7291ad 100644 --- a/utils/swift_build_support/swift_build_support/products/cmake_product.py +++ b/utils/swift_build_support/swift_build_support/products/cmake_product.py @@ -70,7 +70,10 @@ def build_with_cmake(self, build_targets, build_type, build_args, + self.args.extra_cmake_options + [self.source_dir], env=env) - if not self.args.skip_build or self.product_name() == "llvm": + is_llvm = self.product_name() == "llvm" + if (not is_llvm and not self.args.skip_build) or ( + is_llvm and self.args._build_llvm + ): cmake_opts = [self.build_dir, "--config", build_type] if self.args.cmake_generator == "Xcode": diff --git a/utils/swift_build_support/swift_build_support/products/llvm.py b/utils/swift_build_support/swift_build_support/products/llvm.py index c0011248316f3..c2b0c0eed5e83 100644 --- a/utils/swift_build_support/swift_build_support/products/llvm.py +++ b/utils/swift_build_support/swift_build_support/products/llvm.py @@ -216,20 +216,11 @@ def build(self, host_target): # space/time efficient than -g on that platform. llvm_cmake_options.define('LLVM_USE_SPLIT_DWARF:BOOL', 'YES') - build_targets = ['all'] - - if self.args.llvm_ninja_targets_for_cross_compile_hosts and \ - self.is_cross_compile_target(host_target): - build_targets = (self.args.llvm_ninja_targets_for_cross_compile_hosts) - elif self.args.llvm_ninja_targets: - build_targets = (self.args.llvm_ninja_targets) - - # indicating we don't want to build LLVM should - # override any custom ninja target we specified if not self.args._build_llvm: - build_targets = ['clean'] - - if self.args.skip_build or not self.args.build_llvm: + # Indicating we don't want to build LLVM at all should + # override everything. + build_targets = [] + elif self.args.skip_build or not self.args.build_llvm: # We can't skip the build completely because the standalone # build of Swift depends on these. build_targets = ['llvm-tblgen', 'clang-resource-headers', @@ -248,6 +239,14 @@ def build(self, host_target): 'llvm-nm', 'llvm-size' ]) + else: + build_targets = ['all'] + + if self.args.llvm_ninja_targets_for_cross_compile_hosts and \ + self.is_cross_compile_target(host_target): + build_targets = (self.args.llvm_ninja_targets_for_cross_compile_hosts) + elif self.args.llvm_ninja_targets: + build_targets = (self.args.llvm_ninja_targets) if self.args.host_libtool: llvm_cmake_options.define('CMAKE_LIBTOOL', self.args.host_libtool) diff --git a/validation-test/BuildSystem/llvm-targets-options.test b/validation-test/BuildSystem/llvm-targets-options.test index b164bdaf60d67..45e218a6aeba3 100644 --- a/validation-test/BuildSystem/llvm-targets-options.test +++ b/validation-test/BuildSystem/llvm-targets-options.test @@ -8,7 +8,7 @@ # RUN: mkdir -p %t # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --build-llvm=0 --llvm-ninja-targets="lib/all clangDependencyScanning" --cmake %cmake 2>&1 | %FileCheck --check-prefix=BUILD-LLVM-0-CHECK %s -# BUILD-LLVM-0-CHECK: cmake --build {{.*}}/llvm-{{[^/]*}} clean +# BUILD-LLVM-0-CHECK-NOT: cmake --build {{.*}}/Ninja-DebugAssert/llvm # RUN: %empty-directory(%t) From 5e50aa5d08cd625a9f644c5dfa5a647b18e65d68 Mon Sep 17 00:00:00 2001 From: Anthony Latsis Date: Sat, 23 Sep 2023 01:42:18 +0300 Subject: [PATCH 2/3] [NFC] Add lit test for Xcode project generation --- validation-test/BuildSystem/generate_xcode.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 validation-test/BuildSystem/generate_xcode.test diff --git a/validation-test/BuildSystem/generate_xcode.test b/validation-test/BuildSystem/generate_xcode.test new file mode 100644 index 0000000000000..d1192a18430ff --- /dev/null +++ b/validation-test/BuildSystem/generate_xcode.test @@ -0,0 +1,17 @@ +# RUN: %empty-directory(%t) +# RUN: %empty-directory(%t/Xcode) + +# Build system generation for 'swift' depends on several LLVM tools +# (e.g. llvm-tblgen). This is why we still build them with '--skip-build' or +# '--skip-build-llvm' set, and have an additional '--build-llvm' option to +# actually skip building that bare minimum too. +# +# To save time, borrow these dependencies from the current build directories, +# and test Xcode project generation only for 'swift'. + +# RUN: ln -s %swift_obj_root/../cmark-%target-os-%target-arch %t/Xcode/cmark-%target-os-%target-arch +# RUN: ln -s %swift_obj_root/../llvm-%target-os-%target-arch %t/Xcode/llvm-%target-os-%target-arch +# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --cmake %cmake --swift-darwin-supported-archs="$(uname -m)" --build-subdir="Xcode" --skip-build-cmark --build-llvm=0 --xcode + +# REQUIRES: standalone_build +# REQUIRES: OS=macosx From 2644adf2b091c1abd0b6b59b35a648a3b43b01a9 Mon Sep 17 00:00:00 2001 From: Anthony Latsis Date: Sat, 23 Sep 2023 01:31:17 +0300 Subject: [PATCH 3/3] [NFC] Delete redundant RUN line in test --- validation-test/BuildSystem/skip_build_xcode.test | 1 - 1 file changed, 1 deletion(-) diff --git a/validation-test/BuildSystem/skip_build_xcode.test b/validation-test/BuildSystem/skip_build_xcode.test index dc01fc837e3e6..6695325d81607 100644 --- a/validation-test/BuildSystem/skip_build_xcode.test +++ b/validation-test/BuildSystem/skip_build_xcode.test @@ -1,5 +1,4 @@ # RUN: %empty-directory(%t) -# RUN: mkdir -p %t # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --xcode --release --swift-darwin-supported-archs="$(uname -m)" --dry-run --cmake %cmake 2>&1 | %FileCheck %s # REQUIRES: standalone_build