apple / swift-llvm-bindings Goto Github PK
View Code? Open in Web Editor NEWSwift Bindings for LLVM Project APIs
License: Apache License 2.0
Swift Bindings for LLVM Project APIs
License: Apache License 2.0
Apologies if I'm asking on the wrong place, because it's maybe more of a C++ inter-op question.
I'm trying to use llvm::Function
through LLVM_Utils
and/or LLVM_IR
. Xcode's auto-completion shows this, which is confusing to me:
Then, when I try to build it, I get this error:
'Function' is not a member type of enum '__ObjC.llvm'
In the swift-llvm-bindings source is this line:
Both Twine
and Function
are classes declared in the llvm
namespace. The only difference is the LLVM_EXTERNAL_VISIBILITY
macro for Function
, but it expands to just [[gnu::visibility("default")]]
on macOS.
Why does llvm.Twine
work, but not llvm.Function
? What should I do to make llvm.Function
work?
It looks like the module map file is usually referenced as <llvm_root>/llvm/include/module.modulemap
and the line 17 in the Package.swift
doesn't seem to locate the module map correctly. That is, the llvmModuleMapPath
is resolved as <llvm_root>/llvm/include/llvm/module.modulemap
and doesn't match where the module map usually is.
guard let llvmHeaderPath = env["SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_HEADERS"] else {
print("please pass an environment variable to swift-package: " +
"SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_HEADERS " +
"(e.g. swift/llvm-project/llvm/include)")
return nil
}
let llvmModuleMapPath = "\(llvmHeaderPath)/llvm/module.modulemap". // line 17
I am quite new to LLVM and am very likely to be wrong. If without llvm
is intended, I can open a pr to fix it. :)
I'm able to build the project standalone using SwiftPM with no problems (or at least I think there is no problem). However, when I use it as a dependency, SwiftPM reports errors of missing modules.
When I build the depending package like this on the command line,
SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_HEADERS=/path/to/LLVM/headers SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_GENERATED_HEADERS=/path/to/LLVM/generated/headers swift build
it reports
error: missing required module 'LLVM_Utils'
at import SwiftLLVM_Utils
.
When I build the depending project in Xcode, it reports
No such module 'SwiftLLVM_Utils'
also at import SwiftLLVM_Utils
.
My toolchain is the 2024-02-15 trunk snapshot.
This is what my depending package's Package.swift
looks like:
// swift-tools-version: 5.9
import Foundation
import PackageDescription
var environment = ProcessInfo.processInfo.environment
var swiftLLVMBindings: Package.Dependency {
if environment["SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_HEADERS"] != nil && environment["SWIFT_LLVM_BINDINGS_PATH_TO_LLVM_GENERATED_HEADERS"] != nil {
return .package(url: "https://github.com/apple/swift-llvm-bindings.git", branch: "llvm.org/main")
} else {
return .package(path: "/local/copy/with/correct/includes")
}
}
let package = Package(
name: "depending-package",
products: [.library(name: "depending-package", targets: ["depending-package"]),],
dependencies: [swiftLLVMBindings],
targets: [
.target(
name: "depending-package",
dependencies: [.product(name: "SwiftLLVM_Utils", package: "swift-llvm-bindings"),],
swiftSettings: [.interoperabilityMode(.Cxx),]
),
.testTarget(
name: "depending-packageTests",
dependencies: ["depending-package"]
),
]
)
What should I do in order to use the project as a dependency?
Hi,
Just want to know if this project is still being maintained? I came from the LLVM Dev Mtg and this is really interesting.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.