xeus-cling icon indicating copy to clipboard operation
xeus-cling copied to clipboard

[Windows] Tracking Windows Support

Open SylvainCorlay opened this issue 5 years ago • 12 comments

Now that cling 0.6 works on windows this issue is meant to track the windows support of xeus-cling

  • ~~most cells in the example notebooks don't work when they involve streams. Disabling redirection prevents the kernel from dying. The stream redirection appears to be the culprit.~~
  • ~~Another cell that fails without any stream redirection is the timeit example. Cxxopts appears to be dropping commas???~~
  • The last issue is the cell that throws an exception which makes the kernel crash.

SylvainCorlay avatar Dec 10 '19 11:12 SylvainCorlay

It seems that most of the streaming issues will be solved with proper testing of xoutput_buffer with MSVC's streambuf implementation.

SylvainCorlay avatar Dec 10 '19 11:12 SylvainCorlay

The stream issue is resolved.

Now remains

  • the issue with cxxopts dropping commas
  • the exception catching on windows.

SylvainCorlay avatar Dec 23 '19 11:12 SylvainCorlay

The cxxopts issue is resolved by requiring cxxopts < 2.2.0. It seems that version 2.2.0 included some regressions. Will be openning a separate issue for this.

Now remains

  • the exception catching on windows
  • the issue with std::endl crashing the interpreter on windows (more specifically the call to ios_base::widen('\n') crashes the interpreter).

SylvainCorlay avatar Dec 25 '19 23:12 SylvainCorlay

@SylvainCorlay Are you able to use xeus-cling on Windows? If I include e.g. stdio.h I get a lot of errors, which restarts the kernel.

