• Kirill Smelkov's avatar
    pyx.build: Adjust compile flags if we are on Windows/MSVC · 5f107215
    Kirill Smelkov authored
    MSVC does not accept -std=c++11 but instead accepts /std:c++11. We cannot
    use that however because with /std:c++11 compilation fails with
    
        .\golang/libgolang.h(280): error C7555: use of designated initializers requires at least '/std:c++20'
        .\golang/libgolang.h(294): error C7555: use of designated initializers requires at least '/std:c++20'
        .\golang/libgolang.h(308): error C7555: use of designated initializers requires at least '/std:c++20'
    
    for
    
        276 // _selsend creates `_chansend(ch, ptx)` case for _chanselect.
        277 static inline
        278 _selcase _selsend(_chan *ch, const void *ptx) {
        279     _selcase _ = {
        280         .ch     = ch,			<-- NOTE
        281         .op     = _CHANSEND,
        282         .flags  = (enum _selflags)0,
        283         .user   = 0xff,
        284     };
    
    and similar places.
    
    -> Use /std:c++20 instead as MSVC advices  (WOW designated initializers are C99
    and it took 21 years for C++ to catch up).
    
    We also need to adjust exception handling mode into "fully conformant" instead
    of "assume extern C cannot throw" setuptools default so that `panic` and other
    extern C libgolang functions generate exceptions that could be caught
    instead of crashing programs.
    
    For C vs C++ flags we also need to adjust our build_ext, because the way
    setuptools/distutils organize compilation for MSVC is different from
    UNIX compilers.
    5f107215
build.py 11.1 KB