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

newbie having an issue installing and running a test with cppyy #258

Open
SimonDev666 opened this issue Sep 23, 2024 · 7 comments
Open

newbie having an issue installing and running a test with cppyy #258

SimonDev666 opened this issue Sep 23, 2024 · 7 comments

Comments

@SimonDev666
Copy link

SimonDev666 commented Sep 23, 2024

hello, just started using cppyy again after a year or so.
as per you use guide the following:

running on kali linux (latest version)
ensured python3.12-dev was installed

$ python -m venv WORK
$ source WORK/bin/activate
(WORK) $ python -m pip install cppyy
(WORK) $

created a simple python file in VS code in WORK 'Test_cppyy01.py'. just contains 'import cppyy'

decided to try from out VS code, so from terminal went into WORK and could see simple python file.
ran file: 'python Test_cppyy01.py'

(Re-)building pre-compiled headers (options: -O2 -march=native); this may take a minute ...
In file included from input_line_3:2:
In file included from /usr/include/c++/14/string:42:
In file included from /usr/include/c++/14/bits/char_traits.h:57:
In file included from /usr/include/c++/14/bits/stl_construct.h:61:
In file included from /usr/include/c++/14/bits/stl_iterator_base_types.h:71:
/usr/include/c++/14/bits/iterator_concepts.h:1013:13: error: no matching function for call to '__begin'
= decltype(ranges::__access::__begin(std::declval<_Tp&>()));

100's of more error lines

any chance of telling me what i am doing wrong.

thanks
Simon

@SimonDev666
Copy link
Author

hello

seemed to have found a fix from your doc:

export CLING_STANDARD_PCH="none"

do or should i use pch headers??
if i should, how do i make or use them for all c++ generic??

@wlav
Copy link
Owner

wlav commented Sep 23, 2024

Setting it to none means the headers will be read in. Ordinarily, this would only be used if you have an alternate (e.g. modules), it typically isn't a fix if there's an issue with the headers, as they're still read in dynamically. In this particular case, it may be that there's no #include <string> (explicit or implicit) in the test script, which removes the problem but only until you do. In other scenarios, setting the envar might be a fix if there's an issue with the installed PCH, but your script is rebuilding it already, so that can't be either.

As for the error itself, I think it's the limited support in Clang13 for concepts. Using EXTRA_CLING_ARGS='-O2 -march=native -std=c++17' would downgrade the C++ version and pre-empt it. (Work is on-going on Clang16 and Clang18 shortly after.)

@SimonDev666
Copy link
Author

given the EXTRA_CLING_ARGS setting mentioned above, do I have download the source and rebuild the entire project?? what would command be, or is it as in your doc 'Install from Source' + the above EXTRA*

@SimonDev666
Copy link
Author

i entered the following 'EXTRA_CLING_ARGS='-O2 -march=native -std=c++17'' in the VS Code python termainal under the activate venv and got no errors. so i may have answered my own above question

@wlav
Copy link
Owner

wlav commented Sep 26, 2024

Yes, it's a run-time thing. PCH may need to be rebuild whenever switching args, but that's it. Aside, I pushed the first changes for LLVM16 yesterday; hopefully be done soon, after which problems like this should (famous last words) go away.

@SimonDev666
Copy link
Author

i deleted my virtual env for python, did a complete apt-get update and upgrade and repeated all of the from the prev comments:
"
python -m venv WORK
source ./WORK/bin/activate
python -m pip install cppyy
"

set these as from your doc and prev comments to me:
"
export CLING_STANDARD_PCH="none"
set EXTRA_CLING_ARGS="-O2 -march=native -std=c++17"
"

no run my code, it runs but now i get run-time errors

In file included from input_line_3:2:
In file included from /usr/include/c++/14/string:42:
In file included from /usr/include/c++/14/bits/char_traits.h:57:
In file included from /usr/include/c++/14/bits/stl_construct.h:61:
In file included from /usr/include/c++/14/bits/stl_iterator_base_types.h:71:
/usr/include/c++/14/bits/iterator_concepts.h:1013:13: error: no matching function for call to '__begin'
= decltype(ranges::__access::__begin(std::declval<_Tp&>()));
^~~~~~~~~~~~~~~~~~~~~~~~~
.....
/usr/include/c++/14/bits/iterator_concepts.h:989:19: note: because '__decay_copy(begin(__t))' would be invalid: no matching function for call to 'begin'
{ __decay_copy(begin(__t)) } -> input_or_output_iterator;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
Error: ./bin/rootcling: compilation failure (/tmp/allDictff783ed64c_dictUmbrella.h)
/home/simon/Desktop/PythonVEnv/VirtEnv/lib/python3.12/site-packages/cppyy_backend/loader.py:139: UserWarning: No precompiled header available (failed to build); this may impact performance.
warnings.warn('No precompiled header available (%s); this may impact performance.' % msg)
['/home/simon/Desktop/PythonVEnv/VirtEnv/lib/python3.12/site-packages/', '/home/simon/Desktop/Code/QT/Test_EmbedPython/Test_001_EmbedPython/', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.12/dist-packages']
(Re-)building pre-compiled headers (options: -O2 -march=native); this may take a minute ...
here
there
done
"

no matter how many times i run my code, i get the above errors, which i did not get before re-doing the current python virt env.

@wlav
Copy link
Owner

wlav commented Oct 21, 2024

It doesn't look like these:

export CLING_STANDARD_PCH="none"
set EXTRA_CLING_ARGS="-O2 -march=native -std=c++17"

were actually set and/or propagated (not sure about the change in set/export either). Can you check on the Python prompt or within your script before importing cppyy what the values are of os.environ['CLING_STANDARD_PCH'] and os.environ['EXTRA_CLING_ARGS']?

As-is, if the standard pch is none, it shouldn't be rebuild and if the second is set (and rebuilding does happen), the values should appear in this line: options: -O2 -march=native as the values set instead of the defaults (as you have).

I'd add that if the only point is to change the used standard, I'd set STDCXX=17 on installation time, or force rebuild the PCH once (by setting the CLING_REBUILD_PCH once). Doing so will "bake in" the standard.

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