Skip to content
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

Support for clang-16 in cppyy #25

Open
lukevalenty opened this issue Sep 26, 2024 · 15 comments
Open

Support for clang-16 in cppyy #25

lukevalenty opened this issue Sep 26, 2024 · 15 comments

Comments

@lukevalenty
Copy link

lukevalenty commented Sep 26, 2024

I was super excited to try out cppyy to enable some property based testing for several open source libraries we have at Intel that are highly dependent on template types and compile-time processing. However, our libraries need at least clang 16. I saw that cling has support for this now, when will cppyy be updated with the latest version of cling with clang 16 support?

@lukevalenty
Copy link
Author

Tagging @elbeno and @mjcaisse who will also be interested in this.

@wlav
Copy link
Owner

wlav commented Sep 26, 2024

I have a big incentive to get that done soon as modern compilers on all 3 major platforms are now failing with LLVM-13 (mainly b/c C++20 is the chosen default, which now brings in code in standard headers using features that makes 13 choke). I started the work, but then upstream is also close to moving to LLVM-18, so waiting for that instead would save me some time, which is in short supply still.

Upstream (https://github.com/compiler-research) also has a fork of cppyy that, once completed, would make future updates to newer versions of LLVM much easier. (Time spent on that is one reason why I haven't kept up here.)

@lukevalenty
Copy link
Author

That's great to hear @wlav! Do you have an idea of the time-frame for clang-16 or 18 backend? I'm trying to decide if its worthwhile to spend time on an alternative method or just wait a little bit longer. Any way contributors can help out?

@wlav
Copy link
Owner

wlav commented Sep 26, 2024

Always consider alternatives. :) cppyy fills a rather unique niche: it either fits or it doesn't.

As for contributions, do you have access to / care about MS Windows? It's always a major holdup for preparing a release (I run it in a VM on Linux, but MS time limits on the images they provide so I have to redo everything for each new release and our IT security folks don't particularly like it), so if you could test LLVM16 there, that would be very helpful.

I've put in the repo what I tested on Linux. Haven't run the CI yet to check Windows, nor updated the version numbers, which makes building from source a bit more complicated. But as-is, it still has six failing tests (on Linux, see below), so I want to get that fixed first before moving on to Mac (and finally Windows).

FAILED test_cpp11features.py::TestCPP11FEATURES::test09_lambda_calls - TypeError: 'cppyy.LowLevelView' object is not callable
FAILED test_datatypes.py::TestDATATYPES::test46_small_int_enums - AssertionError: assert (SmallEnums::Int8Enum::E0) : (char) '\x00' == 0
FAILED test_datatypes.py::TestDATATYPES::test47_hidden_name_enum - NotImplementedError: unsigned int EnumFunctionSameName::bar(EnumFunctionSameName::foo f) =>
FAILED test_fragile.py::TestFRAGILE::test21_failing_cppcode - assert 'expectedunqualified-id' in "FailedtoparsethegivenC++code\x1b[1minput_line_2473:1:2:\x1b[0m\x1b[0;1;31merror:\x1b[0m\x1b[1minvaliddigit'a'indecimalconstant\x1b[0m1aap...
FAILED test_pythonify.py::TestPYTHONIFY::test19_keywords_and_defaults - NameError: name 'MyClass' is not defined
FAILED test_stltypes.py::TestSTLDEQUE::test01_deque_byvalue_regression - TypeError: void f(const unsigned char* buf) =>

Alternatively, given that the above errors are all corner cases, building it from source and putting it through the wringer on Linux is helpful, too. Might catch some more, LLVM16 specific, errors before releasing it.

@lukevalenty
Copy link
Author

lukevalenty commented Sep 26, 2024

@wlav, I have a Windows laptop I can test out LLVM16 on. Point me in the right direction (repo/branch and build/test instructions) and I'll give it a go.

ETA: Just saw your commit, going to take a look now.

@lukevalenty
Copy link
Author

Actually, I need some help knowing how to build locally for linux, mac, and windows. I have all three. I tried using the circleci recipe but that might not work well for working through errors and rebuilding/testing.

@wlav
Copy link
Owner

wlav commented Sep 27, 2024

