Skip to content

Restore the Ability to Build with 5.6/5.5 #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.5

import PackageDescription
import Foundation
Expand Down Expand Up @@ -142,9 +142,11 @@ let package = Package(
]
)

// If `SWIFTCI_USE_LOCAL_DEPS` is set, we are in a CI enviornment that might disallow
#if swift(>=5.6)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we have this dependency. We do not need swift-docc-plugin to use docc, just the 5.5 package manifest or later. I would like to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we needed it to build/preview the documentation using the following command. But maybe I’m missing something.

swift package --disable-sandbox preview-documentation --target SwiftSyntax

CC @kimdv

// If `SWIFTCI_USE_LOCAL_DEPS` is set, we are in a CI enviornment that might disallow
// internet access, so we can't load swift-docc-plugin. Simply don't load it in these
// environments because we don't build docc in CI at the moment.
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"))
}
#endif
23 changes: 22 additions & 1 deletion Sources/SwiftSyntax/BumpPtrAllocator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class BumpPtrAllocator {
/// Check if the address is managed by this allocator.
public func contains(address: UnsafeRawPointer) -> Bool {
func test(_ slab: Slab) -> Bool {
slab.baseAddress! <= address && address < slab.baseAddress! + slab.count
UnsafeRawPointer(slab.baseAddress!) <= address && address < UnsafeRawPointer(slab.baseAddress!) + slab.count
}
return slabs.contains(where: test(_:)) || customSizeSlabs.contains(where: test(_:))
}
Expand All @@ -145,3 +145,24 @@ public class BumpPtrAllocator {
_totalBytesAllocated
}
}

// MARK: Compatibilty Shims

#if swift(<5.7)
extension UnsafeMutableRawPointer {
/// Obtain the next pointer whose bit pattern is a multiple of alignment.
///
/// - Parameter alignment: The alignment of the returned pointer, in bytes.
/// Alignment must be a whole power of 2.
/// - Returns: A pointer aligned to `alignment`.
fileprivate func alignedUp(toMultipleOf alignment: Int) -> Self {
let mask = UInt(alignment) &- 1
assert(
alignment > 0 && UInt(alignment) & mask == 0,
"alignment must be a whole power of 2."
)
let bits = (UInt(bitPattern: self) &+ mask) & ~mask
return .init(bitPattern: bits)!
}
}
#endif