diff --git a/README.md b/README.md index c29433a6..d369eafc 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ There are a couple annoying steps you need to accomplish before building LLVMSwift: - Install LLVM 8.0+ using your favorite package manager. For example: - - `brew install llvm` + - `brew install llvm@11` - Ensure `llvm-config` is in your `PATH` - That will reside in the `/bin` folder wherever your package manager installed LLVM. @@ -198,7 +198,7 @@ compiler projects! ### Installation with Swift Package Manager ```swift -.package(url: "https://github.com/llvm-swift/LLVMSwift.git", from: "0.4.0") +.package(url: "https://github.com/llvm-swift/LLVMSwift.git", from: "0.8.0") ``` ### Installation without Swift Package Manager diff --git a/Sources/LLVM/DIBuilder.swift b/Sources/LLVM/DIBuilder.swift index b61a35b9..de36b885 100644 --- a/Sources/LLVM/DIBuilder.swift +++ b/Sources/LLVM/DIBuilder.swift @@ -197,6 +197,8 @@ extension DIBuilder { /// by third-party tools. /// - splitDWARFPath: The path to the split DWARF file. /// - identity: The identity of the tool that is compiling this source file. + /// - sysRoot: The Clang system root (the value of the `-isysroot` that's passed to clang). + /// - sdkRoot: The SDK root -- on Darwin platforms, this is the last component of the sysroot. /// - Returns: A value representing a compilation-unit level scope. public func buildCompileUnit( for language: DWARFSourceLanguage, @@ -208,7 +210,9 @@ extension DIBuilder { flags: [String] = [], runtimeVersion: Int = 0, splitDWARFPath: String = "", - identity: String = "" + identity: String = "", + sysRoot: String = "", + sdkRoot: String = "" ) -> CompileUnitMetadata { let allFlags = flags.joined(separator: " ") guard let cu = LLVMDIBuilderCreateCompileUnit( @@ -220,7 +224,11 @@ extension DIBuilder { kind.llvm, /*DWOId*/0, splitDebugInlining.llvm, - debugInfoForProfiling.llvm + debugInfoForProfiling.llvm, + sysRoot, + sysRoot.count, + sdkRoot, + sdkRoot.count ) else { fatalError() } @@ -860,15 +868,22 @@ extension DIBuilder { /// - Parameters: /// - type: Original type. /// - name: Typedef name. + /// - alignment: Alignment of the type /// - scope: The surrounding context for the typedef. /// - file: File where this type is defined. /// - line: Line number. public func buildTypedef( - of type: DIType, name: String, scope: DIScope, file: FileMetadata, line: Int + of type: DIType, + name: String, + alignment: Alignment = .one, + scope: DIScope, + file: FileMetadata, + line: Int ) -> DIType { guard let ty = LLVMDIBuilderCreateTypedef( self.llvm, type.asMetadata(), name, name.count, - file.asMetadata(), UInt32(line), scope.asMetadata()) + file.asMetadata(), UInt32(line), scope.asMetadata(), + alignment.rawValue * 8) else { fatalError("Failed to allocate metadata") } diff --git a/Sources/LLVM/MetadataAttributes.swift b/Sources/LLVM/MetadataAttributes.swift index 2af8fc07..22e9b2d6 100644 --- a/Sources/LLVM/MetadataAttributes.swift +++ b/Sources/LLVM/MetadataAttributes.swift @@ -455,9 +455,6 @@ public struct DIFlags : OptionSet { public static let forwardDeclaration = DIFlags(rawValue: LLVMDIFlagFwdDecl.rawValue) /// Denotes a block object. public static let appleBlock = DIFlags(rawValue: LLVMDIFlagAppleBlock.rawValue) - /// Denotes the structure containing a variable captured by reference in a - /// block object. - public static let blockByrefStruct = DIFlags(rawValue: LLVMDIFlagBlockByrefStruct.rawValue) /// Denotes a virtual function or dynamic dispatch. public static let virtual = DIFlags(rawValue: LLVMDIFlagVirtual.rawValue) /// Denotes a compiler-generated declaration that may not appear in source. diff --git a/Sources/LLVM/TargetMachine.swift b/Sources/LLVM/TargetMachine.swift index 573e484b..6c6995c9 100644 --- a/Sources/LLVM/TargetMachine.swift +++ b/Sources/LLVM/TargetMachine.swift @@ -238,7 +238,7 @@ public class TargetMachine { } var err: UnsafeMutablePointer? let status = path.withCString { cStr -> LLVMBool in - var mutable = strdup(cStr) + let mutable = strdup(cStr) defer { free(mutable) } return LLVMTargetMachineEmitToFile(llvm, module.llvm, mutable, type.asLLVM(), &err) } diff --git a/utils/make-pkgconfig.swift b/utils/make-pkgconfig.swift index 9ed629f5..874b184d 100644 --- a/utils/make-pkgconfig.swift +++ b/utils/make-pkgconfig.swift @@ -63,7 +63,7 @@ func makeFile() throws { } /// Ensure we have llvm-config in the PATH - guard let llvmConfig = which("llvm-config-9") ?? which("llvm-config") ?? brewLLVMConfig() else { + guard let llvmConfig = which("llvm-config-11") ?? which("llvm-config") ?? brewLLVMConfig() else { throw "Failed to find llvm-config. Ensure llvm-config is installed and " + "in your PATH" } @@ -84,8 +84,8 @@ func makeFile() throws { let version = (components[0], components[1], components[2]) - guard version >= (9, 0, 0) else { - throw "LLVMSwift requires LLVM version >=9.0.0, but you have \(versionStr)" + guard version >= (11, 0, 0) else { + throw "LLVMSwift requires LLVM version >=11.0.0, but you have \(versionStr)" } print("LLVM version is \(versionStr)")