From d0dfd753416abdb74f31fc604dc910cc60eedef6 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 09:38:33 -0700 Subject: [PATCH 1/4] [Tests] Mark macro test 'REQUIRES: swift_swift_parser' rdar://116239522 --- 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 e9a183c502ea9b2440537603be9b6a8a1e6bbf15 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 11:42:31 -0700 Subject: [PATCH 2/4] [Macros] Fix plugin-server test for non-Darwin platforms `.dylib` was hardcoded. Accept other platforms' shared library filenames --- 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 00f993529793fec6755cce915e69ad2baca1a265 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 12:38:30 -0700 Subject: [PATCH 3/4] [Windows] Enable macros in Windows After FetchContent changes, macros in Windows were disabled. --- 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 fc03e2e0a6f8cd9838323e33330b7a1d44dde1fa Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 29 Sep 2023 15:11:38 -0700 Subject: [PATCH 4/4] [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. --- 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 ^