Unverified Commit aa3815c5 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

set the EIGEN_MPL2_ONLY flag and add tests to make sure it is set for compile and codegen (#655)

parent 79c77fdd
......@@ -46,6 +46,9 @@ else()
message(WARNING "You are using an unsupported compiler. Compilation has only been tested with Clang (${CLANG_MIN_VERSION} and up), Apple Clang (${APPLE_CLANG_MIN_VERSION} and up), and GCC (${GCC_MIN_VERSION} and up).")
endif()
# Prevent Eigen from using any LGPL3 code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY")
if($ENV{NGRAPH_USE_PREBUILT_LLVM})
set(NGRAPH_USE_PREBUILT_LLVM TRUE)
endif()
......
......@@ -148,6 +148,9 @@ void codegen::StaticCompiler::initialize()
args.push_back("-mllvm");
args.push_back("-inline-threshold=1000000");
// Prevent Eigen from using any LGPL3 code
args.push_back("-DEIGEN_MPL2_ONLY");
// Prepare DiagnosticEngine
IntrusiveRefCntPtr<DiagnosticOptions> diag_options = new DiagnosticOptions();
diag_options->ErrorLimit = 20;
......
......@@ -26,6 +26,10 @@
#include "ngraph/ops/result.hpp"
#include "ngraph/placement.hpp"
#if not defined(EIGEN_MPL2_ONLY)
#error("The flag `EIGEN_MPL2_ONLY` must be defined");
#endif
using namespace std;
using namespace ngraph;
......
......@@ -26,6 +26,22 @@
using namespace std;
using namespace ngraph;
TEST(codegen, eigen_gpl_test)
{
// In order for this test to pass the in-memory compiler must define EIGEN_MPL2_ONLY
constexpr auto source = R"(
#if not defined(EIGEN_MPL2_ONLY)
#error("must define flag")
#endif
)";
codegen::Compiler compiler;
codegen::ExecutionEngine execution_engine;
auto module = compiler.compile(source);
ASSERT_NE(nullptr, module);
}
TEST(DISABLED_codegen, simple_return)
{
constexpr auto source = R"(extern "C" int test() { return 2+5; })";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment