From 62e91f149265ec2fd46341cb00a3df3dafd5a901 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Thu, 7 Sep 2023 23:19:51 +0000 Subject: [PATCH 1/7] [CMake] Use explicit RPATHs for unit test executables Instead of letting CMake set RPATH of the test executables, use INSTALL_RPATH and BUILD_WITH_INSTALL_RPATH just like other executable and shared libraries. Previously when a swift module link with exported swift-syntax targets e.g. 'SwiftSyntax::SwiftParser', the libraries in earlyswiftsyntax were used instead of the copied libraries in the swift build directory. That wasn't ideal. (cherry picked from commit 891d7b728b14b22bbc4d0c5ed7fe78f693ea818b) --- cmake/modules/AddSwiftUnittests.cmake | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/cmake/modules/AddSwiftUnittests.cmake b/cmake/modules/AddSwiftUnittests.cmake index 45acb9bf10698..b3ed5ef8a391f 100644 --- a/cmake/modules/AddSwiftUnittests.cmake +++ b/cmake/modules/AddSwiftUnittests.cmake @@ -111,10 +111,31 @@ function(add_swift_unittest test_dirname) endif() endif() + file(RELATIVE_PATH relative_lib_path "${CMAKE_CURRENT_BINARY_DIR}" "${SWIFT_LIBRARY_OUTPUT_INTDIR}") + + if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) + set_property( + TARGET ${test_dirname} + APPEND PROPERTY INSTALL_RPATH "@executable_path/${relative_lib_path}") + elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD") + set_property( + TARGET ${test_dirname} + APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${relative_lib_path}") + endif() + if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST) # Link to stdlib the compiler uses. - _add_swift_runtime_link_flags(${test_dirname} "../../lib" "") - set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) + _add_swift_runtime_link_flags(${test_dirname} "${relative_lib_path}" "") + + if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) + set_property( + TARGET ${test_dirname} + APPEND PROPERTY INSTALL_RPATH "@executable_path/${relative_lib_path}/swift/host") + elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD") + set_property( + TARGET ${test_dirname} + APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${relative_lib_path}/swift/host") + endif() endif() endfunction() From 6872901a8ed37e5af4f239ceaec6e6aaa3ce5a73 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 14 Sep 2023 22:52:01 +0000 Subject: [PATCH 2/7] build: fallback `BOOTSTRAPPING_MODE` before the first use `BOOTSTRAPPING_MODE` was used for configuring `SWIFT_ENABLE_ARRAY_COW_CHECKS` before it's fully fixed. (cherry picked from commit 06bffb960f86baacb7587e5a04096c54008bab0f) --- CMakeLists.txt | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a28bf92956680..9a460b731d019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -838,6 +838,24 @@ elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER) set(SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER}") endif() +# When we have the early SwiftSyntax build, we can include its parser. +if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR) + set(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS + ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/cmake/SwiftSyntaxTargets.cmake) + if(NOT EXISTS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}") + message(STATUS "Skipping Swift Swift parser integration due to missing early SwiftSyntax") + else() + set(SWIFT_SWIFT_PARSER TRUE) + include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}) + + if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS") + # Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled. + message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled") + set(BOOTSTRAPPING_MODE "HOSTTOOLS") + endif() + endif() +endif() + if(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS|.*-WITH-HOSTLIBS") if(SWIFT_ENABLE_ARRAY_COW_CHECKS) message(STATUS "array COW checks disabled when building the swift modules with host libraries") @@ -944,24 +962,6 @@ if(XCODE) set(SWIFT_SDKS "OSX") endif() -# When we have the early SwiftSyntax build, we can include its parser. -if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR) - set(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS - ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/cmake/SwiftSyntaxTargets.cmake) - if(NOT EXISTS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}") - message(STATUS "Skipping Swift Swift parser integration due to missing early SwiftSyntax") - else() - set(SWIFT_SWIFT_PARSER TRUE) - include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}) - - if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS") - # Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled. - message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled") - set(BOOTSTRAPPING_MODE "HOSTTOOLS") - endif() - endif() -endif() - # FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics, # so we need to hard-code it. For example, the SDK for Android is just 'ANDROID', From efac2428ede20dc18c21d85f33a184a969c79e2a Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Thu, 28 Sep 2023 11:22:10 -0700 Subject: [PATCH 3/7] Merge pull request #68408 from rintaro/fetch-content [CMake] Replace early swift-syntax with FetchContent (cherry picked from commit 8dbde04c6184a803db6c1dbcf676d59daddea7d6) --- CMakeLists.txt | 66 +++++--- cmake/modules/AddPureSwift.cmake | 56 +++---- cmake/modules/AddSwift.cmake | 42 ++--- cmake/modules/AddSwiftUnittests.cmake | 2 +- cmake/modules/SetRPATH.cmake | 24 --- cmake/modules/SwiftComponents.cmake | 9 +- lib/AST/CMakeLists.txt | 4 +- lib/ASTGen/CMakeLists.txt | 20 +-- lib/CMakeLists.txt | 155 ++++-------------- lib/Frontend/CMakeLists.txt | 4 +- lib/Frontend/PrintingDiagnosticConsumer.cpp | 8 +- lib/IDE/CodeCompletion.cpp | 2 +- lib/Macros/CMakeLists.txt | 2 +- .../Sources/ObservationMacros/CMakeLists.txt | 10 +- lib/Macros/Sources/SwiftMacros/CMakeLists.txt | 8 +- lib/Parse/CMakeLists.txt | 36 ++-- lib/Parse/ParseDecl.cpp | 10 +- lib/Parse/ParseIfConfig.cpp | 2 +- lib/Parse/ParseType.cpp | 2 +- lib/Sema/CMakeLists.txt | 4 +- lib/Sema/CSApply.cpp | 2 +- lib/Sema/CSGen.cpp | 2 +- lib/Sema/TypeCheckMacros.cpp | 20 +-- test/CMakeLists.txt | 11 +- test/lit.site.cfg.in | 2 +- .../cmake/modules/AddSwiftSourceKit.cmake | 8 +- tools/driver/CMakeLists.txt | 4 +- tools/libSwiftScan/CMakeLists.txt | 2 +- tools/swift-plugin-server/CMakeLists.txt | 8 +- utils/build-script-impl | 10 -- .../build_script_invocation.py | 26 ++- .../swift_build_support/products/__init__.py | 2 - .../products/earlyswiftdriver.py | 7 +- .../products/earlyswiftsyntax.py | 82 --------- 34 files changed, 233 insertions(+), 419 deletions(-) delete mode 100644 cmake/modules/SetRPATH.cmake delete mode 100644 utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a460b731d019..726758e7143d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ include(CMakeDependentOption) include(CheckLanguage) include(GNUInstallDirs) include(SwiftImplicitImport) +include(FetchContent) # Enable Swift for the host compiler build if we have the language. It is # optional until we have a bootstrap story. @@ -691,10 +692,9 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang) add_compile_options($<$:-Werror=c++98-compat-extra-semi>) endif() -# Make sure we know where swift-syntax is because we need it to build the parser. -if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}") - message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE") -endif() +option(SWIFT_BUILD_SWIFT_SYNTAX + "Enable building swift syntax" + FALSE) set(SWIFT_BUILD_HOST_DISPATCH FALSE) if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -794,7 +794,6 @@ include(SwiftConfigureSDK) include(SwiftComponents) include(SwiftList) include(AddPureSwift) -include(SetRPATH) # Configure swift include, install, build components. swift_configure_components() @@ -830,7 +829,7 @@ elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") else() set(BOOTSTRAPPING_MODE "HOSTTOOLS") endif() -elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER) +elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX) # We are building using a pre-installed host toolchain but not bootstrapping # the Swift modules. This happens when building using 'build-tooling-libs' # where we haven't built a new Swift compiler. Use the Swift compiler from the @@ -838,21 +837,11 @@ elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER) set(SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER}") endif() -# When we have the early SwiftSyntax build, we can include its parser. -if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR) - set(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS - ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/cmake/SwiftSyntaxTargets.cmake) - if(NOT EXISTS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}") - message(STATUS "Skipping Swift Swift parser integration due to missing early SwiftSyntax") - else() - set(SWIFT_SWIFT_PARSER TRUE) - include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}) - - if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS") - # Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled. - message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled") - set(BOOTSTRAPPING_MODE "HOSTTOOLS") - endif() +if(SWIFT_BUILD_SWIFT_SYNTAX) + # Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled. + if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS") + message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled") + set(BOOTSTRAPPING_MODE "HOSTTOOLS") endif() endif() @@ -962,7 +951,6 @@ if(XCODE) set(SWIFT_SDKS "OSX") endif() - # FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics, # so we need to hard-code it. For example, the SDK for Android is just 'ANDROID', # and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately. @@ -1171,13 +1159,17 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT CMAKE_CROSSCOMPILING) set(CMAKE_OSX_DEPLOYMENT_TARGET "") endif() +swift_get_host_triple(SWIFT_HOST_TRIPLE) +set(SWIFT_HOST_MODULE_TRIPLE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_MODULE}") +set(SWIFT_HOST_LIBRARIES_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/host") + if(SWIFT_INCLUDE_TOOLS) message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}") message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}") message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}") message(STATUS " Bootstrapping: ${BOOTSTRAPPING_MODE}") - message(STATUS " Swift parser: ${SWIFT_SWIFT_PARSER}") + message(STATUS " Swift parser: ${SWIFT_BUILD_SWIFT_SYNTAX}") message(STATUS "") else() message(STATUS "Not building host Swift tools") @@ -1323,6 +1315,34 @@ endif() add_subdirectory(include) if(SWIFT_INCLUDE_TOOLS) + # Include 'swift-syntax'. + # This is a function because we want to set some 'CMAKE_*' variables temporarily.' + # TODO: Replace this with 'block()' after CMake 3.25 + function(include_swift_syntax) + if(NOT SWIFT_BUILD_SWIFT_SYNTAX) + return() + endif() + if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}") + message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE") + return() + endif() + + set(CMAKE_Swift_COMPILER_TARGET ${SWIFT_HOST_TRIPLE}) + set(BUILD_SHARED_LIBS ON) + # All libraries in 'swift-syntax' goes to 'lib/swift/host'. + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD") + set(SWIFT_HOST_LIBRARIES_RPATH "$ORIGIN;$ORIGIN/../${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}") + endif() + + FetchContent_Declare(SwiftSyntax + SOURCE_DIR "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}" + ) + FetchContent_MakeAvailable(SwiftSyntax) + endfunction() + include_swift_syntax() + add_subdirectory(lib) # SwiftCompilerSources must come before "tools". diff --git a/cmake/modules/AddPureSwift.cmake b/cmake/modules/AddPureSwift.cmake index 6c79fdcf351ce..953c607947fc0 100644 --- a/cmake/modules/AddPureSwift.cmake +++ b/cmake/modules/AddPureSwift.cmake @@ -2,17 +2,15 @@ include(macCatalystUtils) # Workaround a cmake bug, see the corresponding function in swift-syntax function(force_target_link_libraries TARGET) - cmake_parse_arguments(ARGS "" "" "PUBLIC" ${ARGN}) - - foreach(DEPENDENCY ${ARGS_PUBLIC}) - target_link_libraries(${TARGET} PRIVATE ${DEPENDENCY}) - add_dependencies(${TARGET} ${DEPENDENCY}) + target_link_libraries(${TARGET} ${ARGN}) + cmake_parse_arguments(ARGS "PUBLIC;PRIVATE;INTERFACE" "" "" ${ARGN}) + foreach(DEPENDENCY ${ARGS_UNPARSED_ARGUMENTS}) string(REGEX REPLACE [<>:\"/\\|?*] _ sanitized ${DEPENDENCY}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/forced-${sanitized}-dep.swift COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/forced-${sanitized}-dep.swift DEPENDS ${DEPENDENCY} - ) + ) target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/forced-${sanitized}-dep.swift ) @@ -46,21 +44,7 @@ function(_add_host_swift_compile_options name) $<$:-runtime-compatibility-version> $<$:none>) - # Set the appropriate target triple. - # FIXME: This should be set by CMake. - if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) - set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}") - endif() - - if(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID") - set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL}) - endif() - - get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}" - MACCATALYST_BUILD_FLAVOR "" - DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}") - - target_compile_options(${name} PRIVATE $<$:-target;${target}>) + target_compile_options(${name} PRIVATE $<$:-target;${SWIFT_HOST_TRIPLE}>) _add_host_variant_swift_sanitizer_flags(${name}) endfunction() @@ -121,7 +105,7 @@ endfunction() # source1 ... # Sources to add into this library. function(add_pure_swift_host_library name) - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) message(STATUS "Not building ${name} because swift-syntax is not available") return() endif() @@ -196,13 +180,15 @@ function(add_pure_swift_host_library name) # Make sure we can use the host libraries. target_include_directories(${name} PUBLIC - ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + target_link_directories(${name} PUBLIC + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") if(APSHL_EMIT_MODULE) # Determine where Swift modules will be built and installed. - set(module_triple ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_MODULE}) - set(module_dir ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + set(module_triple "${SWIFT_HOST_MODULE_TRIPLE}") + set(module_dir "${SWIFT_HOST_LIBRARIES_DEST_DIR}") set(module_base "${module_dir}/${name}.swiftmodule") set(module_file "${module_base}/${module_triple}.swiftmodule") set(module_interface_file "${module_base}/${module_triple}.swiftinterface") @@ -234,6 +220,12 @@ function(add_pure_swift_host_library name) >) endif() + if(LLVM_USE_LINKER) + target_link_options(${name} PRIVATE + "-use-ld=${LLVM_USE_LINKER}" + ) + endif() + # Export this target. set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name}) endfunction() @@ -241,7 +233,7 @@ endfunction() # Add a new "pure" Swift host tool. # # "Pure" Swift host tools can only contain Swift code, and will be built -# with the host compiler. +# with the host compiler. # # Usage: # add_pure_swift_host_tool(name @@ -262,7 +254,7 @@ endfunction() # source1 ... # Sources to add into this tool. function(add_pure_swift_host_tool name) - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) message(STATUS "Not building ${name} because swift-syntax is not available") return() endif() @@ -322,7 +314,15 @@ function(add_pure_swift_host_tool name) # Make sure we can use the host libraries. target_include_directories(${name} PUBLIC - ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + target_link_directories(${name} PUBLIC + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + + if(LLVM_USE_LINKER) + target_link_options(${name} PRIVATE + "-use-ld=${LLVM_USE_LINKER}" + ) + endif() # Workaround to touch the library and its objects so that we don't # continually rebuild (again, see corresponding change in swift-syntax). diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index 44b84c7e1333a..561e1ab92d8cc 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -112,9 +112,7 @@ function(_add_host_variant_swift_sanitizer_flags target) endif() endfunction() -# Usage: -# _add_host_variant_c_compile_link_flags(name) -function(_add_host_variant_c_compile_link_flags name) +function(swift_get_host_triple out_var) if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}") endif() @@ -123,26 +121,30 @@ function(_add_host_variant_c_compile_link_flags name) set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL}) endif() + get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}" + MACCATALYST_BUILD_FLAVOR "" + DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}") + + set(${out_var} "${target}" PARENT_SCOPE) +endfunction() + +# Usage: +# _add_host_variant_c_compile_link_flags(name) +function(_add_host_variant_c_compile_link_flags name) # MSVC and gcc don't understand -target. # clang-cl understands --target. if(CMAKE_C_COMPILER_ID MATCHES "Clang") - get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}" - MACCATALYST_BUILD_FLAVOR "" - DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}") if("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC") # clang-cl options - target_compile_options(${name} PRIVATE $<$:--target=${target}>) - target_link_options(${name} PRIVATE $<$:--target=${target}>) + target_compile_options(${name} PRIVATE $<$:--target=${SWIFT_HOST_TRIPLE}>) + target_link_options(${name} PRIVATE $<$:--target=${SWIFT_HOST_TRIPLE}>) else() - target_compile_options(${name} PRIVATE $<$:-target;${target}>) - target_link_options(${name} PRIVATE $<$:-target;${target}>) + target_compile_options(${name} PRIVATE $<$:-target;${SWIFT_HOST_TRIPLE}>) + target_link_options(${name} PRIVATE $<$:-target;${SWIFT_HOST_TRIPLE}>) endif() endif() if (CMAKE_Swift_COMPILER) - get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}" - MACCATALYST_BUILD_FLAVOR "" - DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}") - target_compile_options(${name} PRIVATE $<$:-target;${target}>) + target_compile_options(${name} PRIVATE $<$:-target;${SWIFT_HOST_TRIPLE}>) _add_host_variant_swift_sanitizer_flags(${name}) endif() @@ -442,7 +444,7 @@ endfunction() function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping) if(NOT BOOTSTRAPPING_MODE) - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS") else() return() @@ -579,7 +581,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping) ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}) endif() - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) # For the "end step" of bootstrapping configurations, we need to be # able to fall back to the SDK directory for libswiftCore et al. if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") @@ -657,7 +659,7 @@ function(add_swift_host_library name) translate_flags(ASHL "${options}") # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER AND ASHL_SHARED) + if (SWIFT_BUILD_SWIFT_SYNTAX AND ASHL_SHARED) set(ASHL_HAS_SWIFT_MODULES ON) endif() @@ -703,7 +705,7 @@ function(add_swift_host_library name) add_library(${name} ${libkind} ${ASHL_SOURCES}) - target_link_directories(${name} PUBLIC ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + target_link_directories(${name} PUBLIC "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Respect LLVM_COMMON_DEPENDS if it is set. # @@ -925,7 +927,7 @@ function(add_swift_host_tool executable) endif() # Once the new Swift parser is linked in, every host tool has Swift modules. - if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT) + if (SWIFT_BUILD_SWIFT_SYNTAX AND NOT ASHT_DOES_NOT_USE_SWIFT) set(ASHT_HAS_SWIFT_MODULES ON) endif() @@ -964,7 +966,7 @@ function(add_swift_host_tool executable) endif() endif() - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) set(extra_relative_rpath "") if(NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "") if(executable MATCHES "-bootstrapping") diff --git a/cmake/modules/AddSwiftUnittests.cmake b/cmake/modules/AddSwiftUnittests.cmake index b3ed5ef8a391f..78a84e6ec5821 100644 --- a/cmake/modules/AddSwiftUnittests.cmake +++ b/cmake/modules/AddSwiftUnittests.cmake @@ -123,7 +123,7 @@ function(add_swift_unittest test_dirname) APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${relative_lib_path}") endif() - if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST) + if (SWIFT_BUILD_SWIFT_SYNTAX AND NOT ASU_IS_TARGET_TEST) # Link to stdlib the compiler uses. _add_swift_runtime_link_flags(${test_dirname} "${relative_lib_path}" "") diff --git a/cmake/modules/SetRPATH.cmake b/cmake/modules/SetRPATH.cmake deleted file mode 100644 index 76b8b4644e59a..0000000000000 --- a/cmake/modules/SetRPATH.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(SWIFT_SET_RPATH_SCRIPT_FILE "${CMAKE_CURRENT_LIST_FILE}") - -function(swift_get_set_rpath_script_file out_var) - set(${out_var} "${SWIFT_SET_RPATH_SCRIPT_FILE}" PARENT_SCOPE) -endfunction() - -# Actual RPATH_CHANGE operation to the file. -function(_swift_set_rpath_impl file new_rpath) - # FIXME: Handle non-ELF files. We can't use RPATH_SET because it's only available CMake 3.21.0 - execute_process( - COMMAND readelf -Wd "${file}" - COMMAND grep -Po "R(UN)?PATH.*\\[\\K[^\\]]*" - OUTPUT_VARIABLE current_rpath - ) - string(STRIP "${current_rpath}" current_rpath) - - # NOTE: RPATH_CHANGE is not documented, and works only for ELF and XCOFF. - file(RPATH_CHANGE FILE "${file}" OLD_RPATH "${current_rpath}" NEW_RPATH "${new_rpath}") -endfunction() - -# For 'cmake -P '. -if (SWIFT_SET_RPATH_FILE AND SWIFT_SET_RPATH_NEW_RPATH) - _swift_set_rpath_impl("${SWIFT_SET_RPATH_FILE}" "${SWIFT_SET_RPATH_NEW_RPATH}") -endif() diff --git a/cmake/modules/SwiftComponents.cmake b/cmake/modules/SwiftComponents.cmake index 5bfb3c7427693..c29f5286e1a28 100644 --- a/cmake/modules/SwiftComponents.cmake +++ b/cmake/modules/SwiftComponents.cmake @@ -65,11 +65,12 @@ # * toolchain-tools -- a subset of tools that we will install to the OSS toolchain. # * testsuite-tools -- extra tools required to run the Swift testsuite. # * static-mirror-lib -- Build the static mirror library used by SwiftStaticMirror. +# * swift-syntax-lib -- install swift-syntax libraries # * toolchain-dev-tools -- install development tools useful in a shared toolchain # * llvm-toolchain-dev-tools -- install LLVM development tools useful in a shared toolchain # * dev -- headers and libraries required to use Swift compiler as a library. set(_SWIFT_DEFINED_COMPONENTS - "autolink-driver;back-deployment;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;libexec;stdlib;stdlib-experimental;sdk-overlay;static-mirror-lib;editor-integration;tools;testsuite-tools;toolchain-tools;toolchain-dev-tools;llvm-toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers") + "autolink-driver;back-deployment;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;libexec;stdlib;stdlib-experimental;sdk-overlay;static-mirror-lib;swift-syntax-lib;editor-integration;tools;testsuite-tools;toolchain-tools;toolchain-dev-tools;llvm-toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers") # The default install components include all of the defined components, except # for the following exceptions. @@ -96,6 +97,12 @@ macro(swift_configure_components) set(SWIFT_INSTALL_COMPONENTS "${_SWIFT_DEFAULT_COMPONENTS}" CACHE STRING "A semicolon-separated list of components to install from the set ${_SWIFT_DEFINED_COMPONENTS}") + # 'compiler' depends on 'swift-syntax-lib' component. + if ("compiler" IN_LIST SWIFT_INSTALL_COMPONENTS AND + NOT "swift-syntax-lib" IN_LIST SWIFT_INSTALL_COMPONENTS) + list(APPEND SWIFT_INSTALL_COMPONENTS "swift-syntax-lib") + endif() + foreach(component ${_SWIFT_DEFINED_COMPONENTS}) add_custom_target(${component}) add_llvm_install_targets(install-${component} diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index 9e5590b7315db..4bf20a642f0f8 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -155,10 +155,10 @@ target_link_libraries(swiftAST INTERFACE clangAPINotes clangBasic) -if(SWIFT_SWIFT_PARSER) +if(SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftAST PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/ASTGen/CMakeLists.txt b/lib/ASTGen/CMakeLists.txt index b80782f838e52..2628124156dfd 100644 --- a/lib/ASTGen/CMakeLists.txt +++ b/lib/ASTGen/CMakeLists.txt @@ -24,15 +24,15 @@ add_pure_swift_host_library(swiftASTGen STATIC DEPENDENCIES swiftAST SWIFT_DEPENDENCIES - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftCompilerPluginMessageHandling - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros - SwiftSyntax::SwiftSyntaxMacroExpansion + SwiftBasicFormat + SwiftCompilerPluginMessageHandling + SwiftDiagnostics + SwiftOperators + SwiftParser + SwiftParserDiagnostics + SwiftSyntax + SwiftSyntaxBuilder + SwiftSyntaxMacros + SwiftSyntaxMacroExpansion swiftLLVMJSON ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7a6f55c80406f..3c580fd824fb0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -13,9 +13,7 @@ list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen clang-tablegen-targets) # Set up for linking against swift-syntax. -if (SWIFT_SWIFT_PARSER) - # Set up linking against the swift-syntax modules. - # Link against the swift-syntax modules. +if (SWIFT_BUILD_SWIFT_SYNTAX) set(SWIFT_SYNTAX_MODULES SwiftBasicFormat SwiftParser @@ -29,130 +27,43 @@ if (SWIFT_SWIFT_PARSER) SwiftCompilerPluginMessageHandling ) - # Compute the list of SwiftSyntax targets that we will link against. - list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "SwiftSyntax::" - OUTPUT_VARIABLE SWIFT_SYNTAX_TARGETS) - - set(SWIFT_SYNTAX_LIBRARIES_BUILD_DIR - "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host") - set(SWIFT_HOST_LIBRARIES_DEST_DIR - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/host") - - # Determine the SwiftSyntax shared library files that were built as - # part of earlyswiftsyntax. - list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "${CMAKE_SHARED_LIBRARY_PREFIX}" - OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES) - list(TRANSFORM SWIFT_SYNTAX_SHARED_LIBRARIES APPEND - "${CMAKE_SHARED_LIBRARY_SUFFIX}" - OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES) - - list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "${CMAKE_IMPORT_LIBRARY_PREFIX}" - OUTPUT_VARIABLE SWIFT_SYNTAX_IMPORT_LIBRARIES) - list(TRANSFORM SWIFT_SYNTAX_IMPORT_LIBRARIES APPEND - "${CMAKE_IMPORT_LIBRARY_SUFFIX}" OUTPUT_VARIABLE - SWIFT_SYNTAX_IMPORT_LIBRARIES) - - # Interface library to collect swiftinterfaces and swiftmodules from - # SwiftSyntax - add_library(swiftSyntaxLibraries INTERFACE) - - # Copy over all of the shared libraries from earlyswiftsyntax so they can - # be found via RPATH. - foreach (sharedlib ${SWIFT_SYNTAX_SHARED_LIBRARIES}) - set(add_origin_rpath) - if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD") - # At runtime, use swiftCore in the current toolchain. - swift_get_set_rpath_script_file(setrpath_command) - set(add_origin_rpath COMMAND ${CMAKE_COMMAND} - "-DSWIFT_SET_RPATH_FILE=${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - "-DSWIFT_SET_RPATH_NEW_RPATH='$$ORIGIN:$$ORIGIN/../${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}'" - -P "${setrpath_command}" - ) - endif() - - if(CMAKE_SYSTEM_NAME MATCHES Windows) - add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${sharedlib} - DEPENDS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/bin/${sharedlib}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/bin/${sharedlib} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${sharedlib}) - add_custom_target(copy_swiftSyntaxLibrary_${sharedlib} - DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${sharedlib} - COMMENT "copying ${sharedlib}") - swift_install_in_component(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${sharedlib} - DESTINATION bin - COMPONENT compiler) - else() - add_custom_command(OUTPUT "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - DEPENDS "${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${sharedlib}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${sharedlib} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib} - ${add_origin_rpath}) - add_custom_target(copy_swiftSyntaxLibrary_${sharedlib} - DEPENDS "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - COMMENT "Copying ${sharedlib}") - swift_install_in_component(PROGRAMS "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host" - COMPONENT compiler) - endif() - - add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${sharedlib}) - endforeach() - + # Install shared runtime libraries if(CMAKE_SYSTEM_NAME MATCHES Windows) - foreach(implib ${SWIFT_SYNTAX_IMPORT_LIBRARIES}) - add_custom_command(OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/windows/${SWIFT_HOST_VARIANT_ARCH}/${implib} - DEPENDS ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host/${implib} - COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host/${implib} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/windows/${SWIFT_HOST_VARIANT_ARCH}/${implib}) - add_custom_target(copy_swiftSyntaxLibrary_${implib} - DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/windows/${SWIFT_HOST_VARIANT_ARCH}/${implib} - COMMENT "Copying ${implib}") - swift_install_in_component(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/windows/${SWIFT_HOST_VARIANT_ARCH}/${implib} - DESTINATION lib - COMPONENT compiler) - add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${implib}) - endforeach() + swift_install_in_component(TARGETS ${SWIFT_SYNTAX_MODULES} + RUNTIME + DESTINATION "bin" + COMPONENT swift-syntax-lib) + else() + swift_install_in_component(TARGETS ${SWIFT_SYNTAX_MODULES} + LIBRARY + DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host" + COMPONENT swift-syntax-lib) endif() - # Copy all of the Swift modules from earlyswiftsyntax so they can be found - # in the same relative place within the build directory as in the final - # toolchain. - list(TRANSFORM SWIFT_SYNTAX_MODULES APPEND ".swiftmodule" - OUTPUT_VARIABLE SWIFT_SYNTAX_MODULE_DIRS) - - foreach(module_dir ${SWIFT_SYNTAX_MODULE_DIRS}) - # Find all of the source module files. - file(GLOB module_files - "${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${module_dir}/*.swiftinterface") - - # Determine the destination module files. - set(dest_module_files) - foreach(full_module_file ${module_files}) - get_filename_component(module_file ${full_module_file} NAME) - list(APPEND dest_module_files - "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir}/${module_file}") - endforeach() - - add_custom_command( - OUTPUT ${dest_module_files} - DEPENDS ${module_files} - COMMAND ${CMAKE_COMMAND} -E make_directory ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${module_files} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir}/ - ) - - add_custom_target(copy_swiftSyntaxModule_${module_dir} - DEPENDS ${dest_module_files} - COMMENT "Copying ${module_dir}" - ) - - swift_install_in_component( - FILES ${dest_module_files} - DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host/${module_dir}" - COMPONENT compiler - ) + # Install import libraries in Windows. + if(CMAKE_SYSTEM_NAME MATCHES Windows) + list(TRANSFORM SWIFT_SYNTAX_MODULES + PREPEND "${CMAKE_IMPORT_LIBRARY_PREFIX}" + OUTPUT_VARIABLE SWIFT_SYNTAX_IMPORT_LIBRARIES) + list(TRANSFORM SWIFT_SYNTAX_IMPORT_LIBRARIES + APPEND "${CMAKE_IMPORT_LIBRARY_SUFFIX}" + OUTPUT_VARIABLE SWIFT_SYNTAX_IMPORT_LIBRARIES) + list(TRANSFORM SWIFT_SYNTAX_IMPORT_LIBRARIES + PREPEND "${SWIFT_HOST_LIBRARIES_DEST_DIR}/" + OUTPUT_VARIABLE SWIFT_SYNTAX_IMPORT_LIBRARIES) + swift_install_in_component(PROGRAMS "${SWIFT_SYNTAX_IMPORT_LIBRARIES}" + DESTINATION lib + COMPONENT swift-syntax-lib) + endif() - add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxModule_${module_dir}) + # Install Swift module interface files. + foreach(module ${SWIFT_SYNTAX_MODULES}) + set(module_dir "${module}.swiftmodule") + set(module_file "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir}/${SWIFT_HOST_MODULE_TRIPLE}.swiftinterface") + swift_install_in_component(FILES "${module_file}" + DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host/${module_dir}" + COMPONENT swift-syntax-lib) endforeach() - - # Add copied SwiftSyntax libraries to global dependencies. - list(APPEND LLVM_COMMON_DEPENDS swiftSyntaxLibraries) endif() add_subdirectory(APIDigester) diff --git a/lib/Frontend/CMakeLists.txt b/lib/Frontend/CMakeLists.txt index c01fdcf7e174b..ebb9a2aeecabf 100644 --- a/lib/Frontend/CMakeLists.txt +++ b/lib/Frontend/CMakeLists.txt @@ -37,9 +37,9 @@ target_link_libraries(swiftFrontend PRIVATE set_swift_llvm_is_available(swiftFrontend) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftFrontend PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/Frontend/PrintingDiagnosticConsumer.cpp b/lib/Frontend/PrintingDiagnosticConsumer.cpp index 9f6a8976c3aef..da70fa1f2f177 100644 --- a/lib/Frontend/PrintingDiagnosticConsumer.cpp +++ b/lib/Frontend/PrintingDiagnosticConsumer.cpp @@ -315,7 +315,7 @@ namespace { } } // end anonymous namespace -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Enqueue a diagnostic with ASTGen's diagnostic rendering. static void enqueueDiagnostic( void *queuedDiagnostics, const DiagnosticInfo &info, SourceManager &SM @@ -389,7 +389,7 @@ static SmallVector getSourceBufferStack( } } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX void PrintingDiagnosticConsumer::queueBuffer( SourceManager &sourceMgr, unsigned bufferID) { QueuedBuffer knownSourceFile = queuedBuffers[bufferID]; @@ -454,7 +454,7 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM, switch (FormattingStyle) { case DiagnosticOptions::FormattingStyle::Swift: { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX // Use the swift-syntax formatter. auto bufferStack = getSourceBufferStack(SM, Info.Loc); if (!bufferStack.empty()) { @@ -496,7 +496,7 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM, } void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (queuedDiagnostics) { char *renderedString = nullptr; SwiftInt renderedStringLen = 0; diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index a9c9a6f720bc1..b18af9bc03cb4 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -1173,7 +1173,7 @@ static void addPoundDirectives(CodeCompletionResultSink &Sink) { Builder.addRightParen(); }); -#ifndef SWIFT_SWIFT_PARSER +#ifndef SWIFT_BUILD_SWIFT_SYNTAX addWithName("warning", CodeCompletionKeywordKind::pound_warning, [&] (CodeCompletionResultBuilder &Builder) { Builder.addLeftParen(); diff --git a/lib/Macros/CMakeLists.txt b/lib/Macros/CMakeLists.txt index 3598a4e917557..23e7de788cd47 100644 --- a/lib/Macros/CMakeLists.txt +++ b/lib/Macros/CMakeLists.txt @@ -33,7 +33,7 @@ function(add_swift_macro_library name) # If we don't have the Swift swift parser, bail out, because the above # add_pure_swift_host_library did nothing. - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) return() endif() diff --git a/lib/Macros/Sources/ObservationMacros/CMakeLists.txt b/lib/Macros/Sources/ObservationMacros/CMakeLists.txt index 3afd3380125aa..c3deee2c4747a 100644 --- a/lib/Macros/Sources/ObservationMacros/CMakeLists.txt +++ b/lib/Macros/Sources/ObservationMacros/CMakeLists.txt @@ -15,9 +15,9 @@ add_swift_macro_library(ObservationMacros Extensions.swift ObservableMacro.swift SWIFT_DEPENDENCIES - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxMacros + SwiftDiagnostics + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntax + SwiftSyntaxMacros ) diff --git a/lib/Macros/Sources/SwiftMacros/CMakeLists.txt b/lib/Macros/Sources/SwiftMacros/CMakeLists.txt index 32a798260afdb..9d83b612b4987 100644 --- a/lib/Macros/Sources/SwiftMacros/CMakeLists.txt +++ b/lib/Macros/Sources/SwiftMacros/CMakeLists.txt @@ -13,8 +13,8 @@ add_swift_macro_library(SwiftMacros OptionSetMacro.swift SWIFT_DEPENDENCIES - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftDiagnostics + SwiftSyntax + SwiftSyntaxBuilder + SwiftSyntaxMacros ) diff --git a/lib/Parse/CMakeLists.txt b/lib/Parse/CMakeLists.txt index 1b66331ad7e6d..8a01e55f893b0 100644 --- a/lib/Parse/CMakeLists.txt +++ b/lib/Parse/CMakeLists.txt @@ -25,35 +25,35 @@ target_link_libraries(swiftParse PRIVATE swiftAST ) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_link_libraries(swiftParse PRIVATE - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftBasicFormat + SwiftParser + SwiftParserDiagnostics + SwiftDiagnostics + SwiftSyntax + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntaxMacros swiftASTGen ) add_dependencies(swiftParse - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftBasicFormat + SwiftParser + SwiftParserDiagnostics + SwiftDiagnostics + SwiftSyntax + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntaxMacros swiftASTGen ) target_compile_definitions(swiftParse PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index b0ad653786b7b..6081deac3b374 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -163,7 +163,7 @@ extern "C" void parseTopLevelSwift(const char *buffer, void *outputContext, void (*)(void *, void *)); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX static void appendToVector(void *declPtr, void *vecPtr) { auto vec = static_cast *>(vecPtr); auto decl = static_cast(declPtr); @@ -209,7 +209,7 @@ extern "C" void swift_ASTGen_buildTopLevelASTNodes(void *sourceFile, /// decl-sil-stage [[only in SIL mode] /// \endverbatim void Parser::parseTopLevelItems(SmallVectorImpl &items) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX llvm::Optional existingParsingTransaction; parseSourceFileViaASTGen(items, existingParsingTransaction); #endif @@ -260,7 +260,7 @@ void Parser::parseTopLevelItems(SmallVectorImpl &items) { } } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (existingParsingTransaction) existingParsingTransaction->abort(); @@ -312,7 +312,7 @@ void Parser::parseTopLevelItems(SmallVectorImpl &items) { void *ExportedSourceFileRequest::evaluate(Evaluator &evaluator, const SourceFile *SF) const { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX // The SwiftSyntax parser doesn't (yet?) handle SIL. if (SF->Kind == SourceFileKind::SIL) return nullptr; @@ -345,7 +345,7 @@ void Parser::parseSourceFileViaASTGen( SmallVectorImpl &items, llvm::Optional &transaction, bool suppressDiagnostics) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX const auto &langOpts = Context.LangOpts; // We only need to do parsing if we either have ASTGen enabled, or want the diff --git a/lib/Parse/ParseIfConfig.cpp b/lib/Parse/ParseIfConfig.cpp index ef10f8fdde5b8..58d991841cab3 100644 --- a/lib/Parse/ParseIfConfig.cpp +++ b/lib/Parse/ParseIfConfig.cpp @@ -557,7 +557,7 @@ class EvaluateIfConfigCondition : // Check whether this is any one of the known compiler features. const auto &langOpts = Ctx.LangOpts; -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX const bool hasSwiftSwiftParser = true; #else const bool hasSwiftSwiftParser = false; diff --git a/lib/Parse/ParseType.cpp b/lib/Parse/ParseType.cpp index db7323c69dae8..83a86e4b9a342 100644 --- a/lib/Parse/ParseType.cpp +++ b/lib/Parse/ParseType.cpp @@ -601,7 +601,7 @@ extern "C" TypeRepr *swift_ASTGen_buildTypeRepr( /// ParserResult Parser::parseType( Diag<> MessageID, ParseTypeReason reason) { - #if SWIFT_SWIFT_PARSER + #if SWIFT_BUILD_SWIFT_SYNTAX auto astGenResult = parseASTFromSyntaxTree( [&](void *exportedSourceFile, const void *sourceLoc) { const void *endLocPtr = nullptr; diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt index 16494b3ff76d2..6a80e3c20768d 100644 --- a/lib/Sema/CMakeLists.txt +++ b/lib/Sema/CMakeLists.txt @@ -86,10 +86,10 @@ target_link_libraries(swiftSema PRIVATE swiftParse swiftSerialization) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftSema PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) target_link_libraries(swiftSema PRIVATE swiftASTGen) diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 0891865a43fcc..61b2c0eae84d5 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -2934,7 +2934,7 @@ namespace { } Expr *visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX auto &ctx = cs.getASTContext(); if (ctx.LangOpts.hasFeature(Feature::BuiltinMacros)) { auto expandedType = solution.simplifyType(solution.getType(expr)); diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 882349e9acf49..af0de3c9628d9 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -1356,7 +1356,7 @@ namespace { } Type visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { -#ifdef SWIFT_SWIFT_PARSER +#ifdef SWIFT_BUILD_SWIFT_SYNTAX auto &ctx = CS.getASTContext(); if (ctx.LangOpts.hasFeature(Feature::BuiltinMacros)) { auto kind = MagicIdentifierLiteralExpr::getKindString(expr->getKind()) diff --git a/lib/Sema/TypeCheckMacros.cpp b/lib/Sema/TypeCheckMacros.cpp index 5313ab221e60e..6cc8cb36ac735 100644 --- a/lib/Sema/TypeCheckMacros.cpp +++ b/lib/Sema/TypeCheckMacros.cpp @@ -94,7 +94,7 @@ extern "C" bool swift_ASTGen_pluginServerLoadLibraryPlugin( void *handle, const char *libraryPath, const char *moduleName, void *diagEngine); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Look for macro's type metadata given its external module and type name. static void const * lookupMacroTypeMetadataByExternalName(ASTContext &ctx, StringRef moduleName, @@ -190,7 +190,7 @@ MacroDefinition MacroDefinitionRequest::evaluate( auto sourceFile = macro->getParentSourceFile(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX char *externalMacroNamePtr; ptrdiff_t externalMacroNameLength; ptrdiff_t *replacements; @@ -296,7 +296,7 @@ initializeExecutablePlugin(ASTContext &ctx, // FIXME: Ideally this should be done right after invoking the plugin. // But plugin loading is in libAST and it can't link ASTGen symbols. if (!executablePlugin->isInitialized()) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (!swift_ASTGen_initializePlugin(executablePlugin, &ctx.Diags)) { return nullptr; } @@ -317,7 +317,7 @@ initializeExecutablePlugin(ASTContext &ctx, // If this is a plugin server, load the library. if (!libraryPath.empty()) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX llvm::SmallString<128> resolvedLibraryPath; auto fs = ctx.SourceMgr.getFileSystem(); if (auto err = fs->getRealPath(libraryPath, resolvedLibraryPath)) { @@ -391,7 +391,7 @@ CompilerPluginLoadRequest::evaluate(Evaluator &evaluator, ASTContext *ctx, static llvm::Optional resolveInProcessMacro(ASTContext &ctx, Identifier moduleName, Identifier typeName, LoadedLibraryPlugin *plugin) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Look for the type metadata given the external module and type names. auto macroMetatype = lookupMacroTypeMetadataByExternalName( ctx, moduleName.str(), typeName.str(), plugin); @@ -415,7 +415,7 @@ static llvm::Optional resolveExecutableMacro(ASTContext &ctx, LoadedExecutablePlugin *executablePlugin, Identifier moduleName, Identifier typeName) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (auto *execMacro = swift_ASTGen_resolveExecutableMacro( moduleName.str().data(), moduleName.str().size(), typeName.str().data(), typeName.str().size(), executablePlugin)) { @@ -986,7 +986,7 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion, LazyValue discriminator([&]() -> std::string { if (!discriminatorStr.empty()) return discriminatorStr.str(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX Mangle::ASTMangler mangler; return mangler.mangleMacroExpansion(expansion); #else @@ -1047,7 +1047,7 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion, return nullptr; } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX PrettyStackTraceFreestandingMacroExpansion debugStack( "expanding freestanding macro", expansion); @@ -1226,7 +1226,7 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo, LazyValue discriminator([&]() -> std::string { if (!discriminatorStr.empty()) return discriminatorStr.str(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX Mangle::ASTMangler mangler; return mangler.mangleAttachedMacroExpansion(attachedTo, attr, role); #else @@ -1304,7 +1304,7 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo, return nullptr; } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX PrettyStackTraceDecl debugStack("expanding attached macro", attachedTo); auto *astGenAttrSourceFile = attrSourceFile->getExportedSourceFile(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a2998850bb96d..96411667cb4ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -210,16 +210,7 @@ normalize_boolean_spelling(SWIFT_STDLIB_ENABLE_OBJC_INTEROP) normalize_boolean_spelling(SWIFT_ENABLE_BACKTRACING) is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED) -# Get 'SWIFT_HOST_TRIPLE' and 'SWIFT_HOST_SDKROOT' for lit.site.cfg.in -if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) - set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}") -endif() -if(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID") - set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL}) -endif() -get_target_triple(SWIFT_HOST_TRIPLE SWIFT_HOST_TRIPLE_VARIANT "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}" - MACCATALYST_BUILD_FLAVOR "" - DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}") +# Get 'SWIFT_HOST_SDKROOT' for lit.site.cfg.in set(SWIFT_HOST_SDKROOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}") set(profdata_merge_worker diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 8544f2a22bcea..8d4414f3c5d36 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -166,7 +166,7 @@ elif "@BOOTSTRAPPING_MODE@" == 'BOOTSTRAPPING': elif "@BOOTSTRAPPING_MODE@" == 'BOOTSTRAPPING-WITH-HOSTLIBS': config.available_features.add('bootstrapping_with_hostlibs_mode') -if '@SWIFT_SWIFT_PARSER@' == 'TRUE': +if '@SWIFT_BUILD_SWIFT_SYNTAX@' == 'TRUE': config.available_features.add('swift_swift_parser') # Let the main config do the real work. diff --git a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake index 2293712165751..4b5a63fef6046 100644 --- a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake +++ b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake @@ -25,7 +25,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES) # to do it. set(ASKD_BOOTSTRAPPING_MODE ${BOOTSTRAPPING_MODE}) if (NOT ASKD_BOOTSTRAPPING_MODE) - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(ASKD_BOOTSTRAPPING_MODE HOSTTOOLS) endif() endif() @@ -152,7 +152,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES) endif() endif() - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) # Add rpath to the host Swift libraries. file(RELATIVE_PATH relative_hostlib_path "${path}" "${SWIFTLIB_DIR}/host") @@ -261,7 +261,7 @@ macro(add_sourcekit_library name) endif() # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER AND SOURCEKITLIB_SHARED) + if (SWIFT_BUILD_SWIFT_SYNTAX AND SOURCEKITLIB_SHARED) set(SOURCEKITLIB_HAS_SWIFT_MODULES ON) endif() @@ -365,7 +365,7 @@ macro(add_sourcekit_framework name) set(framework_location "${lib_dir}/${name}.framework") # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(SOURCEKITFW_HAS_SWIFT_MODULES ON) endif() diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index f08e56ee3c2f1..1b350f229d4a5 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -4,9 +4,7 @@ # Add additional libraries to which we need to link when the Swift Swift # parser is built in. function(add_swift_parser_link_libraries target) - if(SWIFT_SWIFT_PARSER) - target_link_directories(${target} PRIVATE - ${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}) + if(SWIFT_BUILD_SWIFT_SYNTAX) target_link_libraries(${target} PRIVATE swiftCore) diff --git a/tools/libSwiftScan/CMakeLists.txt b/tools/libSwiftScan/CMakeLists.txt index 1a99080337f84..ced11bf418416 100644 --- a/tools/libSwiftScan/CMakeLists.txt +++ b/tools/libSwiftScan/CMakeLists.txt @@ -43,7 +43,7 @@ if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD" AND BOOTSTRAPP ) endif() -if(SWIFT_SWIFT_PARSER) +if(SWIFT_BUILD_SWIFT_SYNTAX) if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) # Ensure that we can find the host shared libraries. set_property( diff --git a/tools/swift-plugin-server/CMakeLists.txt b/tools/swift-plugin-server/CMakeLists.txt index 1d1b88b22bd8a..34e8637089521 100644 --- a/tools/swift-plugin-server/CMakeLists.txt +++ b/tools/swift-plugin-server/CMakeLists.txt @@ -1,4 +1,4 @@ -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) # _swiftCSwiftPluginServer is just a C support library for swift-plugin-server # Don't bother to create '.a' for that. add_swift_host_library(_swiftCSwiftPluginServer OBJECT @@ -19,9 +19,9 @@ if (SWIFT_SWIFT_PARSER) SWIFT_COMPONENT compiler SWIFT_DEPENDENCIES - SwiftSyntax::SwiftSyntaxMacros - SwiftSyntax::SwiftSyntaxMacroExpansion - SwiftSyntax::SwiftCompilerPluginMessageHandling + SwiftSyntaxMacros + SwiftSyntaxMacroExpansion + SwiftCompilerPluginMessageHandling swiftLLVMJSON ) target_include_directories(swift-plugin-server PRIVATE diff --git a/utils/build-script-impl b/utils/build-script-impl index f16b13d7bd17c..8e88cd120a39f 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -844,16 +844,6 @@ function set_build_options_for_host() { swift_cmake_options+=( -DCOVERAGE_DB="${COVERAGE_DB}" ) - - if [[ "$(true_false ${SWIFT_EARLYSWIFTSYNTAX})" == "TRUE" ]]; then - early_swiftsyntax_build_dir="$(build_directory ${host} earlyswiftsyntax)" - swift_cmake_options+=( - -DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}" - ) - lldb_cmake_options+=( - -DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}" - ) - fi } function configure_default_options() { diff --git a/utils/swift_build_support/swift_build_support/build_script_invocation.py b/utils/swift_build_support/swift_build_support/build_script_invocation.py index 1e54515905ccf..f294adac6dcfd 100644 --- a/utils/swift_build_support/swift_build_support/build_script_invocation.py +++ b/utils/swift_build_support/swift_build_support/build_script_invocation.py @@ -248,13 +248,15 @@ def convert_to_impl_arguments(self): if args.swift_disable_dead_stripping: args.extra_cmake_options.append('-DSWIFT_DISABLE_DEAD_STRIPPING:BOOL=TRUE') - swift_syntax_src = os.path.join(self.workspace.source_root, - "swift-syntax") - args.extra_cmake_options.append( - '-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH={}'.format(swift_syntax_src)) - if args.build_early_swiftsyntax: - impl_args += ["--swift-earlyswiftsyntax"] + swift_syntax_src = os.path.join(self.workspace.source_root, + "swift-syntax") + args.extra_cmake_options.append( + '-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH={}'.format(swift_syntax_src)) + args.extra_cmake_options.append('-DSWIFT_BUILD_SWIFT_SYNTAX:BOOL=TRUE') + if self.args.assertions: + args.extra_cmake_options.append( + '-DSWIFTSYNTAX_ENABLE_ASSERTIONS:BOOL=TRUE') # Then add subproject install flags that either skip building them /or/ # if we are going to build them and install_all is set, we also install @@ -443,6 +445,15 @@ def convert_to_impl_arguments(self): os.path.abspath(args.coverage_db) ] + # '--install-swiftsyntax' is a legacy form of 'swift-syntax-lib' + # install component. + if (args.install_swiftsyntax and + '--install-swift' not in args.build_script_impl_args): + impl_args += [ + "--install-swift", + "--swift-install-components=swift-syntax-lib" + ] + if args.llvm_install_components: impl_args += [ "--llvm-install-components=%s" % args.llvm_install_components @@ -565,9 +576,6 @@ def compute_product_pipelines(self): builder.begin_pipeline() - builder.add_product(products.EarlySwiftSyntax, - is_enabled=self.args.build_early_swiftsyntax) - # If --skip-early-swift-driver is passed in, swift will be built # as usual, but relying on its own C++-based (Legacy) driver. # Otherwise, we build an "early" swift-driver using the host diff --git a/utils/swift_build_support/swift_build_support/products/__init__.py b/utils/swift_build_support/swift_build_support/products/__init__.py index 5f4d65c7ad995..5a382b8cd68c7 100644 --- a/utils/swift_build_support/swift_build_support/products/__init__.py +++ b/utils/swift_build_support/swift_build_support/products/__init__.py @@ -14,7 +14,6 @@ from .cmark import CMark from .curl import LibCurl from .earlyswiftdriver import EarlySwiftDriver -from .earlyswiftsyntax import EarlySwiftSyntax from .foundation import Foundation from .indexstoredb import IndexStoreDB from .libcxx import LibCXX @@ -63,7 +62,6 @@ 'SwiftPM', 'SwiftDriver', 'EarlySwiftDriver', - 'EarlySwiftSyntax', 'XCTest', 'SwiftSyntax', 'SKStressTester', diff --git a/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py b/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py index 48f4e59014f1a..62c5222a54bf3 100644 --- a/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py +++ b/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py @@ -13,7 +13,6 @@ import os import sys -from . import earlyswiftsyntax from . import product from .. import shell from .. import toolchain @@ -64,11 +63,7 @@ def should_build(self, host_target): @classmethod def get_dependencies(cls): - # FIXME: This isn't a real dependency, but is necessary to linearize the - # dependency graph from Swift to EarlySwiftSyntax. If we properly - # express the dependency from Swift -> EarlySwiftSyntax, build_graph.py - # asserts that there are multiple roots to the graph. - return [earlyswiftsyntax.EarlySwiftSyntax] + return [] def should_clean(self, host_target): return self.args.clean_early_swift_driver diff --git a/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py b/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py deleted file mode 100644 index 37c1bede9b0bd..0000000000000 --- a/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py +++ /dev/null @@ -1,82 +0,0 @@ -# swift_build_support/products/earlyswiftsyntax.py --------------*- python -*- -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ---------------------------------------------------------------------------- - -import sys - -from . import cmake_product -from .. import toolchain - - -# SwiftSyntax is a Swift module used to parse and manipulate Swift syntax. This -# build product is a "Special" SwiftSyntax that gets built with the host -# toolchain that can be linked into the Swift compiler itself, hence it does not -# depend on any other build product of `build-script`. -class EarlySwiftSyntax(cmake_product.CMakeProduct): - @classmethod - def product_source_name(cls): - return "swift-syntax" - - @classmethod - def is_build_script_impl_product(cls): - return False - - @classmethod - def is_before_build_script_impl_product(cls): - return True - - def should_build(self, host_target): - # Temporarily disable for non-darwin since this build never works - # outside of that case currently. - if sys.platform != 'darwin' and sys.platform != 'linux': - return False - - if self.args.build_early_swiftsyntax: - if toolchain.host_toolchain().find_tool("swift") is None: - warn_msg = 'Host toolchain could not locate a '\ - 'compiler to build early swift-syntax.' - print('-- Warning: {}', warn_msg) - return False - else: - return True - return False - - @classmethod - def get_dependencies(cls): - return [] - - def build(self, host_target): - self.cmake_options.define('CMAKE_BUILD_TYPE:STRING', - self.args.swift_build_variant) - self.cmake_options.define('BUILD_SHARED_LIBS:STRING', 'YES') - - self.generate_toolchain_file_for_darwin_or_linux(host_target) - - self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', self.args.install_prefix) - self.cmake_options.define('SWIFTSYNTAX_ENABLE_ASSERTIONS:BOOL', - self.args.assertions) - self.build_with_cmake(["all"], self.args.swift_build_variant, []) - - def should_test(self, host_target): - # The normal SwiftSyntax target runs tests through SwiftPM. - return False - - def test(self, host_target): - pass - - def should_install(self, host_target): - # When '--install-swift' is enabled, earlyswiftsyntax libraries are installed - # from 'swift' product. - return (self.should_build(host_target) and self.args.install_swiftsyntax and - "--install-swift" not in self.args.build_script_impl_args) - - def install(self, host_target): - self.install_with_cmake(["install"], self.host_install_destdir(host_target)) From ac08a9729a89c2c37844ee40fb4daa53e155698b Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 09:38:33 -0700 Subject: [PATCH 4/7] [Tests] Mark macro test 'REQUIRES: swift_swift_parser' rdar://116239522 (cherry picked from commit d0dfd753416abdb74f31fc604dc910cc60eedef6) --- test/IDE/complete_pound_expr.swift | 2 +- test/Macros/extension_macro_plugin.swift | 3 +-- test/Macros/macro_plugin_server.swift | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/IDE/complete_pound_expr.swift b/test/IDE/complete_pound_expr.swift index bb074a1ab0d26..4bfd862f00d68 100644 --- a/test/IDE/complete_pound_expr.swift +++ b/test/IDE/complete_pound_expr.swift @@ -1,7 +1,7 @@ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POUND_EXPR_1 | %FileCheck %s -check-prefix=POUND_EXPR_INTCONTEXT // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POUND_EXPR_2 | %FileCheck %s -check-prefix=POUND_EXPR_STRINGCONTEXT // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POUND_EXPR_3 | %FileCheck %s -check-prefix=POUND_EXPR_SELECTORCONTEXT -// REQUIRES: objc_interop +// REQUIRES: objc_interop, swift_swift_parser import ObjectiveC diff --git a/test/Macros/extension_macro_plugin.swift b/test/Macros/extension_macro_plugin.swift index 5204d9c74fb4b..51800270d7be5 100644 --- a/test/Macros/extension_macro_plugin.swift +++ b/test/Macros/extension_macro_plugin.swift @@ -1,5 +1,4 @@ -// FIXME: Swift parser is not enabled on Linux CI yet. -// REQUIRES: OS=macosx +// REQUIRES: swift_swift_parser // RUN: %empty-directory(%t) // RUN: %empty-directory(%t/plugins) diff --git a/test/Macros/macro_plugin_server.swift b/test/Macros/macro_plugin_server.swift index f2bd9012efa18..12dae8eebc07f 100644 --- a/test/Macros/macro_plugin_server.swift +++ b/test/Macros/macro_plugin_server.swift @@ -1,5 +1,4 @@ -// FIXME: Swift parser is not enabled on Linux CI yet. -// REQUIRES: OS=macosx +// REQUIRES: swift_swift_parser // RUN: %empty-directory(%t) // RUN: %empty-directory(%t/plugins) From e1641049f5a6f4100c832cefd19d1d88fed4a30b Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 11:42:31 -0700 Subject: [PATCH 5/7] [Macros] Fix plugin-server test for non-Darwin platforms `.dylib` was hardcoded. Accept other platforms' shared library filenames (cherry picked from commit e9a183c502ea9b2440537603be9b6a8a1e6bbf15) --- test/Macros/macro_plugin_server.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Macros/macro_plugin_server.swift b/test/Macros/macro_plugin_server.swift index 12dae8eebc07f..50d1202f7c353 100644 --- a/test/Macros/macro_plugin_server.swift +++ b/test/Macros/macro_plugin_server.swift @@ -46,9 +46,9 @@ // CHECK: ->(plugin:[[#PID1:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION:]]}}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"getCapabilityResult":{"capability":{"features":["load-plugin-library"],"protocolVersion":[[#PROTOCOL_VERSION]]}}} -// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}plugins/libMacroDefinition.dylib","moduleName":"MacroDefinition"}} +// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} -// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}plugins/libEvilMacros.dylib","moduleName":"EvilMacros"}} +// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} // CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"${{.*}}","macro":{"moduleName":"MacroDefinition","name":"stringify","typeName":"StringifyMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{{{.+}}},"source":"#stringify(a + b)"}}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"expandMacroResult":{"diagnostics":[],"expandedSource":"(a + b, \"a + b\")"}} @@ -57,9 +57,9 @@ // CHECK: ->(plugin:[[#PID2:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION]]}}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"getCapabilityResult":{"capability":{"features":["load-plugin-library"],"protocolVersion":[[#PROTOCOL_VERSION]]}}} -// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}plugins/libMacroDefinition.dylib","moduleName":"MacroDefinition"}} +// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} -// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}plugins/libEvilMacros.dylib","moduleName":"EvilMacros"}} +// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} // CHECK-NEXT: ->(plugin:[[#PID2]]) {"expandFreestandingMacro":{"discriminator":"${{.*}}","macro":{"moduleName":"MacroDefinition","name":"stringify","typeName":"StringifyMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{{{.+}}},"source":"#stringify(b + a)"}}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"expandMacroResult":{"diagnostics":[],"expandedSource":"(b + a, \"b + a\")"}} From 357f17f4c144fc1b5d1fea6051a8b00474a9ad0e Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 12:38:30 -0700 Subject: [PATCH 6/7] [Windows] Enable macros in Windows After FetchContent changes, macros in Windows were disabled. (cherry picked from commit 00f993529793fec6755cce915e69ad2baca1a265) --- CMakeLists.txt | 3 ++- test/CMakeLists.txt | 1 + test/Macros/extension_macro_plugin.swift | 2 +- test/Macros/macro_plugin_server.swift | 10 +++++----- utils/build-windows-toolchain.bat | 1 + utils/build-windows.bat | 2 ++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 726758e7143d3..38b9f214e467b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1336,8 +1336,9 @@ if(SWIFT_INCLUDE_TOOLS) set(SWIFT_HOST_LIBRARIES_RPATH "$ORIGIN;$ORIGIN/../${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}") endif() + file(TO_CMAKE_PATH "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}" swift_syntax_path) FetchContent_Declare(SwiftSyntax - SOURCE_DIR "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}" + SOURCE_DIR "${swift_syntax_path}" ) FetchContent_MakeAvailable(SwiftSyntax) endfunction() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 96411667cb4ec..cad0d77e194aa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -208,6 +208,7 @@ normalize_boolean_spelling(SWIFT_STDLIB_ENABLE_UNICODE_DATA) normalize_boolean_spelling(SWIFT_ENABLE_DISPATCH) normalize_boolean_spelling(SWIFT_STDLIB_ENABLE_OBJC_INTEROP) normalize_boolean_spelling(SWIFT_ENABLE_BACKTRACING) +normalize_boolean_spelling(SWIFT_BUILD_SWIFT_SYNTAX) is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED) # Get 'SWIFT_HOST_SDKROOT' for lit.site.cfg.in diff --git a/test/Macros/extension_macro_plugin.swift b/test/Macros/extension_macro_plugin.swift index 51800270d7be5..eaf90a366c231 100644 --- a/test/Macros/extension_macro_plugin.swift +++ b/test/Macros/extension_macro_plugin.swift @@ -12,7 +12,7 @@ // RUN: %S/Inputs/syntax_macro_definitions.swift \ // RUN: -g -no-toolchain-stdlib-rpath -// RUN: SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \ +// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \ // RUN: -typecheck -verify \ // RUN: -swift-version 5 -enable-experimental-feature ExtensionMacros \ // RUN: -external-plugin-path %t/plugins#%swift-plugin-server \ diff --git a/test/Macros/macro_plugin_server.swift b/test/Macros/macro_plugin_server.swift index 50d1202f7c353..2a99bb19f0d10 100644 --- a/test/Macros/macro_plugin_server.swift +++ b/test/Macros/macro_plugin_server.swift @@ -20,7 +20,7 @@ // RUN: %S/Inputs/evil_macro_definitions.swift \ // RUN: -g -no-toolchain-stdlib-rpath -// RUN: SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \ +// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \ // RUN: -typecheck -verify \ // RUN: -swift-version 5 -enable-experimental-feature Macros \ // RUN: -external-plugin-path %t/plugins#%swift-plugin-server \ @@ -46,9 +46,9 @@ // CHECK: ->(plugin:[[#PID1:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION:]]}}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"getCapabilityResult":{"capability":{"features":["load-plugin-library"],"protocolVersion":[[#PROTOCOL_VERSION]]}}} -// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} +// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} -// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} +// CHECK-NEXT: ->(plugin:[[#PID1]]) {"loadPluginLibrary":{"libraryPath":"{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} // CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"${{.*}}","macro":{"moduleName":"MacroDefinition","name":"stringify","typeName":"StringifyMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{{{.+}}},"source":"#stringify(a + b)"}}} // CHECK-NEXT: <-(plugin:[[#PID1]]) {"expandMacroResult":{"diagnostics":[],"expandedSource":"(a + b, \"a + b\")"}} @@ -57,9 +57,9 @@ // CHECK: ->(plugin:[[#PID2:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION]]}}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"getCapabilityResult":{"capability":{"features":["load-plugin-library"],"protocolVersion":[[#PROTOCOL_VERSION]]}}} -// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} +// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"{{.*}}MacroDefinition.{{dylib|so|dll}}","moduleName":"MacroDefinition"}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} -// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"BUILD_DIR{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} +// CHECK-NEXT: ->(plugin:[[#PID2]]) {"loadPluginLibrary":{"libraryPath":"{{.*}}EvilMacros.{{dylib|so|dll}}","moduleName":"EvilMacros"}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"loadPluginLibraryResult":{"diagnostics":[],"loaded":true}} // CHECK-NEXT: ->(plugin:[[#PID2]]) {"expandFreestandingMacro":{"discriminator":"${{.*}}","macro":{"moduleName":"MacroDefinition","name":"stringify","typeName":"StringifyMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{{{.+}}},"source":"#stringify(b + a)"}}} // CHECK-NEXT: <-(plugin:[[#PID2]]) {"expandMacroResult":{"diagnostics":[],"expandedSource":"(b + a, \"b + a\")"}} diff --git a/utils/build-windows-toolchain.bat b/utils/build-windows-toolchain.bat index 99fbbb113a0c7..25257384cc5e6 100644 --- a/utils/build-windows-toolchain.bat +++ b/utils/build-windows-toolchain.bat @@ -252,6 +252,7 @@ cmake ^ -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION=YES ^ + -D SWIFT_BUILD_SWIFT_SYNTAX=YES ^ -D LLVM_EXTERNAL_SWIFT_SOURCE_DIR="%SourceRoot%\swift" ^ -D LLVM_EXTERNAL_CMARK_SOURCE_DIR="%SourceRoot%\cmark" ^ diff --git a/utils/build-windows.bat b/utils/build-windows.bat index ce0c325a0c125..47a5ccab65d0e 100644 --- a/utils/build-windows.bat +++ b/utils/build-windows.bat @@ -274,6 +274,7 @@ cmake^ -DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^ -DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO^ -DSWIFT_LIT_ARGS="--time-tests"^ + -DSWIFT_BUILD_SWIFT_SYNTAX=YES ^ -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH=%source_root%\swift-syntax^ -S "%source_root%\swift" %exitOnError% @@ -318,6 +319,7 @@ cmake^ -DLLDB_DISABLE_PYTHON=YES^ -DLLDB_INCLUDE_TESTS:BOOL=NO^ -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON^ + -DSWIFT_BUILD_SWIFT_SYNTAX=YES ^ -S "%source_root%\llvm-project\lldb" %exitOnError% cmake --build "%build_root%\lldb" %exitOnError% From ad889b348e77d1b437a87809dc71d698e808f512 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 15:11:38 -0700 Subject: [PATCH 7/7] [Windows] Don't build earlyswiftsyntax in Windows build-windows-toolchain.bat used to build and install 'swift-syntax' for the compiler. Now that swift-syntax is built as a part of 'swift' build. So no need to built it separately anymore. (cherry picked from commit fc03e2e0a6f8cd9838323e33330b7a1d44dde1fa) --- utils/build-windows-toolchain.bat | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/utils/build-windows-toolchain.bat b/utils/build-windows-toolchain.bat index 25257384cc5e6..528ef5ddc72d7 100644 --- a/utils/build-windows-toolchain.bat +++ b/utils/build-windows-toolchain.bat @@ -190,31 +190,6 @@ cmake --build "%BuildRoot%\curl" --target install || (exit /b) path %BuildRoot%\toolchains\5.9.0\PFiles64\Swift\runtime-development\usr\bin;%BuildRoot%\toolchains\5.9.0\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin;%Path% -:: Build Swift Syntax -cmake ^ - -B "%BuildRoot%\99" ^ - - -D BUILD_SHARED_LIBS=YES ^ - -D CMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^ - -D CMAKE_C_COMPILER=cl.exe ^ - -D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^ - -D CMAKE_CXX_COMPILER=cl ^ - -D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^ - -D CMAKE_MT=mt ^ - -D CMAKE_Swift_COMPILER=%BuildRoot%/toolchains/5.9.0/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe ^ - -D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^ - -D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^ - -D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^ - - -D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^ - - -D SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26=YES ^ - - -G Ninja ^ - -S %SourceRoot%\swift-syntax || (exit /b) -cmake --build %BuildRoot%\99 || (exit /b) -cmake --build %BuildRoot%\99 --target install || (exit /b) - :: Build Toolchain cmake ^ -B "%BuildRoot%\1" ^ @@ -258,7 +233,6 @@ cmake ^ -D LLVM_EXTERNAL_CMARK_SOURCE_DIR="%SourceRoot%\cmark" ^ -D PYTHON_HOME=%PYTHON_HOME% ^ -D PYTHON_EXECUTABLE=%PYTHON_HOME%\python.exe ^ - -D SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR="%BuildRoot%\99" ^ -D SWIFT_PATH_TO_LIBDISPATCH_SOURCE="%SourceRoot%\swift-corelibs-libdispatch" ^ -D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="%SourceRoot%\swift-syntax" ^ -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=%SourceRoot%\swift-experimental-string-processing ^