Re: Adding API functions for detecting interpreter language and standard#839
Conversation
| /** | ||
| * Enum to represent the programming language of the interpreter. | ||
| */ | ||
| typedef enum { |
There was a problem hiding this comment.
warning: enum 'CXInterpreterLanguage' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
typedef enum {
^| CXInterpreterLanguage_CUDA, | ||
| CXInterpreterLanguage_HIP, | ||
| CXInterpreterLanguage_HLSL | ||
| } CXInterpreterLanguage; |
There was a problem hiding this comment.
warning: use 'using' instead of 'typedef' [modernize-use-using]
| } CXInterpreterLanguage; | |
| using CXInterpreterLanguage = enum { | |
| CXInterpreterLanguage_Unknown, | |
| CXInterpreterLanguage_Asm, | |
| CXInterpreterLanguage_CIR, | |
| CXInterpreterLanguage_LLVM_IR, | |
| CXInterpreterLanguage_C, | |
| CXInterpreterLanguage_CPlusPlus, | |
| CXInterpreterLanguage_ObjC, | |
| CXInterpreterLanguage_ObjCPlusPlus, | |
| CXInterpreterLanguage_OpenCL, | |
| CXInterpreterLanguage_OpenCLCXX, | |
| CXInterpreterLanguage_CUDA, | |
| CXInterpreterLanguage_HIP, | |
| CXInterpreterLanguage_HLSL | |
| }; |
| /** | ||
| * Enum to represent the language standard of the interpreter. | ||
| */ | ||
| typedef enum { |
There was a problem hiding this comment.
warning: enum 'CXInterpreterLanguageStandard' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
typedef enum {
^| CXInterpreterLanguageStandard_hlsl202x, | ||
| CXInterpreterLanguageStandard_hlsl202y, | ||
| CXInterpreterLanguageStandard_lang_unspecified | ||
| } CXInterpreterLanguageStandard; |
There was a problem hiding this comment.
warning: use 'using' instead of 'typedef' [modernize-use-using]
| } CXInterpreterLanguageStandard; | |
| using CXInterpreterLanguageStandard = enum { | |
| CXInterpreterLanguageStandard_c89, | |
| CXInterpreterLanguageStandard_c94, | |
| CXInterpreterLanguageStandard_gnu89, | |
| CXInterpreterLanguageStandard_c99, | |
| CXInterpreterLanguageStandard_gnu99, | |
| CXInterpreterLanguageStandard_c11, | |
| CXInterpreterLanguageStandard_gnu11, | |
| CXInterpreterLanguageStandard_c17, | |
| CXInterpreterLanguageStandard_gnu17, | |
| CXInterpreterLanguageStandard_c23, | |
| CXInterpreterLanguageStandard_gnu23, | |
| CXInterpreterLanguageStandard_c2y, | |
| CXInterpreterLanguageStandard_gnu2y, | |
| CXInterpreterLanguageStandard_cxx98, | |
| CXInterpreterLanguageStandard_gnucxx98, | |
| CXInterpreterLanguageStandard_cxx11, | |
| CXInterpreterLanguageStandard_gnucxx11, | |
| CXInterpreterLanguageStandard_cxx14, | |
| CXInterpreterLanguageStandard_gnucxx14, | |
| CXInterpreterLanguageStandard_cxx17, | |
| CXInterpreterLanguageStandard_gnucxx17, | |
| CXInterpreterLanguageStandard_cxx20, | |
| CXInterpreterLanguageStandard_gnucxx20, | |
| CXInterpreterLanguageStandard_cxx23, | |
| CXInterpreterLanguageStandard_gnucxx23, | |
| CXInterpreterLanguageStandard_cxx26, | |
| CXInterpreterLanguageStandard_gnucxx26, | |
| CXInterpreterLanguageStandard_opencl10, | |
| CXInterpreterLanguageStandard_opencl11, | |
| CXInterpreterLanguageStandard_opencl12, | |
| CXInterpreterLanguageStandard_opencl20, | |
| CXInterpreterLanguageStandard_opencl30, | |
| CXInterpreterLanguageStandard_openclcpp10, | |
| CXInterpreterLanguageStandard_openclcpp2021, | |
| CXInterpreterLanguageStandard_hlsl, | |
| CXInterpreterLanguageStandard_hlsl2015, | |
| CXInterpreterLanguageStandard_hlsl2016, | |
| CXInterpreterLanguageStandard_hlsl2017, | |
| CXInterpreterLanguageStandard_hlsl2018, | |
| CXInterpreterLanguageStandard_hlsl2021, | |
| CXInterpreterLanguageStandard_hlsl202x, | |
| CXInterpreterLanguageStandard_hlsl202y, | |
| CXInterpreterLanguageStandard_lang_unspecified | |
| }; |
69221b4 to
4fb2f71
Compare
4fb2f71 to
6853b9c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #839 +/- ##
==========================================
+ Coverage 79.56% 79.75% +0.18%
==========================================
Files 11 11
Lines 4013 4035 +22
==========================================
+ Hits 3193 3218 +25
+ Misses 820 817 -3
... and 1 file with indirect coverage changes
🚀 New features to boost your workflow:
|
c39cc83 to
8c23c35
Compare
mcbarton
left a comment
There was a problem hiding this comment.
Can the tests we expanded to cover c23 and c++23? That way we cover all the standards we use for c/c++ kernels in xeus-cpp.
Sure, I will add one after this test session is completed |
|
@aaronj0, why do we have random cppyy tests failing? |
8c23c35 to
6073fba
Compare
76c5871 to
6991527
Compare
| Cpp::InterpreterLanguageStandard::gnucxx17); | ||
| } | ||
|
|
||
| TYPED_TEST(CPPINTEROP_TEST_MODE, Interpreter_ExternalInterpreter) { |
There was a problem hiding this comment.
warning: no header providing "llvm::ExitOnError" is directly included [misc-include-cleaner]
unittests/CppInterOp/InterpreterTest.cpp:2:
+ #include <llvm/Support/Error.h>
They have been fixed on main, rerunning should fix the jobs |
6991527 to
802d29a
Compare
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
LGTM!
Nice work. Thank you.
|
Congratulations on your first PR to CppInterOp. |
Thanks for guidance, I have learned a lot |
|
@keremsahn I am currently trying to update CppInterOp to llvm 22. I am now down to one failing test (Interpreter_GetLanguageStandardC). As you added this test, I was wondering if you knew why I get this error for llvm 22 https://github.com/compiler-research/CppInterOp/actions/runs/23491010379/job/68359063882?pr=812#step:13:889 . Here is the llvm 22 compatibility PR #812 |
I am checking |
Check the llvm/llvm-project#148701 EXTERN_C void *memcpy(void *restrict dst, const void *restrict src, __SIZE_TYPE__ n);
EXTERN_C inline void __clang_Interpreter_SetValueCopyArr(const void* Src, void* Placement, unsigned long Size) {
memcpy(Placement, Src, Size);
}This is injected into the code and since the tests do not include c89 which restrict and inline keywords are not available the PR was not failed. |
Thanks for the speedy reply. Do you have an idea for a patch which might fix the llvm 22 PR, either to CppInterOp or upstream in llvm? |
I think it is better to directly fix the original PR instead of a patch. We can use Clang extensions |
|
Not sure if I am replying too late. But we can just drop C89 test in CppInterOp. The inline function specifier was introduced in C99 (ref: https://en.cppreference.com/w/c/language/inline.html & https://en.cppreference.com/w/c/language/restrict.html). So let's just keep tests from C99. @keremsahn could you please open an issue in LLVM about this incompatible code injection for C89 at interpreter startup. Please ping Vassil and me. |
Tomorrow I will try the thing I suggested above, if it will not work it is just better to delete the C89 test as you said. And sure I will open the issue tonight or tomorrow. |
Sorry about the delay, I were not available. llvm/llvm-project#189088 here is the issue. I will tackle with it tomorrow if it still remains unsolved. |
The problem is solved but in the main branch, not in the release/22.x. Here is the PR llvm/llvm-project#189432 |
Two API functions; InterpreterLanguage GetLanguage(), InterpreterLanguageStandard GetLanguageStandard() and enums for interpreter language, standard added.
Fixes #744