diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt index 19e3c4cbf..fcc3d68a2 100644 --- a/lib/Interpreter/CMakeLists.txt +++ b/lib/Interpreter/CMakeLists.txt @@ -36,6 +36,7 @@ target_link_libraries(clangCppInterOp PRIVATE ${cling_clang_interp} clangAST clangBasic + clangFrontend clangLex clangSema dl @@ -45,4 +46,3 @@ string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION) set_source_files_properties(CppInterOp.cpp PROPERTIES COMPILE_DEFINITIONS "LLVM_BINARY_DIR=\"${LLVM_BINARY_DIR}\";CPPINTEROP_VERSION=\"${_VAR}\"" ) - diff --git a/lib/Interpreter/DynamicLibraryManager.cpp b/lib/Interpreter/DynamicLibraryManager.cpp index 28ae99856..b5a65c0f8 100644 --- a/lib/Interpreter/DynamicLibraryManager.cpp +++ b/lib/Interpreter/DynamicLibraryManager.cpp @@ -286,8 +286,10 @@ namespace Cpp { if (llvm::sys::path::is_absolute(libStem)) { if (isSharedLibrary(libStem)) return normalizePath(libStem); - else - return std::string(); + + LLVM_DEBUG(dbgs() << "Dyld::lookupLibrary: '" << libStem.str() << "'" + << "is not a shared library\n"); + return std::string(); } // Subst all known linker variables ($origin, @rpath, etc.) diff --git a/unittests/CppInterOp/CMakeLists.txt b/unittests/CppInterOp/CMakeLists.txt index 08cd4ee9a..7ca5e5dfa 100644 --- a/unittests/CppInterOp/CMakeLists.txt +++ b/unittests/CppInterOp/CMakeLists.txt @@ -19,3 +19,15 @@ target_link_libraries(CppInterOpTests ) export_executable_symbols(CppInterOpTests) + +unset(LLVM_LINK_COMPONENTS) + +add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp) +target_link_libraries(DynamicLibraryManagerTests + PRIVATE + clangCppInterOp + ) + +add_dependencies(DynamicLibraryManagerTests TestSharedLib) +#export_executable_symbols_for_plugins(TestSharedLib) +add_subdirectory(TestSharedLib) diff --git a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp new file mode 100644 index 000000000..c7dea4c2f --- /dev/null +++ b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp @@ -0,0 +1,8 @@ +#include "gtest/gtest.h" + +#include "clang/Interpreter/CppInterOp.h" + +TEST(DynamicLibraryManagerTest, Sanity) { + EXPECT_TRUE(Cpp::CreateInterpreter()); + EXPECT_TRUE(Cpp::LoadLibrary("TestSharedLib")); +} diff --git a/unittests/CppInterOp/TestSharedLib/CMakeLists.txt b/unittests/CppInterOp/TestSharedLib/CMakeLists.txt new file mode 100644 index 000000000..0111ea0f3 --- /dev/null +++ b/unittests/CppInterOp/TestSharedLib/CMakeLists.txt @@ -0,0 +1,7 @@ +add_llvm_library(TestSharedLib SHARED BUILDTREE_ONLY TestSharedLib.cpp) +# Put TestSharedLib next to the unit test executable. +set_output_directory(TestSharedLib + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../ + LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../ + ) +set_target_properties(TestSharedLib PROPERTIES FOLDER "Tests") diff --git a/unittests/CppInterOp/TestSharedLib/TestSharedLib.cpp b/unittests/CppInterOp/TestSharedLib/TestSharedLib.cpp new file mode 100644 index 000000000..c0d7c474c --- /dev/null +++ b/unittests/CppInterOp/TestSharedLib/TestSharedLib.cpp @@ -0,0 +1,3 @@ +#include "TestSharedLib.h" + +int ret_zero() { return 0; } diff --git a/unittests/CppInterOp/TestSharedLib/TestSharedLib.h b/unittests/CppInterOp/TestSharedLib/TestSharedLib.h new file mode 100644 index 000000000..9577f66d6 --- /dev/null +++ b/unittests/CppInterOp/TestSharedLib/TestSharedLib.h @@ -0,0 +1,6 @@ +#ifndef UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB_H +#define UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB_H + +int ret_zero(); + +#endif // UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB_H