The CI scripts were contributed; I never got the circleci one to work. The reason for its existence was that github emulates ARM, which is slow, and the jobs run out of time. A Linux ARM wheel has been requested frequently, though, so would have been useful. The CI on github also has other limitations: the Linux one uses the old ABI and the Mac one cross compiles for ARM. The latter can't work b/c the build process creates a few executables that are then to be used in the build. That fails when cross compiling. Intel Mac and Windows on github CI was functional, IIRC. I have CI disabled until I get closer to a release; builds take to long to bother with every little commit.

Details on building from source are here:
https://cppyy.readthedocs.io/en/latest/repositories.html#building-from-source

An important one is --no-use-pep517 as pip's dependency resolution is different for the build environment than for the runtime environment (always has been, but PEP517 makes it worse). All recent backends are strictly ABI compatible, though, so shouldn't be an issue when building the latest. For development on a local machine, I use cmake to build.

@lukevalenty
Copy link
Author

Ok, I'll need to follow these instructions and let you know how it goes. What's the latest commit in which you expect all the unit tests to pass in x86_64 linux? I'm using ubuntu 22.04, do you see any problems with that? Any specific compiler and python versions I should be using?

@wlav
Copy link
Owner

wlav commented Sep 27, 2024

Just prior to putting in the LLVM16 patches should work for all tests on Linux except 1 (test01_deque_byvalue_regression). That one fails b/c of a naming conflict between 2 tests (ie., it will work when run independently).

Last fully functional commit is c84cc07

Note that there are a handful of tests that fail on Windows (have been for a long time); several esoteric, such as the use of std::tuple. (MSVC implements that through inheritance such that std::tuple<int, int> inherits from std::tuple<int>, with as a consequence that get() on the former is matched by get() on the base, if called earlier.)

I'm down to 4 failing tests on Linux.

@lukevalenty
Copy link
Author

lukevalenty commented Sep 29, 2024

I'm getting a lot of failed tests on linux. I followed the instructions to build from source using cmake using gcc 13.1, python 3.10, and ubuntu 22.04. I'm not sure why I'm getting so many more failing tests than you. Let me know if there is a known stable combination of dependencies or a docker image I should use.

FAILED test_advancedcpp.py::TestADVANCEDCPP::test16_template_global_functions
FAILED test_advancedcpp.py::TestADVANCEDCPP::test26_using_directive
FAILED test_api.py::TestAPI::test06_custom_executor
FAILED test_concurrent.py::TestCONCURRENT::test04_cpp_threading_with_exceptions
FAILED test_concurrent.py::TestCONCURRENT::test05_float2d_callback
FAILED test_cpp11features.py::TestCPP11FEATURES::test09_lambda_calls
FAILED test_cpp11features.py::TestCPP11FEATURES::test10_optional
FAILED test_cpp11features.py::TestCPP11FEATURES::test11_chrono
FAILED test_crossinheritance.py::TestCROSSINHERITANCE::test07_templated_base
FAILED test_datatypes.py::TestDATATYPES::test40_more_aggregates
FAILED test_datatypes.py::TestDATATYPES::test46_small_int_enums
FAILED test_datatypes.py::TestDATATYPES::test47_hidden_name_enum
FAILED test_doc_features.py::TestTUTORIALFEATURES::test06_add_operator
FAILED test_doc_features.py::TestTUTORIALFEATURES::test09_templated_function
FAILED test_doc_features.py::TestTALKEXAMPLES::test_unicode
FAILED test_fragile.py::TestFRAGILE::test16_opaque_handle
FAILED test_fragile.py::TestSTDNOTINGLOBAL::test01_stl_in_std
FAILED test_operators.py::TestOPERATORS::test09_templated_operator
FAILED test_pythonify.py::TestPYTHONIFY::test19_keywords_and_defaults
FAILED test_pythonization.py::TestClassPYTHONIZATION::test02_size_mapping_of_templated_method
FAILED test_stltypes.py::TestSTLSTRING::test01_string_argument_passing
FAILED test_stltypes.py::TestSTLSTRING::test02_string_data_access
FAILED test_stltypes.py::TestSTLSTRING::test05_stlstring_and_unicode
FAILED test_stltypes.py::TestSTLSTRING::test08_string_operators
FAILED test_stltypes.py::TestSTLSTRING::test10_string_in_repr_and_str_bytes
FAILED test_stltypes.py::TestSTLLIST::test01_builtin_list_type
FAILED test_stltypes.py::TestSTLLIST::test02_empty_list_type
FAILED test_stltypes.py::TestSTLLIST::test03_replacement_of_eq
FAILED test_stltypes.py::TestSTLLIST::test04_iter_of_iter
FAILED test_stltypes.py::TestSTLLIST::test05_list_cpp17_style
FAILED test_stltypes.py::TestSTLLIST::test06_convert_list_of_strings
FAILED test_stltypes.py::TestSTLDEQUE::test01_deque_byvalue_regression
FAILED test_stltypes.py::TestSTLDEQUE::test02_deque_cpp17_style
FAILED test_templates.py::TestTEMPLATES::test03_templated_function
FAILED test_templates.py::TestTEMPLATES::test06_variadic_sfinae
FAILED test_templates.py::TestTEMPLATES::test07_type_deduction
FAILED test_templates.py::TestTEMPLATES::test12_template_aliases
FAILED test_templates.py::TestTEMPLATES::test13_using_templated_method
FAILED test_templates.py::TestTEMPLATES::test15_rvalue_templates
FAILED test_templates.py::TestTEMPLATES::test16_variadic
FAILED test_templates.py::TestTEMPLATES::test17_empty_body
FAILED test_templates.py::TestTEMPLATES::test23_overloaded_setitem
FAILED test_templates.py::TestTEMPLATED_TYPEDEFS::test01_using
FAILED test_templates.py::TestTEMPLATED_TYPEDEFS::test02_mapped_type_as_internal
FAILED test_templates.py::TestTEMPLATED_TYPEDEFS::test03_mapped_type_as_template_arg
FAILED test_templates.py::TestTEMPLATE_TYPE_REDUCTION::test01_reduce_binary

