jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.08k stars 297 forks source link

Only C++11 is working 👋 #461

Open xdevs-tmp opened 1 year ago

xdevs-tmp commented 1 year ago

I tried to install xeus-cling in a jupyter/datascience-notebook container and here is the commands i used:

conda create -n cling -y
conda activate cling
conda install -c conda-forge  xeus-cling jupyter notebook
jupyter kernelspec list

I can see the C++11, C++14, C++17 showing in the Launcher, and i also found xcpp14,17 in the kernel dir: cat /opt/conda/envs/cling/share/jupyter/kernels/xcpp14/kernel.json

{
  "display_name": "C++14",
  "argv": [
      "/opt/conda/envs/cling/bin/xcpp",
      "-f",
      "{connection_file}",
      "-std=c++14"
  ],
  "language": "C++14"
}

I tried to run: /opt/conda/envs/cling/bin/xcpp -std=c++14 It outputs:

Warning in cling::IncrementalParser::CheckABICompatibility():
  Possible C++ standard library mismatch, compiled with __GLIBCXX__ '20210601'
  Extraction of runtime standard library version was: '20220527'
**Segmentation fault**

but C++11 working: /opt/conda/envs/cling/bin/xcpp -std=c++11

It outputs:

Starting xeus-cling kernel...

If you want to connect to this kernel from an other client, just copy and paste the following content inside of a `kernel.json` file. And then run for example:

# jupyter console --existing kernel.json
kernel.json
{
    "transport": "tcp",
    "ip": "127.0.0.1",
    "control_port": 64488,
    "shell_port": 53046,
    "stdin_port": 57367,
    "iopub_port": 49758,
    "hb_port": 49918,
    "signature_scheme": "hmac-sha256",
    "key": "0c93d4c196d943d4a247eb1324a54599"
}
Run with XEUS 2.4.1

I guess 11 is working, because of the global cpp? (base) jovyan@xx:~$ which cpp /usr/bin/cpp

xdevs-tmp commented 1 year ago

@SylvainCorlay, what may be the possible root cause for the "Segmentation fault" issue for 14 and 17?

xdevs-tmp commented 1 year ago

(cling) jovyan@b03a2d5b6e2d:~/work$ /opt/conda/envs/cling/bin/xcpp -std=c++17 Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with GLIBCXX '20210601' Extraction of runtime standard library version was: '20220527' Segmentation fault <---------------

(cling) jovyan@b03a2d5b6e2d:~/work$ /opt/conda/envs/cling/bin/xcpp -std=c++14 Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with GLIBCXX '20210601' Extraction of runtime standard library version was: '20220527' Segmentation fault <---------------

(cling) jovyan@b03a2d5b6e2d:~/work$ /opt/conda/envs/cling/bin/xcpp -std=c++11 Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with GLIBCXX '20210601' Extraction of runtime standard library version was: '20220527' Starting xeus-cling kernel... If you want to connect to this kernel from an other client, just copy and paste the following content inside of a kernel.json file. And then run for example:

jupyter console --existing kernel.json

kernel.json

{
    "transport": "tcp",
    "ip": "127.0.0.1",
    "control_port": 64891,
    "shell_port": 61218,
    "stdin_port": 54142,
    "iopub_port": 56446,
    "hb_port": 50707,
    "signature_scheme": "hmac-sha256",
    "key": "060d50a125674bf7b729ea07ff6caa6a"
}

Run with XEUS 2.4.1

xdevs-tmp commented 1 year ago

I have no way to find why 14 & 17 are not working? Is that 14 and 17 c++ libs are missing?

xmjiao commented 11 months ago

Having exactly the same issue with xeus-cling 0.13.0 on Ubuntu 22.04 with linux-aarch64, but the same version works with linux-x86_64 using exactly the same configurations.

xmjiao commented 11 months ago

I ran xcpp -std=c++14 and xcpp -std=c++17 inside gdb and found that segmentation fault occurs in clang::CXXRecordDecl::getLambdaCallOperator() const () from /usr/local/miniforge/lib/libxeus-cling.so.0.

This was using xeus-cling 0.13.0 installed with miniforge.

Hope this helps in isolating the issue.

davidxzfei commented 8 months ago

I got the same issue on ubuntu 22.04 ARM64. I have a work around by the following command:

conda create -n cling "python>=3.9" jupyterlab xeus-cling gcc_linux-aarch64=9.3.0 -c conda-forge

After run this command, all of the c++ kernels can run in jupyter.

I got this workaround from this link and change a little bit for ARM64 ubuntu: https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/-/issues/26

xmjiao commented 7 months ago

@davidxzfei Thanks for the hint! Downgrading to gcc_linux-aarch64=9.3.0 seems to be the key. gcc 9.4.0 also worked for me, but I did not try newer versions.