Skip to content

Commit 1ad818b

Browse files
committed
[build-script] Add module ABI name prefix to swift-syntax libraries
Add 'Compiler' prefix to ABI names of swift-syntax libraries so that compiler libraries (e.g. sourcekitdInProc) can be used from binaries linking with swift-syntax (e.g. via SwiftPM) swiftlang#68812 rdar://116951101
1 parent 2f52082 commit 1ad818b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

test/Macros/macro_plugin_error.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@
1717

1818
// CHECK: ->(plugin:[[#PID1:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION:]]}}}
1919
// CHECK-NEXT: <-(plugin:[[#PID1]]) {"getCapabilityResult":{"capability":{"protocolVersion":1}}}
20-
// CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":6,"offset":[[#]]},"source":"#fooMacro(1)"}}}
20+
// CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":7,"offset":[[#]]},"source":"#fooMacro(1)"}}}
2121
// CHECK-NEXT: <-(plugin:[[#PID1]]) {"invalidResponse":{}}
22-
// CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":8,"offset":[[#]]},"source":"#fooMacro(2)"}}}
22+
// CHECK-NEXT: ->(plugin:[[#PID1]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":9,"offset":[[#]]},"source":"#fooMacro(2)"}}}
2323
// ^ This messages causes the mock plugin exit because there's no matching expected message.
2424

2525
// CHECK: ->(plugin:[[#PID2:]]) {"getCapability":{"capability":{"protocolVersion":[[#PROTOCOL_VERSION]]}}}
2626
// CHECK-NEXT: <-(plugin:[[#PID2]]) {"getCapabilityResult":{"capability":{"protocolVersion":1}}}
27-
// CHECK-NEXT: ->(plugin:[[#PID2]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":10,"offset":[[#]]},"source":"#fooMacro(3)"}}}
27+
// CHECK-NEXT: ->(plugin:[[#PID2]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"fooMacro","typeName":"FooMacro"},"macroRole":"expression","syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"{{.+}}test.swift","line":11,"offset":[[#]]},"source":"#fooMacro(3)"}}}
2828
// CHECK-NEXT: <-(plugin:[[#PID2:]]) {"expandFreestandingMacroResult":{"diagnostics":[],"expandedSource":"3.description"}}
2929

3030
//--- test.swift
3131
@freestanding(expression) macro fooMacro(_: Any) -> String = #externalMacro(module: "TestPlugin", type: "FooMacro")
3232

3333
func test() {
3434
// FIXME: Should be more user friendly message.
35+
// FIXME: -module-abi-name ABI name is leaking.
3536

3637
let _: String = #fooMacro(1)
37-
// expected-error @-1 {{typeMismatch(SwiftCompilerPluginMessageHandling.PluginToHostMessage}}
38+
// expected-error @-1 {{typeMismatch(CompilerSwiftCompilerPluginMessageHandling.PluginToHostMessage}}
3839
let _: String = #fooMacro(2)
3940
// expected-error @-1 {{failed to receive result from plugin (from macro 'fooMacro')}}
4041
let _: String = #fooMacro(3)

utils/build-windows-toolchain.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ cmake ^
214214

215215
-D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^
216216

217+
-D SWIFT_MODULE_ABI_NAME_PREFIX="Compiler" ^
218+
217219
-G Ninja ^
218220
-S %SourceRoot%\swift-syntax || (exit /b)
219221
cmake --build %BuildRoot%\99 || (exit /b)

utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def build(self, host_target):
6363
self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', self.args.install_prefix)
6464
self.cmake_options.define('SWIFTSYNTAX_ENABLE_ASSERTIONS:BOOL',
6565
self.args.assertions)
66+
self.cmake_options.define('SWIFT_MODULE_ABI_NAME_PREFIX:STRING', 'Compiler')
6667
self.build_with_cmake(["all"], self.args.swift_build_variant, [])
6768

6869
def should_test(self, host_target):

0 commit comments

Comments
 (0)