In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:12:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt.h:10:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:184:30: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long long')
    typedef unsigned int     size_t;
                             ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:196:13: error: unknown type name '_Bool'
    typedef _Bool __vcrt_bool;
            ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:215:22: error: 'short wchar_t' is invalid
    typedef unsigned short wchar_t;
                     ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt.h:156:13: error: unknown type name '_Bool'
    typedef _Bool __crt_bool;
            ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:13:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:13:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_stdio_config.h:31:10: error: Unsupported architecture
        #error Unsupported architecture
         ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:13:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:320:16: error: no matching function for call to '_vfwprintf_l'
        return _vfwprintf_l(_Stream, _Format, NULL, _ArgList);
               ^~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:296:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:351:20: error: no matching function for call to '_vfwprintf_s_l'
            return _vfwprintf_s_l(_Stream, _Format, NULL, _ArgList);
                   ^~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:325:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_s_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:382:16: error: no matching function for call to '_vfwprintf_p_l'
        return _vfwprintf_p_l(_Stream, _Format, NULL, _ArgList);
               ^~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:358:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_p_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:409:16: error: no matching function for call to '_vfwprintf_l'
        return _vfwprintf_l(stdout, _Format, NULL, _ArgList);
               ^~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:296:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:438:20: error: no matching function for call to '_vfwprintf_s_l'
            return _vfwprintf_s_l(stdout, _Format, NULL, _ArgList);
                   ^~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:325:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_s_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:467:16: error: no matching function for call to '_vfwprintf_p_l'
        return _vfwprintf_p_l(stdout, _Format, NULL, _ArgList);
               ^~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:358:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_p_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:483:9: error: use of undeclared identifier '__crt_va_start_a'
        __crt_va_start(_ArgList, _Locale);
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vadefs.h:160:35: note: expanded from macro '__crt_va_start'
    #define __crt_va_start(ap, x) __crt_va_start_a(ap, x)
                                  ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:13:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:485:9: error: use of undeclared identifier '__crt_va_end'
        __crt_va_end(_ArgList);
        ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:501:9: error: use of undeclared identifier '__crt_va_start_a'
        __crt_va_start(_ArgList, _Format);
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vadefs.h:160:35: note: expanded from macro '__crt_va_start'
    #define __crt_va_start(ap, x) __crt_va_start_a(ap, x)
                                  ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:13:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:502:19: error: no matching function for call to '_vfwprintf_l'
        _Result = _vfwprintf_l(_Stream, _Format, NULL, _ArgList);
                  ^~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:296:37: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'const _locale_t' (aka '__crt_locale_pointers *const') for 3rd argument
    _CRT_STDIO_INLINE int __CRTDECL _vfwprintf_l(
                                    ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:503:9: error: use of undeclared identifier '__crt_va_end'
        __crt_va_end(_ArgList);
        ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:520:9: error: use of undeclared identifier '__crt_va_start_a'
        __crt_va_start(_ArgList, _Locale);
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vadefs.h:160:35: note: expanded from macro '__crt_va_start'
    #define __crt_va_start(ap, x) __crt_va_start_a(ap, x)
                                  ^
In file included from input_line_7:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h:13:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:522:9: error: use of undeclared identifier '__crt_va_end'
        __crt_va_end(_ArgList);
        ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:540:13: error: use of undeclared identifier '__crt_va_start_a'
            __crt_va_start(_ArgList, _Format);
            ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vadefs.h:160:35: note: expanded from macro '__crt_va_start'
    #define __crt_va_start(ap, x) __crt_va_start_a(ap, x)
                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Interpreter Error: 

Furthermore I see this error message when I include stdio.h.

In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\new:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\exception:8:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits:6:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xstddef:338:2: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
        auto _Unfancy(_Ptrty _Ptr)
        ^
input_line_2:1:10: fatal error: 'cling/Interpreter/RuntimeUniverse.h' file not found
#include "cling/Interpreter/RuntimeUniverse.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AchimTuran avatar Apr 05 '20 11:04 AchimTuran

I used the commit 4ac584962f9235f26fae27a93a5bff9a58791657 (master from today) with the following instructions to build the project:

git clone https://github.com/jupyter-xeus/xeus-cling
cd xeus-cling
mkdir build && cd build
conda install -c conda-forge jupyterlab
conda create -n xeus-cling -c conda-forge cmake xeus=0.23.3 cling=0.6.0 clangdev=5.0 llvmdev=5 nlohmann_json cppzmq=4.3.0 xtl=0.6.9 pugixml cxxopts=2.1.1 dirent
conda activate xeus-cling
cmake -D CMAKE_INSTALL_PREFIX="%CONDA_PREFIX%" CMAKE_INSTALL_LIBDIR="%CONDA_PREFIX%/lib" -D DOWNLOAD_GTEST=ON -G"Visual Studio 14 Win64" ..
cmake --build . --target INSTALL --config Release

Furthermore I needed some patches to get the build working. See 0001-patches.zip. Should I open a pull request with the changes?

AchimTuran avatar Apr 05 '20 11:04 AchimTuran

The downloaded cling.exe with conda install works fine: grafik

AchimTuran avatar Apr 05 '20 11:04 AchimTuran

Okay I partially got it working. When I use Jupyter Lab with the C++14 language support it works. If C++11 is used I see the following error:

In file included from input_line_1:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\new:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\exception:8:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits:6:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xstddef:338:2: error: 'auto' return without trailing return type; deduced return types are a C++14 extension

Is this a known issue?

In Jupyter notebook I'm able to run the following code: grafik

AchimTuran avatar Apr 05 '20 13:04 AchimTuran

@SylvainCorlay I opend #328 with my fixes, but somehow the build breaks, see https://github.com/jupyter-xeus/xeus-cling/pull/328#issuecomment-609421564.

AchimTuran avatar Apr 05 '20 14:04 AchimTuran

@AchimTuran thanks for looking into this. The main reason why we have not uploaded a xeus-cling conda package is

https://github.com/root-project/cling/issues/300

Basically std::endl crashes the interpreter on windows. (The most relevant content are by the end of the thread). This is reproducible with the cling conda package.

I will respond more inline in your PR.

SylvainCorlay avatar Apr 05 '20 14:04 SylvainCorlay

Quick update on this, it seems that root-project/cling#300 should be solved by using vs2019. Hence windows support may presumably be achieved once we can switch to vs2019 on conda-forge.

SylvainCorlay avatar Jan 25 '21 17:01 SylvainCorlay

Just here to say this is very exciting! Feel free to delete this comment, but before you do is there a way to hack together an unsupported version so I can start playing early? I don't have space to dual boot my PC but really want to use this as a learning tool for C++.

wcneill avatar Nov 11 '22 21:11 wcneill

Just here to say this is very exciting! Feel free to delete this comment, but before you do is there a way to hack together an unsupported version so I can start playing early? I don't have space to dual boot my PC but really want to use this as a learning tool for C++.

sameee i'm on windows too, this seems so cool 🥹

hiyorijl avatar Jun 17 '23 13:06 hiyorijl