Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install capnp
run: |
curl -O https://capnproto.org/capnproto-c++-1.3.0.tar.gz
tar zxf capnproto-c++-1.3.0.tar.gz
cd capnproto-c++-1.3.0
./configure
make -j6 check
sudo make install
- name: Set up Clang ${{ env.CLANG_VERSION }}
env:
TEMP_DIR: ${{ runner.temp }}
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install capnp
run: |
curl -O https://capnproto.org/capnproto-c++-1.3.0.tar.gz
tar zxf capnproto-c++-1.3.0.tar.gz
cd capnproto-c++-1.3.0
./configure
make -j6 check
sudo make install
- name: Set up MLIR
uses: munich-quantum-software/setup-mlir@97da765dfa9dc8e055611ca934fe51bcade8140c # v1.3.0
with:
Expand Down
19 changes: 18 additions & 1 deletion cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(FetchContent)

set(FETCH_PACKAGES "")

if(BUILD_JEFF_MLIR_TRANSLATION)
Expand All @@ -9,7 +10,23 @@ if(BUILD_JEFF_MLIR_TRANSLATION)
)
list(APPEND FETCH_PACKAGES jeff)

find_package(CapnProto REQUIRED)
if(WIN32)
set(WITH_FIBERS
OFF
CACHE
BOOL
"Disable fiber support on Windows to avoid a build error due to disabled exceptions"
FORCE
)
endif()
FetchContent_Declare(
capnproto
GIT_REPOSITORY https://github.com/capnproto/capnproto.git
GIT_TAG v1.3.0
PATCH_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> patch --forward -p1 -i
${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/capnproto-disable-tests.patch
)
list(APPEND FETCH_PACKAGES capnproto)
Comment thread
burgholzer marked this conversation as resolved.
endif()

if(BUILD_JEFF_MLIR_TESTS)
Expand Down
11 changes: 11 additions & 0 deletions cmake/patches/capnproto-disable-tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -1,5 +1,8 @@

+# Disable vendored Cap'n Proto tests when consumed through FetchContent.
+set(BUILD_TESTING OFF)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's just a matter of the flag, can we not set it from our side?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not. The project itself calls include(CTest), which unconditionally sets that variable again and overrides anything that we set here.
I have probably tried 5 different ways to exclude the tests; this is the one that worked reliably.

Mid- to long-term, one could contribute an upstream fix for this that scopes the testing to the project.
The sensible default is typically to enable the tests by default if running as the top-level CMake project (using PROJECT_IS_TOP_LEVEL) and to provide an additional project-specific option in CMake that defaults to OFF for downstream consumers.
I currently do not have the capacity to drive that through, but maybe @denialhaag has once he is back from vacation.

+
# Tests ========================================================================

if(BUILD_TESTING)
14 changes: 12 additions & 2 deletions include/jeff/Translation/Deserialize.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#pragma once

#include <llvm/ADT/StringRef.h>
#include <capnp/common.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/MLIRContext.h>
#include <mlir/IR/OwningOpRef.h>

/**
* @brief Deserialize a memory buffer containing a serialized .jeff module into an MLIR module.
* @param context The MLIR context to use for the deserialization.
* @param buffer A memory buffer containing the serialized jeff module.
* @return An owning reference to the deserialized MLIR module.
*/
mlir::OwningOpRef<mlir::ModuleOp> deserialize(mlir::MLIRContext* context,
kj::ArrayPtr<capnp::word> buffer);

/**
* @brief Deserialize a .jeff file into an MLIR module.
* @param context The MLIR context to use for the deserialization.
* @param path The path to the .jeff file.
* @return An owning reference to the deserialized MLIR module.
*/
mlir::OwningOpRef<mlir::ModuleOp> deserialize(mlir::MLIRContext* context, llvm::StringRef path);
mlir::OwningOpRef<mlir::ModuleOp> deserializeFromFile(mlir::MLIRContext* context,
llvm::StringRef path);
19 changes: 16 additions & 3 deletions include/jeff/Translation/Serialize.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#pragma once

#include <llvm/ADT/StringRef.h>
#include <capnp/common.h>
#include <kj/array.h>
#include <mlir/IR/BuiltinOps.h>

/**
* @brief Serialize an MLIR module into a .jeff file.
* @brief Serialize an MLIR module containing a jeff program into a memory buffer.
* @param module The MLIR module to serialize.
* @return An owned memory buffer containing the serialized jeff module.
*
* @details
* Known limitations:
*
* - Only one-dimensional tensors with dynamic size are supported.
*/
kj::Array<capnp::word> serialize(mlir::ModuleOp module);

/**
* @brief Serialize an MLIR module containing a jeff program into a .jeff file.
* @param module The MLIR module to serialize.
* @param path The path to the .jeff file.
*
Expand All @@ -13,4 +26,4 @@
*
* - Only one-dimensional tensors with dynamic size are supported.
*/
void serialize(mlir::ModuleOp module, llvm::StringRef path);
void serializeToFile(mlir::ModuleOp module, llvm::StringRef path);
9 changes: 4 additions & 5 deletions lib/Translation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ add_mlir_library(
Deserialize.cpp
Serialize.cpp
LINK_LIBS
PRIVATE
MLIRJeff
MLIRFuncDialect
PUBLIC
CapnProto::capnp
DISABLE_INSTALL
)

target_compile_definitions(MLIRJeffTranslation PRIVATE ${CAPNP_DEFINITIONS})

target_include_directories(
MLIRJeffTranslation
PRIVATE ${CAPNP_INCLUDE_DIRS}
PUBLIC ${jeff_SOURCE_DIR}/impl/cpp/src/capnp ${jeff_BINARY_DIR}/impl/cpp/src/capnp
MLIRJeffTranslation PUBLIC ${jeff_SOURCE_DIR}/impl/cpp/src/capnp
${jeff_BINARY_DIR}/impl/cpp/src/capnp
)

target_sources(MLIRJeffTranslation PUBLIC ${jeff_SOURCE_DIR}/impl/cpp/src/capnp/jeff.capnp.c++)
Loading
Loading