Skip to content

Commit 139981f

Browse files
committed
Support the package access modifier in CMake build
As far as I can tell, we weren’t passing `-package-name` if the host compiler does not support CMO at all. Since we require Swift 5.9 (indicated by the Package manifest), we can unconditionally set `-package-name`.
1 parent 65b02a9 commit 139981f

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ if(NOT DEFINED SWIFTSYNTAX_PACKAGE_NAME)
5757
set(SWIFTSYNTAX_PACKAGE_NAME "${SWIFT_MODULE_ABI_NAME_PREFIX}${PROJECT_NAME}")
5858
endif()
5959

60+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name ${SWIFTSYNTAX_PACKAGE_NAME}>")
61+
6062
# Determine the module triple.
6163
if("${SWIFT_HOST_MODULE_TRIPLE}" STREQUAL "")
6264
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)

Sources/SwiftSyntax/Trivia.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ extension RawTriviaPiece: CustomDebugStringConvertible {
216216
}
217217
}
218218

219-
@_spi(RawSyntax)
220-
public extension Trivia {
219+
package extension Trivia {
221220
func trimmingPrefix(
222221
while predicate: (TriviaPiece) -> Bool
223222
) -> Trivia {

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ function(add_swift_syntax_library name)
9191
if(Swift_COMPILER_PACKAGE_CMO_SUPPORT STREQUAL "IMPLEMENTED")
9292
target_compile_options("${target}" PRIVATE
9393
$<$<COMPILE_LANGUAGE:Swift>:
94-
"SHELL:-package-name ${SWIFTSYNTAX_PACKAGE_NAME}"
9594
"SHELL:-Xfrontend -package-cmo"
9695
"SHELL:-Xfrontend -allow-non-resilient-access"
9796
>)
9897
elseif(Swift_COMPILER_PACKAGE_CMO_SUPPORT STREQUAL "EXPERIMENTAL")
9998
target_compile_options("${target}" PRIVATE
10099
$<$<COMPILE_LANGUAGE:Swift>:
101-
"SHELL:-package-name ${SWIFTSYNTAX_PACKAGE_NAME}"
102100
"SHELL:-Xfrontend -experimental-package-cmo"
103101
"SHELL:-Xfrontend -experimental-allow-non-resilient-access"
104102
"SHELL:-Xfrontend -experimental-package-bypass-resilience"

0 commit comments

Comments
 (0)