Skip to content

Commit

Permalink
Merge pull request #28 from apple/egorzhdan/build-fixes-20230725
Browse files Browse the repository at this point in the history
🍒[build] Various fixes
  • Loading branch information
egorzhdan authored Sep 6, 2023
2 parents 46c67a9 + 4ed6293 commit 680142b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
endif()

set(min_supported_swift_version 5.8)
set(min_supported_swift_version 5.9)
if(CMAKE_Swift_COMPILER_VERSION VERSION_LESS "${min_supported_swift_version}")
message(FATAL_ERROR "Outdated Swift compiler: "
"Swift ${min_supported_swift_version} or newer is required.")
Expand Down
3 changes: 2 additions & 1 deletion Sources/LLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ add_library(LLVM_Utils
LLVM_Utils.swift)
target_compile_options(LLVM_Utils PUBLIC
"-emit-module"
"-Xfrontend" "-enable-experimental-cxx-interop")
"SHELL:-Xcc -std=c++17"
"-cxx-interoperability-mode=default")
target_include_directories(LLVM_Utils PUBLIC
"${LLVM_MAIN_INCLUDE_DIR}"
"${LLVM_INCLUDE_DIR}")
Expand Down
8 changes: 7 additions & 1 deletion Sources/LLVM/LLVM_Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

extension String {
public init(_ stringRef: llvm.StringRef) {
self.init(cxxString: stringRef.str())
self.init(stringRef.str())
}

public func withStringRef<Result>(_ body: (llvm.StringRef) -> Result) -> Result {
Expand All @@ -34,9 +34,15 @@ extension StaticString {
}

public func ==(lhs: llvm.StringRef, rhs: StaticString) -> Bool {
#if $NewCxxMethodSafetyHeuristics
let lhsBuffer = UnsafeBufferPointer<UInt8>(
start: lhs.bytes_begin(),
count: Int(lhs.bytes_end() - lhs.bytes_begin()))
#else
let lhsBuffer = UnsafeBufferPointer<UInt8>(
start: lhs.__bytes_beginUnsafe(),
count: Int(lhs.__bytes_endUnsafe() - lhs.__bytes_beginUnsafe()))
#endif
return rhs.withUTF8Buffer { (rhsBuffer: UnsafeBufferPointer<UInt8>) in
if lhsBuffer.count != rhsBuffer.count { return false }
return lhsBuffer.elementsEqual(rhsBuffer, by: ==)
Expand Down

0 comments on commit 680142b

Please sign in to comment.