From 337a9bb5c2266bdcc1fa5136fd65def153ef12dd Mon Sep 17 00:00:00 2001 From: Antoniu Pop Date: Mon, 14 Mar 2022 13:49:50 +0000 Subject: [PATCH] fix(dfr): add runtime termination call on compiler main exit. --- compiler/lib/Runtime/CMakeLists.txt | 1 + compiler/lib/Runtime/DFRuntime.cpp | 1 - compiler/lib/Runtime/dfr_terminate.cpp | 11 +++++++++++ compiler/src/main.cpp | 7 +++++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 compiler/lib/Runtime/dfr_terminate.cpp diff --git a/compiler/lib/Runtime/CMakeLists.txt b/compiler/lib/Runtime/CMakeLists.txt index fcd5c4b78..8c95b67e7 100644 --- a/compiler/lib/Runtime/CMakeLists.txt +++ b/compiler/lib/Runtime/CMakeLists.txt @@ -1,6 +1,7 @@ add_library(ConcretelangRuntime SHARED context.cpp wrappers.cpp + dfr_terminate.cpp ) if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED) diff --git a/compiler/lib/Runtime/DFRuntime.cpp b/compiler/lib/Runtime/DFRuntime.cpp index dfe61b38c..607c77816 100644 --- a/compiler/lib/Runtime/DFRuntime.cpp +++ b/compiler/lib/Runtime/DFRuntime.cpp @@ -344,7 +344,6 @@ int __wrap_main(int argc, char *argv[]) { } } - /**********************/ /* Debug interface. */ /**********************/ diff --git a/compiler/lib/Runtime/dfr_terminate.cpp b/compiler/lib/Runtime/dfr_terminate.cpp new file mode 100644 index 000000000..9ecf182db --- /dev/null +++ b/compiler/lib/Runtime/dfr_terminate.cpp @@ -0,0 +1,11 @@ +// Part of the Concrete Compiler Project, under the BSD3 License with Zama +// Exceptions. See +// https://github.com/zama-ai/concrete-compiler-internal/blob/master/LICENSE.txt +// for license information. + +#ifndef CONCRETELANG_PARALLEL_EXECUTION_ENABLED + +#include +void _dfr_terminate() {} + +#endif diff --git a/compiler/src/main.cpp b/compiler/src/main.cpp index 160898258..301fd038b 100644 --- a/compiler/src/main.cpp +++ b/compiler/src/main.cpp @@ -29,6 +29,7 @@ #include "concretelang/Dialect/RT/IR/RTDialect.h" #include "concretelang/Dialect/TFHE/IR/TFHEDialect.h" #include "concretelang/Dialect/TFHE/IR/TFHETypes.h" +#include "concretelang/Runtime/runtime_api.h" #include "concretelang/Support/Error.h" #include "concretelang/Support/JitCompilerEngine.h" #include "concretelang/Support/LLVMEmitFile.h" @@ -480,8 +481,10 @@ mlir::LogicalResult compilerMain(int argc, char **argv) { } int main(int argc, char **argv) { + int result = 0; if (mlir::failed(compilerMain(argc, argv))) - return 1; + result = 1; - return 0; + _dfr_terminate(); + return result; }