wlav / cppyy

Other
384 stars 38 forks source link

Issue with aarch64 #162

Open lonelyzerg opened 1 year ago

lonelyzerg commented 1 year ago

Hi, I am trying to add python binding support for ns/3 on my ARM SBC (Rock 5b with a RK3588 CPU). I had difficulty installing cppyy and import cppyy in python fails for me.

Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cppyy
(Re-)building pre-compiled headers (options: -O2 -march=native); this may take a minute ...
error: the clang compiler does not support '-march=native'
error: the clang compiler does not support '-march=native'
Error: Parsing Linkdef file etc/dictpch/allLinkDefs.h
/home/rock/.local/lib/python3.8/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)
error: the clang compiler does not support '-march=native'

uname -a:

rock@rock-5b:~$ uname -a
Linux rock-5b 5.10.110-36-rockchip-gba392dc725fa #rockchip SMP Tue Jan 17 07:19:43 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

I wonder if I can disable the flag somewhere. (sorry I'm not really familiar with C++ compilers)

Also below is some problems I came across with installing cppyy that might help debugging. So to start with, cppyy does not have whl on my arch, so it starts to compile cppyy-cling from source. Then it fails at about 99% progress.

I searched for the problem and found that it might related to not enough memory (8GB for my board) and I compiled cppyy-cling alone with single thread.

I letf it to compile over night and the next day I check the log and found that is has been compiling over and over again without actually building the whl. I stopped it and built the whl manually and then installed it.

Next I installed cppyy with pip3 and the installation is successful, but when I import cppyy the error above just showed up.

Thanks!

wlav commented 1 year ago

The flag to use is CLING_EXTRA_ARGS. Set it to "-O2" or something simple.

Yes, there are no wheels yet. There was a contribution that allows wheels to be build on CircleCI, but the last step still fails for some reason and I haven't had the time to try to figure it out.

lonelyzerg commented 1 year ago

So I just add this flag when compiling cppyy-cling?

wlav commented 1 year ago

Also when running. I'll fix it in the repo, too, to not add -march=native if on aarch64, but I'm not sure (until you try, I have no access to a Linux ARM device) whether that's all there is to it.

Aside, the conda install (https://anaconda.org/conda-forge/cppyy) is behind (2.3.1), but does have an Linux aarch64 build.

lonelyzerg commented 1 year ago

Thank you!

I will rebuild the whl and maybe provide some feed back later today (Pacific Time).

lonelyzerg commented 1 year ago

Am I missing something?

rock@rock-5b:~$ STDCXX=20 MAKE_NPROCS=1 CLING_EXTRA_ARGS=-O2 python3 -m pip install --verbose cppyy-cling --no-binary=cppyy-cling --no-cache-dir^C
rock@rock-5b:~$ CLING_EXTRA_ARGS=-O2 python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cppyy
(Re-)building pre-compiled headers (options: -O2 -march=native); this may take a minute ...
error: the clang compiler does not support '-march=native'
error: the clang compiler does not support '-march=native'
Error: Parsing Linkdef file etc/dictpch/allLinkDefs.h
/home/rock/.local/lib/python3.8/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)
error: the clang compiler does not support '-march=native'
wlav commented 1 year ago

Sorry, my mistake, it's EXTRA_CLING_ARGS, not CLING_EXTRA_ARGS (the latter being more logical, but I didn't invent the name...).

lonelyzerg commented 1 year ago

Thanks for the update, will try.