hylo-lang/swifty-llvm
**Swifty-LLVM** is a Swifty interface for the [LLVM](https://llvm.org) compiler infrastructure, currently wrapping LLVM's C API.
Development/Use Requirements
Swift
This package requires Swift 6.2
LLVM
This package requires LLVM 20. Major versions of LLVM are not interchangeable or backward-compatible.
If you are using this package for development we strongly recommend the use of an LLVM with assertions enabled such as these; otherwise it's much too easy to violate LLVM's preconditions without knowing it. This package's devcontainer (in the .devcontainer subdirectory) has assert-enabled LLVM builds preinstalled in /opt/llvm-Debug and /opt/llvm-MinSizeRel.
Building with CMake and Ninja
- Configure: choose a build-directory and a CMake build type
(usually Debug or Release) and then, where <LLVM> is the path to the root directory of your LLVM installation,
`` cmake -D CMAKE_BUILD_TYPE=<build-type> \ -D LLVM_DIR=<LLVM>/lib/cmake/llvm \ -G Ninja -S . -B <build-directory> ``
(on Windows substitute your shell's line continuation character for \ or just remove the line breaks and backslashes).
If you want to run tests, add -DBUILD_TESTING=1.
Note: on macOS, if you are not using your Xcode's default toolchain, you may need -D CMAKE_Swift_COMPILER=swiftc to prevent CMake from using Xcode's default swift.
If this command fails it could be because you have an LLVM without CMake support installed; we suggest you try one of these packages instead.
- Build:
`` cmake --build <build-directory> ``
- Test (requires
-DBUILD_TESTING=1in step 1):
`` ctest --parallel --test-dir <build-directory> ``
Building with CMake and Xcode
- Generate Xcode project: choose a build-directory and then,
where <LLVM> is the path to the root directory of your LLVM installation,
`` cmake -D LLVM_DIR=<LLVM>/lib/cmake/llvm \ -G Xcode -S . -B <build-directory> ``
If you want to run tests, add -DBUILD_TESTING=1.
- Profit: open the
.xcodeprojfile in the build-directory and
use Xcode's UI to build and test.
Building with Swift Package Manager or Xcode
You can skip the following steps if you are using development containers.
- Install pkg-config.
- Ubuntu: sudo apt install pkg-config - Windows: choco install pkgconfiglite (Chocolatey) or install it manually - MacOS: sudo port install pkgconfig (Mac Ports)
- a) When not using Xcode: Add your LLVM installation's
pkgconfigsubfolder toPKG_CONFIG_PATHunless you are using Xcode.
b) When using Xcode: You will need to install llvm.pc in a directory that's already searched by Xcode, e.g. /usr/local/lib/pkgconfig/. The Hylo LLVM installation includes a script in <LLVM>/pkgconfig/install-pc.sh that helps with this: `` cd <LLVM>/pkgconfig ./install-pc.sh llvm.pc /usr/local/lib/pkgconfig/ ``
Now you should be able to build and test the project:
swift build -c release
swift test -c releaseNotes to macOS users:
- Add
platforms: [.macOS("xxx")]toPackage.swiftwherexxxis
your macOS version to address the warning complaining that an "object file was built for newer macOS version than being linked".
- You may need to add the path to
zstdlibrary inllvm.pc.
Package Metadata
Repository: hylo-lang/swifty-llvm
Default branch: main
README: README.md