@wlav
Copy link
Owner

wlav commented Sep 29, 2024

Typically, when a lot of unrelated tests fail, it's something basic with the setup. Can you post the actual errors?

@lukevalenty
Copy link
Author

Typically, when a lot of unrelated tests fail, it's something basic with the setup. Can you post the actual errors?

I'm having a hard time getting them to reproduce consistently. I'm going to build a docker image and script that should reproduce it consistently, then I will share that along with the errors.

@lukevalenty
Copy link
Author

So I created a docker image to ensure the issue reproduced with a fresh install. I followed the instructions on the webpage you linked and created this docker file based on them:

Dockerfile.txt

Running this image, I get similar failures as before:

cppyy_failures.txt

@lukevalenty
Copy link
Author

Running them without the --forked option results in a segfault on the unicode test:

cppyy_failures_notforked_segfault_unicode.txt

@lukevalenty
Copy link
Author

Without --forked and filtering out the unicode test it looks a little bit better:

=============================================================== short test summary info ================================================================
FAILED test_fragile.py::TestFRAGILE::test21_failing_cppcode - AssertionError: assert 'invaliddigit' in 'FailedtoparsethegivenC++code\x1b[1minput_line_2524:1:1:\x1b[0m\x1b[0;1;31merror:\x1b[0m\x1b[1mexpectedunq...
FAILED test_numba.py::TestNUMBA::test13_std_vector_dot_product - TypeError: __array__() takes no keyword arguments
FAILED test_stltypes.py::TestSTLVECTOR::test18_array_interface - TypeError: __array__() takes no keyword arguments
FAILED test_stltypes.py::TestSTLSTRING::test01_string_argument_passing - TypeError: none of the 3 overloaded methods succeeded. Full details:
FAILED test_stltypes.py::TestSTLSTRING::test02_string_data_access - TypeError: none of the 3 overloaded methods succeeded. Full details:
FAILED test_stltypes.py::TestSTLSTRING::test05_stlstring_and_unicode - cppyy.gbl.std.runtime_error: unsigned long UnicodeAndSTL::get_size_w(std::wstring s) =>
FAILED test_stltypes.py::TestSTLSTRING::test08_string_operators - TypeError: Template method resolution failed:
FAILED test_stltypes.py::TestSTLSTRING::test10_string_in_repr_and_str_bytes - AssertionError: assert '' == 'Test3'
================================================ 8 failed, 518 passed, 3 skipped, 2 warnings in 51.30s =================================================

cppyy_failures_notforked_no_unicode.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants