[PATCH] D128862: [MLIR] Add rudimentary Swift bindings test case

George via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 15:39:45 PDT 2022


GeorgeLyon created this revision.
GeorgeLyon added reviewers: lattner, compnerd, ftynse, rriddle.
GeorgeLyon added a project: MLIR.
Herald added subscribers: bzcheeseman, sdasgup3, wenzhicui, wrengr, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, mehdi_amini, mgorny.
Herald added a project: All.
GeorgeLyon requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added a project: LLVM.

This commit adds a rudimentary Swift bindings test to MLIR. The basic model for Swift bindings is very similar to Python, in that they are both hidden behind a CMake flag (in Swift's case, MLIR_ENABLE_BINDINGS_SWIFT), and do not affect the build otherwise.

As a compiled, C-style language, Swift can be more deeply integrated into the build system than Python. Specifically, we can actually create Swift targets in CMake that are more-or-less indistinguishable from C and C++ targets (via add_llvm_executable and friends). This will eventually allow us to develop libraries in Swift that do not require a working Swift compiler to be run (assuming we statically link Swift's standard library).
One downside to adding Swift in this way, is that a few places in LLVM's build system add compile definitions and flags which are not compatible with Swift globally to any LLVM target. I have fixed the few such places where this affected Swift bindings for MLIR by using CMake's COMPILE_LANGUAGE generator feature, which allows us to specify directly that certain options or flags are only relevant to C and C++ sources.

Notably, this commit does not add the bindings themselves, just the initial test case demonstrating compiling a Swift target which depends on an MLIR library. My hope is that I can address feedback about how I am integrating with the build system independently of the bindings themselves, and upon merging this to main perhaps add this path to CI so new flags are not added in a way that is incompatible with Swift.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128862

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/HandleLLVMOptions.cmake
  mlir/CMakeLists.txt
  mlir/test/CMakeLists.txt
  mlir/test/lit.cfg.py
  mlir/test/lit.site.cfg.py.in
  mlir/test/swift/CMakeLists.txt
  mlir/test/swift/ir.swift
  mlir/test/swift/lit.local.cfg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128862.441188.patch
Type: text/x-patch
Size: 7193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/41be1876/attachment.bin>


More information about the llvm-commits mailing list