-
Notifications
You must be signed in to change notification settings - Fork 34
Out-Of-Process Interpreter for CppInterOp #717
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
base: main
Are you sure you want to change the base?
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 16. Check the log or trigger a new build to see more.
|
||
inline std::unique_ptr<clang::Interpreter> | ||
createClangInterpreter(std::vector<const char*>& args) { | ||
createClangInterpreter(std::vector<const char*>& args, int stdin_fd = 0, |
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::vector" is directly included [misc-include-cleaner]
lib/CppInterOp/Compatibility.h:14:
+ #include <vector>
struct FileDeleter { | ||
void operator()(FILE* f /* owns */) { | ||
if (f) | ||
fclose(f); |
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: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]
fclose(f);
^
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 (llvm::sys::RunningOnValgrind()) | ||
GTEST_SKIP() << "XFAIL due to Valgrind report"; | ||
TestUtils::CreateInterpreter(); | ||
pid_t pid = Cpp::GetExecutorPID(); |
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 "pid_t" is directly included [misc-include-cleaner]
unittests/CppInterOp/FunctionReflectionTest.cpp:15:
- #include <string>
+ #include <sched.h>
+ #include <string>
} | ||
} | ||
|
||
TInterp_t |
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 "TInterp_t" is directly included [misc-include-cleaner]
unittests/CppInterOp/Utils.cpp:13:
- #include <string>
+ #include <clang-c/CXCppInterOp.h>
+ #include <string>
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
c56d565
to
7217df9
Compare
Before pushing commits to this PR please either ping me, or delete caches as they are made. This PR has caused a large number of llvm cached builds to be deleted on main, which in turn has required multiple PRs workflow runs to be stopped while the cache is rebuilt. |
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
} | ||
|
||
#ifndef _WIN32 | ||
pid_t getOutOfProcessExecutorPID() const { |
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 'getOutOfProcessExecutorPID' should be marked [[nodiscard]] [modernize-use-nodiscard]
pid_t getOutOfProcessExecutorPID() const { | |
[[nodiscard]] pid_t getOutOfProcessExecutorPID() const { |
} | ||
|
||
#ifndef _WIN32 | ||
pid_t getOutOfProcessExecutorPID() const { |
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 'getOutOfProcessExecutorPID' can be made static [readability-convert-member-functions-to-static]
pid_t getOutOfProcessExecutorPID() const { | |
static pid_t getOutOfProcessExecutorPID() { |
} | ||
|
||
#ifndef _WIN32 | ||
pid_t getOutOfProcessExecutorPID() const { |
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 "pid_t" is directly included [misc-include-cleaner]
lib/CppInterOp/CppInterOpInterpreter.h:25:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <sched.h>
+ #if CLANG_VERSION_MAJOR >= 19
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #717 +/- ##
==========================================
- Coverage 81.03% 80.98% -0.06%
==========================================
Files 9 9
Lines 4214 4308 +94
==========================================
+ Hits 3415 3489 +74
- Misses 799 819 +20
🚀 New features to boost your workflow:
|
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.
Please look at the comments.
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
} | ||
} | ||
|
||
TInterp_t |
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 "TInterp_t" is directly included [misc-include-cleaner]
unittests/CppInterOp/Utils.cpp:15:
- #include <string>
+ #include <clang-c/CXCppInterOp.h>
+ #include <string>
The tests are not covering over 1/4 of this patch. @kr-2003 can you improve the coverage? |
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.
Sorry for the late code review. Please address the comments.
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
operator const clang::Interpreter&() const { return *inner; } | ||
operator clang::Interpreter&() { return *inner; } | ||
|
||
bool isOutOfProcess() const { return outOfProcess; } |
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 'isOutOfProcess' should be marked [[nodiscard]] [modernize-use-nodiscard]
bool isOutOfProcess() const { return outOfProcess; } | |
[[nodiscard]] bool isOutOfProcess() const { return outOfProcess; } |
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
lib/CppInterOp/Compatibility.h
Outdated
std::string(LLVM_BUILD_LIB_DIR) + "/bin/llvm-jitlink-executor"; | ||
OutOfProcessConfig.UseSharedMemory = false; | ||
OutOfProcessConfig.SlabAllocateSize = 0; | ||
// LCOV_EXCL_START |
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.
LCOV_EXCL_START and LCOV_EXCL_STOP are things I think we should be using. If something is not being covered, we need to know. Then we can make an informed decision if its not something expected to be covered. Excluding sections from the report is a bad idea.
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.
can't test out this lambda. this block is run in the child process of oop interpreter. that's why ignored it during the coverage.
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.
I am removing the comments. I realised that it's not good practice to ignore the coverage.
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
// Use interpreter-managed redirection file for out-of-process stdout | ||
FILE* redirected = I.getRedirectionFileForOutOfProcess(FD); | ||
if (redirected) { | ||
m_TempFile.release(); // release ownership of current tmpfile |
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 value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value]
m_TempFile.release(); // release ownership of current tmpfile
^
m_OwnsFile = false; | ||
} | ||
} else { | ||
m_TempFile.reset(tmpfile()); |
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: initializing non-owner argument of type 'pointer' (aka '_IO_FILE *') with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]
m_TempFile.reset(tmpfile());
^
This PR enables Out-Of-Process Interpreter for CppInterOp.
Under the hood, it uses LLVM's
llvm-jitlink-executor
andlib ORC RT
to delegate the JIT execution to different process. The user just needs to pass--use-oop-jit
flag as ClangArgs while constructing the interpreter to use this feature.