-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library autoloader #308
base: main
Are you sure you want to change the base?
Library autoloader #308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 12. Check the log or trigger a new build to see more.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
+ Coverage 72.22% 74.30% +2.07%
==========================================
Files 8 8
Lines 2963 3043 +80
==========================================
+ Hits 2140 2261 +121
+ Misses 823 782 -41
... and 2 files with indirect coverage changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 14. Check the log or trigger a new build to see more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 18. Check the log or trigger a new build to see more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
A couple of quick thoughts for future upstreaming: we'd want to make this compatible with out-of-process execution, and it'd be great if we could re-use parts of it for MachO auto-linking. We should consider whether |
Thanks for the feedback, @lhames. That makes sense.
I was not aware such a thing existed. @SahilPatidar perhaps that's interesting in terms of your project, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
0686324
to
c1dd45f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
} | ||
|
||
void setEnabled(bool enabled) { | ||
Enabled = enabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'isEnabled' can be made const [readability-make-member-function-const]
Enabled = enabled; | |
bool isEnabled() const { |
lib/Interpreter/CppInterOp.cpp
Outdated
} | ||
|
||
void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> R) override { | ||
if (!sAutoSG || !sAutoSG->isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'getName' should be marked [[nodiscard]] [modernize-use-nodiscard]
if (!sAutoSG || !sAutoSG->isEnabled()) { | |
[[nodiscard]] StringRef getName() const override { |
c1dd45f
to
a04706e
Compare
@aaronj0, do you have a clue why cppyy fails? |
cppyy does not fail, InterOp does not build on any of the jobs. This comes back to the point that CppInterOp is only built on the jobs tagged with "cppyy" not the first stage that only builds llvm. On a preliminary look, it seems like on llvm19 we get:
and on 18 and 17, these "undefined reference to They also fail in some of the emscripten builds but I am more interested in the fact that they pass on llvm 17 and 18 with clang-repl on all platforms |
a04706e
to
876169a
Compare
af9fdf8
to
876169a
Compare
a7ebf63
to
307574f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 21. Check the log or trigger a new build to see more.
class AutoLoadLibrarySearchGenerator : public llvm::orc::DefinitionGenerator { | ||
bool Enabled = false; | ||
public: | ||
bool isEnabled() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'isEnabled' can be made const [readability-make-member-function-const]
bool isEnabled() { | |
bool isEnabled() const { |
AutoloadLibraryMU(std::string Library, const llvm::orc::SymbolNameVector &Symbols) | ||
: MaterializationUnit({getSymbolFlagsMap(Symbols), nullptr}), lib(std::move(Library)), syms(Symbols) {} | ||
|
||
StringRef getName() const override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'getName' should be marked [[nodiscard]] [modernize-use-nodiscard]
StringRef getName() const override { | |
[[nodiscard]] StringRef getName() const override { |
lib/Interpreter/CppInterOp.cpp
Outdated
} | ||
|
||
void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> R) override { | ||
if (!sAutoSG || !sAutoSG->isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
if (!sAutoSG || !sAutoSG->isEnabled()) {
^
lib/Interpreter/CppInterOp.cpp
Outdated
} | ||
|
||
void materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility> R) override { | ||
if (!sAutoSG || !sAutoSG->isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
if (!sAutoSG || !sAutoSG->isEnabled()) {
^
} | ||
|
||
if (!loadedSymbols.empty()) { | ||
llvm::cantFail(R->notifyResolved(loadedSymbols)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "llvm::cantFail" is directly included [misc-include-cleaner]
llvm::cantFail(R->notifyResolved(loadedSymbols));
^
auto& I = getInterp(); | ||
auto *DLM = I.getDynamicLibraryManager(); | ||
|
||
std::unordered_map<std::string, llvm::orc::SymbolNameVector> found; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::unordered_map" is directly included [misc-include-cleaner]
lib/Interpreter/CppInterOp.cpp:26:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <unordered_map>
+ #if CLANG_VERSION_MAJOR >= 19
} | ||
|
||
for (auto &&KV : found) { | ||
auto MU = std::make_unique<AutoloadLibraryMU>(KV.first, std::move(KV.second)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::make_unique" is directly included [misc-include-cleaner]
auto MU = std::make_unique<AutoloadLibraryMU>(KV.first, std::move(KV.second));
^
llvm::orc::JITDylib& DyLib = *EE.getProcessSymbolsJITDylib().get(); | ||
#endif // CLANG_VERSION_MAJOR | ||
|
||
if (!sAutoSG) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
if (!sAutoSG) {
^
#endif // CLANG_VERSION_MAJOR | ||
|
||
if (!sAutoSG) { | ||
sAutoSG = &DyLib.addGenerator(std::make_unique<AutoLoadLibrarySearchGenerator>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
sAutoSG = &DyLib.addGenerator(std::make_unique<AutoLoadLibrarySearchGenerator>());
^
if (!sAutoSG) { | ||
sAutoSG = &DyLib.addGenerator(std::make_unique<AutoLoadLibrarySearchGenerator>()); | ||
} | ||
sAutoSG->setEnabled(autoload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
sAutoSG->setEnabled(autoload);
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 11. Check the log or trigger a new build to see more.
|
||
bool GetLibrariesAutoload() { | ||
LLVM_DEBUG(dbgs() << "Autoload is " << (sAutoSG && sAutoSG->isEnabled() ? "ON" : "OFF")); | ||
return sAutoSG && sAutoSG->isEnabled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
return sAutoSG && sAutoSG->isEnabled();
^
|
||
bool GetLibrariesAutoload() { | ||
LLVM_DEBUG(dbgs() << "Autoload is " << (sAutoSG && sAutoSG->isEnabled() ? "ON" : "OFF")); | ||
return sAutoSG && sAutoSG->isEnabled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'sAutoSG' [clang-diagnostic-error]
return sAutoSG && sAutoSG->isEnabled();
^
@@ -2,55 +2,175 @@ | |||
|
|||
#include "clang/Interpreter/CppInterOp.h" | |||
|
|||
|
|||
#include "llvm/ExecutionEngine/Orc/Core.h" | |||
#include "llvm/ExecutionEngine/Orc/DebugUtils.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: included header Core.h is not used directly [misc-include-cleaner]
#include "llvm/ExecutionEngine/Orc/DebugUtils.h" | |
#include "llvm/ExecutionEngine/Orc/DebugUtils.h" |
@@ -2,55 +2,175 @@ | |||
|
|||
#include "clang/Interpreter/CppInterOp.h" | |||
|
|||
|
|||
#include "llvm/ExecutionEngine/Orc/Core.h" | |||
#include "llvm/ExecutionEngine/Orc/DebugUtils.h" | |||
#include "llvm/Support/FileSystem.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: included header DebugUtils.h is not used directly [misc-include-cleaner]
#include "llvm/Support/FileSystem.h" | |
#include "llvm/Support/FileSystem.h" |
|
||
// This function isn't referenced outside its translation unit, but it | ||
// can't use the "static" keyword because its address is used for | ||
// GetMainExecutable (since some platforms don't support taking the | ||
// address of main, and some platforms can't implement GetMainExecutable | ||
// without being given the address of a function in the main executable). | ||
std::string GetExecutablePath(const char* Argv0) { | ||
std::string GetExecutablePath(const char* Argv0, void* mainAddr = nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::string" is directly included [misc-include-cleaner]
unittests/CppInterOp/DynamicLibraryManagerTest.cpp:10:
+ #include <string>
// This just needs to be some symbol in the binary; C++ doesn't | ||
// allow taking the address of ::main however. | ||
void* MainAddr = (void*)intptr_t(GetExecutablePath); | ||
void* MainAddr = mainAddr ? mainAddr : (void*)intptr_t(GetExecutablePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
void* MainAddr = mainAddr ? mainAddr : (void*)intptr_t(GetExecutablePath);
^
// This just needs to be some symbol in the binary; C++ doesn't | ||
// allow taking the address of ::main however. | ||
void* MainAddr = (void*)intptr_t(GetExecutablePath); | ||
void* MainAddr = mainAddr ? mainAddr : (void*)intptr_t(GetExecutablePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
void* MainAddr = mainAddr ? mainAddr : (void*)intptr_t(GetExecutablePath);
^
// This just needs to be some symbol in the binary; C++ doesn't | ||
// allow taking the address of ::main however. | ||
void* MainAddr = (void*)intptr_t(GetExecutablePath); | ||
void* MainAddr = mainAddr ? mainAddr : (void*)intptr_t(GetExecutablePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "intptr_t" is directly included [misc-include-cleaner]
unittests/CppInterOp/DynamicLibraryManagerTest.cpp:10:
+ #include <cstdint>
return nameForDlsym; | ||
} | ||
|
||
#include "../../lib/Interpreter/CppInterOp.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: suspicious #include of file with '.cpp' extension [bugprone-suspicious-include]
#include "../../lib/Interpreter/CppInterOp.cpp"
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 12. Check the log or trigger a new build to see more.
// Last assigned Autoload SearchGenerator | ||
// TODO: Test fot thread safe. | ||
class AutoLoadLibrarySearchGenerator; | ||
static AutoLoadLibrarySearchGenerator *sAutoSG = null; | ||
// Flag to indicate ownership when an external interpreter instance is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'null' [clang-diagnostic-error]
static AutoLoadLibrarySearchGenerator *sAutoSG = null;
^
@@ -3435,4 +3440,188 @@ | |||
complete_column); | |||
} | |||
|
|||
#define DEBUG_TYPE "autoload" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
@@ -3435,4 +3440,188 @@ | |||
complete_column); | |||
} | |||
|
|||
#define DEBUG_TYPE "autoload" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::unique_ptr" is directly included [misc-include-cleaner]
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
#define DEBUG_TYPE "autoload" | ||
|
||
static inline std::string DemangleNameForDlsym(const std::string& name) { | ||
std::string nameForDlsym = name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "SEEK_SET" is directly included [misc-include-cleaner]
if (fseek(m_TempFile.get(), 0L, SEEK_SET) != 0)
^
static bool is_demangle_active = false; | ||
static bool demangle = false; | ||
if (!is_demangle_active) { | ||
auto& I = getInterp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fread" is directly included [misc-include-cleaner]
fread(content.get(), sizeof(char), bufsize, m_TempFile.get());
^
static bool demangle = false; | ||
if (!is_demangle_active) { | ||
auto& I = getInterp(); | ||
llvm::orc::LLJIT& EE = *compat::getExecutionEngine(I); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "ferror" is directly included [misc-include-cleaner]
if (ferror(m_TempFile.get()) != 0)
^
if (!is_demangle_active) { | ||
auto& I = getInterp(); | ||
llvm::orc::LLJIT& EE = *compat::getExecutionEngine(I); | ||
auto t = EE.getTargetTriple(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fputs" is directly included [misc-include-cleaner]
fputs("Error reading file", stderr);
^
if (!addr && !loadedLibrary) { | ||
// Try to load the library which should provide the symbol definition. | ||
if (DLM->loadLibrary(lib, false) != DynamicLibraryManager::LoadLibResult::kLoadLibSuccess) { | ||
LLVM_DEBUG(dbgs() << "MU: Failed to load library " << lib); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'isEnabled' can be made const [readability-make-member-function-const]
LLVM_DEBUG(dbgs() << "MU: Failed to load library " << lib); | |
bool isEnabled() const { |
if (addr) { | ||
loadedSymbols[symbol] = | ||
llvm::orc::ExecutorSymbolDef(llvm::orc::ExecutorAddr::fromPtr(addr), JITSymbolFlags::Exported); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'getName' should be marked [[nodiscard]] [modernize-use-nodiscard]
} else { | |
[[nodiscard]] StringRef getName() const override { |
//I.getAddressOfGlobal(*Name); | ||
} | ||
|
||
for (auto &&KV : found) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "llvm::cantFail" is directly included [misc-include-cleaner]
llvm::cantFail(R->notifyResolved(loadedSymbols));
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
static bool is_demangle_active = false; | ||
static bool demangle = false; | ||
if (!is_demangle_active) { | ||
auto& I = getInterp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]
fread(content.get(), sizeof(char), bufsize, m_TempFile.get());
^
Additional context
lib/Interpreter/CppInterOp.cpp:3475: Calling 'StreamCaptureInfo::GetCapturedString'
std::string result = SCI.GetCapturedString();
^
lib/Interpreter/CppInterOp.cpp:3430: Assuming the condition is false
if (dup2(m_DupFD, m_FD) < 0)
^
lib/Interpreter/CppInterOp.cpp:3430: Taking false branch
if (dup2(m_DupFD, m_FD) < 0)
^
lib/Interpreter/CppInterOp.cpp:3433: Assuming the condition is false
if (fseek(m_TempFile.get(), 0L, SEEK_END) != 0)
^
lib/Interpreter/CppInterOp.cpp:3433: Taking false branch
if (fseek(m_TempFile.get(), 0L, SEEK_END) != 0)
^
lib/Interpreter/CppInterOp.cpp:3437: 'bufsize' initialized here
long bufsize = ftell(m_TempFile.get());
^
lib/Interpreter/CppInterOp.cpp:3438: Assuming the condition is true
if (bufsize == -1)
^
lib/Interpreter/CppInterOp.cpp:3438: Taking true branch
if (bufsize == -1)
^
lib/Interpreter/CppInterOp.cpp:3442: Storing uninitialized value
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
lib/Interpreter/CppInterOp.cpp:3442: Passing value via 1st parameter '__p'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
lib/Interpreter/CppInterOp.cpp:3442: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^
/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'
: _M_t(__p)
^
/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^
/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^
/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^
/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^
/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^
/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^
/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^
/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^
/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^
/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^
/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^
/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^
/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^
/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^
lib/Interpreter/CppInterOp.cpp:3442: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^
lib/Interpreter/CppInterOp.cpp:3445: Assuming the condition is false
if (fseek(m_TempFile.get(), 0L, SEEK_SET) != 0)
^
lib/Interpreter/CppInterOp.cpp:3445: Taking false branch
if (fseek(m_TempFile.get(), 0L, SEEK_SET) != 0)
^
lib/Interpreter/CppInterOp.cpp:3450: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)
fread(content.get(), sizeof(char), bufsize, m_TempFile.get());
^
} | ||
sAutoSG->setEnabled(autoload); | ||
|
||
LLVM_DEBUG(dbgs() << "Autoload=" << (sAutoSG->isEnabled() ? "ON" : "OFF")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::unordered_map" is directly included [misc-include-cleaner]
lib/Interpreter/CppInterOp.cpp:26:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <unordered_map>
+ #if CLANG_VERSION_MAJOR >= 19
@@ -0,0 +1,13 @@ | |||
#ifndef UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB2_H | |||
#define UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB2_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: header guard does not follow preferred style [llvm-header-guard]
#define UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB2_H | |
#ifndef GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTSHAREDLIB2_TESTSHAREDLIB2_H | |
#define GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTSHAREDLIB2_TESTSHAREDLIB2_H |
unittests/CppInterOp/TestSharedLib2/TestSharedLib2.h:12:
- #endif // UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB2_H
+ #endif // GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTSHAREDLIB2_TESTSHAREDLIB2_H
7383818
to
95e531f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
// Last assigned Autoload SearchGenerator | ||
// TODO: Test fot thread safe. | ||
class AutoLoadLibrarySearchGenerator; | ||
static AutoLoadLibrarySearchGenerator *sAutoSG = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'sAutoSG' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
static AutoLoadLibrarySearchGenerator *sAutoSG = nullptr;
^
// Last assigned Autoload SearchGenerator | ||
// TODO: Test fot thread safe. | ||
class AutoLoadLibrarySearchGenerator; | ||
static AutoLoadLibrarySearchGenerator *sAutoSG = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'sAutoSG' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
static AutoLoadLibrarySearchGenerator *sAutoSG = nullptr;
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
if (!loadedSymbols.empty()) { | ||
llvm::cantFail(R->notifyResolved(loadedSymbols)); | ||
|
||
llvm::orc::SymbolDependenceGroup DepGroup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no type named 'SymbolDependenceGroup' in namespace 'llvm::orc'; did you mean 'SymbolDependenceMap'? [clang-diagnostic-error]
llvm::orc::SymbolDependenceGroup DepGroup; | |
llvm::orc::SymbolDependenceMap DepGroup; |
Additional context
llvm/include/llvm/ExecutionEngine/Orc/Core.h:125: 'SymbolDependenceMap' declared here
using SymbolDependenceMap = DenseMap<JITDylib *, SymbolNameSet>;
^
llvm::cantFail(R->notifyResolved(loadedSymbols)); | ||
|
||
llvm::orc::SymbolDependenceGroup DepGroup; | ||
llvm::cantFail(R->notifyEmitted({DepGroup})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: too many arguments to function call, expected 0, have 1 [clang-diagnostic-error]
llvm::cantFail(R->notifyEmitted({DepGroup}));
^
Additional context
llvm/include/llvm/ExecutionEngine/Orc/Core.h:1932: 'notifyEmitted' declared here
inline Error MaterializationResponsibility::notifyEmitted() {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
#include "llvm/Support/Casting.h" | ||
#include "llvm/Support/Error.h" | ||
#include "llvm/Support/Debug.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: #includes are not sorted properly [llvm-include-order]
#include "llvm/Support/Debug.h" | |
#include "llvm/Support/Debug.h" | |
#include "llvm/Support/Error.h" |
Hey @alexander-penev What is the progress on this ? I haven't had the time to looking into the library loading feature yet but we would need this for xeus-cpp-lite and xeus-cpp I suppose. My understanding was that this would supersede the Loading shared objects feature we could achieve with cling's pragma. |
Co-authored-by: Vassil Vassilev <[email protected]>
06effa9
to
6ef47d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
llvm::orc::SymbolNameVector fSymbols; | ||
public: | ||
AutoloadLibraryMU(const std::string &Library, const llvm::orc::SymbolNameVector &Symbols) | ||
: MaterializationUnit({getSymbolFlagsMap(Symbols), nullptr}), fLibrary(Library), fSymbols(Symbols) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: pass by value and use std::move [modernize-pass-by-value]
: MaterializationUnit({getSymbolFlagsMap(Symbols), nullptr}), fLibrary(Library), fSymbols(Symbols) {} | |
AutoloadLibraryMU(std::string Library, const llvm::orc::SymbolNameVector &Symbols) | |
: MaterializationUnit({getSymbolFlagsMap(Symbols), nullptr}), fLibrary(std::move(Library)), fSymbols(Symbols) {} |
No description provided.