mstorsjo / llvm-mingw

An LLVM/Clang/LLD based mingw-w64 toolchain
Other
1.96k stars 187 forks source link

lldb python support #73

Closed cristianadam closed 3 years ago

cristianadam commented 4 years ago

Qt Creator requires python support from gdb / lldb debugger.

It would be great to have a fully toolchain on Windows 😄

RussellHaley commented 3 years ago

So, if you had a working build using autotools, and but it's failing due to wanting to link python as a DLL, didn't you get a dll and libpyhon*.dll.a when you built it? If not, can you try adding --enable-shared when building python?

No, sorry, the successful build was a cmake build of 3.6.7. It only built the static library (I have never had the autotools work). When I turned on the shared build and added the extensions, everything fell apart again and I was trying to patch source code.

osboxes@osboxes ~/python-cmake-install> ls
bin/  include/  Lib/  libs/  share/
osboxes@osboxes ~/python-cmake-install> find . -type f -iname "*dll*"
osboxes@osboxes ~/python-cmake-install> find . -type f -iname "*.a"
./libs/libpython36.a
./Lib/config/libpython36.a
osboxes@osboxes ~/python-cmake-install> 

After my initial difficulty, I decided to look a little a little harder at the MSYS2 patches - great suggestion @longnguyen2004 - and was able to patch 3.8.7 successfully with the following script:

#!/bin/bash
PATCH_DIR=~/git/MINGW-packages
SRC_DIR=~/Python-3.8.7/
BIGPATCHFILE=/tmp/big.patch

cat $PATCH_DIR/mingw-w64-python/* > $BIGPATCHFILE
cd $SRC_DIR
patch -p1 < $BIGPATCHFILE
osboxes@osboxes ~/Python-3.8.7> ../patch-python.sh
patching file Lib/sysconfig.py
patching file Lib/distutils/spawn.py
patching file setup.py
patching file configure.ac
Hunk #1 succeeded at 5651 (offset 27 lines).
Hunk #2 succeeded at 5663 (offset 27 lines).
patching file Makefile.pre.in
Hunk #3 succeeded at 1795 (offset 3 lines).
patching file Modules/Setup.config.in
patching file configure.ac
Hunk #1 succeeded at 1973 (offset 13 lines).
Hunk #2 succeeded at 2131 (offset 13 lines).
Hunk #3 succeeded at 2153 (offset 13 lines).
Hunk #4 succeeded at 2189 (offset 13 lines).
Hunk #5 succeeded at 2204 (offset 13 lines).
Hunk #6 succeeded at 2409 (offset 13 lines).
Hunk #7 succeeded at 2443 (offset 13 lines).
Hunk #8 succeeded at 2886 (offset 13 lines).
Hunk #9 succeeded at 3179 (offset 28 lines).
Hunk #10 succeeded at 3635 (offset 28 lines).
Hunk #11 succeeded at 4568 (offset 28 lines).
Hunk #12 succeeded at 4605 (offset 28 lines).
patching file Modules/_multiprocessing/multiprocessing.h
patching file pyconfig.h.in
patching file Include/pyport.h
patching file configure.ac
patching file Python/getplatform.c
patching file configure.ac
Hunk #1 succeeded at 899 (offset 6 lines).
patching file Misc/config_mingw
patching file Misc/cross_mingw32
patching file configure.ac
Hunk #1 succeeded at 2420 (offset 13 lines).
patching file configure.ac
Hunk #1 succeeded at 5474 (offset 24 lines).
patching file configure.ac
Hunk #1 succeeded at 580 (offset 6 lines).
patching file Modules/posixmodule.c
patching file Modules/Setup
patching file Modules/Setup.config.in
patching file configure.ac
Hunk #1 succeeded at 3209 (offset 28 lines).
patching file Modules/Setup.config.in
patching file PC/winreg.c
patching file configure.ac
Hunk #1 succeeded at 3216 (offset 28 lines).
patching file Modules/Setup
patching file Modules/Setup.config.in
patching file Lib/distutils/sysconfig.py
patching file Lib/distutils/unixccompiler.py
patching file Include/pyport.h
patching file setup.py
patching file configure.ac
Hunk #1 succeeded at 1210 (offset 6 lines).
Hunk #2 succeeded at 1225 (offset 6 lines).
Hunk #3 succeeded at 2784 (offset 13 lines).
Hunk #4 succeeded at 5519 (offset 24 lines).
patching file configure.ac
Hunk #1 succeeded at 2648 (offset 13 lines).
Hunk #2 succeeded at 3708 (offset 28 lines).
Hunk #3 succeeded at 5508 with fuzz 2 (offset 662 lines).
patching file Makefile.pre.in
patching file Python/dynload_win.c
Hunk #2 succeeded at 207 (offset -2 lines).
patching file configure.ac
Hunk #1 succeeded at 5539 (offset 24 lines).
patching file Makefile.pre.in
patching file setup.py
patching file Modules/selectmodule.c
patching file setup.py
patching file setup.py
patching file configure.ac
Hunk #1 succeeded at 4319 (offset 28 lines).
Hunk #2 succeeded at 5444 (offset 18 lines).
patching file Misc/config_mingw
patching file Modules/socketmodule.c
patching file pyconfig.h.in
Hunk #3 succeeded at 1651 (offset 4 lines).
patching file setup.py
patching file setup.py
patching file Modules/_winapi.c
patching file PC/msvcrtmodule.c
patching file Python/dynamic_annotations.c
patching file setup.py
Hunk #1 succeeded at 1507 (offset -33 lines).
patching file Lib/distutils/command/build_ext.py
Hunk #2 succeeded at 711 (offset 8 lines).
patching file Lib/distutils/util.py
patching file Lib/sysconfig.py
Hunk #1 succeeded at 644 (offset 1 line).
patching file Lib/distutils/ccompiler.py
patching file Lib/distutils/cygwinccompiler.py
patching file Lib/distutils/cygwinccompiler.py
patching file setup.py
Hunk #1 succeeded at 2260 (offset 3 lines).
patching file Lib/sysconfig.py
Hunk #4 succeeded at 497 (offset 1 line).
Hunk #5 succeeded at 568 (offset 1 line).
Hunk #6 succeeded at 583 (offset 1 line).
patching file Modules/_ctypes/_ctypes.c
Hunk #1 succeeded at 3406 (offset 64 lines).
patching file setup.py
Hunk #1 succeeded at 2437 (offset 3 lines).
patching file Lib/distutils/cygwinccompiler.py
patching file Lib/distutils/sysconfig.py
patching file Lib/site.py
patching file Misc/python-config.sh.in
patching file configure.ac
Hunk #5 succeeded at 1649 (offset 6 lines).
Hunk #6 succeeded at 2020 (offset 6 lines).
Hunk #7 succeeded at 2583 (offset 13 lines).
Hunk #8 succeeded at 2608 (offset 13 lines).
Hunk #9 succeeded at 2620 (offset 13 lines).
patching file Include/internal/pycore_condvar.h
patching file Include/pythread.h
patching file setup.py
Hunk #1 succeeded at 2033 (offset 3 lines).
patching file Include/pylifecycle.h
patching file Lib/ntpath.py
Hunk #5 succeeded at 101 (offset 8 lines).
Hunk #6 succeeded at 162 (offset 8 lines).
Hunk #7 succeeded at 218 (offset 8 lines).
Hunk #8 succeeded at 465 (offset 8 lines).
Hunk #9 succeeded at 681 (offset 48 lines).
Hunk #10 succeeded at 692 (offset 33 lines).
Hunk #11 succeeded at 751 (offset 33 lines).
patching file Modules/posixmodule.c
Hunk #1 succeeded at 3476 (offset 38 lines).
Hunk #2 succeeded at 3931 (offset 44 lines).
Hunk #3 succeeded at 4008 (offset 44 lines).
patching file Python/initconfig.c
Hunk #1 succeeded at 130 (offset 32 lines).
Hunk #2 succeeded at 1172 (offset 43 lines).
patching file Python/pathconfig.c
Hunk #1 succeeded at 13 with fuzz 1.
Hunk #2 succeeded at 622 (offset -46 lines).
patching file Python/traceback.c
patching file Include/pylifecycle.h
patching file Modules/getpath.c
patching file Modules/posixmodule.c
Hunk #1 succeeded at 3735 (offset 44 lines).
patching file Python/dynload_win.c
patching file Modules/getpath.c
patching file Modules/Setup.config.in
patching file configure.ac
Hunk #1 succeeded at 604 (offset 6 lines).
patching file Lib/sysconfig.py
patching file Makefile.pre.in
patching file Lib/distutils/command/build_ext.py
patching file Lib/sysconfig.py
Hunk #2 succeeded at 462 with fuzz 2 (offset 1 line).
patching file Lib/distutils/cygwinccompiler.py
patching file Modules/Setup.config.in
patching file setup.py
Hunk #1 succeeded at 1515 (offset -30 lines).
patching file Include/pyport.h
patching file setup.py
patching file Lib/compileall.py
patching file Lib/distutils/command/install.py
patching file Lib/distutils/util.py
patching file Makefile.pre.in
patching file setup.py
Hunk #3 succeeded at 1912 (offset 3 lines).
Hunk #4 succeeded at 1995 (offset 3 lines).
patching file Include/py_curses.h
patching file Python/graminit.c
patching file Modules/parsermodule.c
patching file Makefile.pre.in
Hunk #2 succeeded at 1784 (offset 3 lines).
patching file Programs/_freeze_importlib.c
patching file setup.py
patching file setup.py
Hunk #5 succeeded at 1872 (offset 3 lines).
patching file Lib/distutils/command/install.py
patching file Include/osdefs.h
patching file configure.ac
Hunk #1 succeeded at 3084 (offset 13 lines).
patching file Modules/_localemodule.c
patching file Lib/ctypes/__init__.py
Hunk #1 succeeded at 453 (offset 4 lines).
patching file Modules/_gdbmmodule.c
patching file Include/bytesobject.h
patching file Include/pyerrors.h
patching file Include/sysmodule.h
patching file Lib/ssl.py
patching file Lib/distutils/cygwinccompiler.py
patching file Lib/distutils/cygwinccompiler.py
patching file Python/sysmodule.c
Hunk #2 succeeded at 2743 (offset 49 lines).
patching file Lib/distutils/command/build_ext.py
patching file Python/getcompiler.c
patching file configure.ac
Hunk #1 succeeded at 5692 (offset 24 lines).
patching file Makefile.pre.in
patching file configure.ac
Hunk #1 succeeded at 5311 (offset 18 lines).
patching file Modules/Setup
patching file Modules/Setup
patching file Modules/_multiprocessing/multiprocessing.c
patching file Include/iscygpty.h
patching file Makefile.pre.in
patching file Modules/_io/fileio.c
Hunk #1 succeeded at 19 (offset 1 line).
Hunk #2 succeeded at 1126 (offset 6 lines).
patching file Modules/main.c
patching file Modules/posixmodule.c
Hunk #2 succeeded at 9418 (offset 159 lines).
patching file Python/frozenmain.c
patching file Python/iscygpty.c
patching file Python/pylifecycle.c
Hunk #2 succeeded at 2327 (offset -23 lines).
patching file Python/bltinmodule.c
patching file Objects/fileobject.c
patching file Python/fileutils.c
patching file setup.py
Hunk #1 succeeded at 1311 (offset -20 lines).
patching file Makefile.pre.in
patching file setup.py
Hunk #1 succeeded at 2164 (offset -1 lines).
patching file setup.py
patching file Include/fileobject.h
Hunk #1 succeeded at 30 with fuzz 1 (offset 7 lines).
patching file Modules/getpath.c
patching file Modules/_xxsubinterpretersmodule.c
Hunk #1 succeeded at 1751 (offset 2 lines).
patching file configure.ac
Hunk #1 succeeded at 4138 (offset 28 lines).
patching file Lib/distutils/msvc9compiler.py
patching file Lib/venv/scripts/common/activate
patching file Lib/venv/__init__.py
Hunk #3 succeeded at 244 (offset -1 lines).
Hunk #5 succeeded at 291 (offset -1 lines).
patching file Makefile.pre.in
patching file Lib/distutils/cygwinccompiler.py
patching file configure.ac
Hunk #1 succeeded at 5007 (offset 17 lines).
patching file Misc/python.pc.in
patching file Lib/importlib/_bootstrap_external.py
patching file Lib/pathlib.py
patching file Modules/_localemodule.c
patching file Python/fileutils.c
Hunk #1 succeeded at 1976 (offset 1 line).
patching file setup.py
Hunk #1 succeeded at 892 with fuzz 1.
patching file Modules/_winapi.c
patching file Modules/posixmodule.c
Hunk #1 succeeded at 4869 (offset 65 lines).
Hunk #2 succeeded at 12413 (offset 188 lines).
Hunk #3 succeeded at 13683 (offset 192 lines).
Hunk #4 succeeded at 13733 (offset 192 lines).
patching file Modules/socketmodule.h
patching file PC/python_exe.rc
patching file PC/pythonw_exe.rc
patching file PC/winreg.c
Hunk #1 succeeded at 803 (offset 3 lines).
patching file Python/thread_nt.h

But autotools still says no (computer says no):

osboxes@osboxes ~/Python-3.8.7 [1]> ./configure --host=x86_64-w64-mingw32 --build=x86_64-pc-linux
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-w64-mingw32
checking for python3.8... python3.8
checking for python interpreter for cross build... python3.8
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... configure: error: cross build not supported for x86_64-w64-mingw32

If someone can suggest how to get around autotools refusing to cross build then I think we're in good shape? I don't know anything about autotools (on purpose).

Otherwise I can massage the MSYS2 patches into the CMake build and take a shot at building 3.8.7 with cmake? The existing cmake already has a patching mechanism. I don't mind working with the cmake, I just don't like inventing patches to the python code that I will never be testing. I think the MSYS2 patches are a WAY better idea than the wonky patches that I was working with. They were cluegy.

I need to go make lunches... Night!

mstorsjo commented 3 years ago

No, sorry, the successful build was a cmake build of 3.6.7. It only built the static library (I have never had the autotools work). When I turned on the shared build and added the extensions, everything fell apart again and I was trying to patch source code.

Ok, I see, that probably explains it.

So in that case, I'd suggest you hack out the define of Py_ENABLE_SHARED from your pyconfig.h, and/or define Py_NO_ENABLE_SHARED when building LLDB - that might work, kinda. Not nice of course.

So if you have that successful build, you could try just defining Py_NO_ENABLE_SHARED

But autotools still says no (computer says no):

osboxes@osboxes ~/Python-3.8.7 [1]> ./configure --host=x86_64-w64-mingw32 --build=x86_64-pc-linux
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-w64-mingw32
checking for python3.8... python3.8
checking for python interpreter for cross build... python3.8
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... configure: error: cross build not supported for x86_64-w64-mingw32

If someone can suggest how to get around autotools refusing to cross build then I think we're in good shape? I don't know anything about autotools (on purpose).

Looks like they explicitly only support cross compilation in a few setups they do care about: https://github.com/python/cpython/blob/master/configure.ac#L380-L401

I guess it could be possible to just add a pattern for mingw triples there (and either regenerate configure, or manually patch in the same there in the generated file), but dunno if one has to do a lot of similar patching in other places then, too.

longnguyen2004 commented 3 years ago

Otherwise I can massage the MSYS2 patches into the CMake build and take a shot at building 3.8.7 with cmake?

@RussellHaley Sadly the Python source tree has changed greatly since 3.6.7. Many files are moved around, created and deleted. pgen, which used to be a C program, is now a Python program, so the pgen target needs to be removed/modified. This is non-trivial imo.

I'm gonna poke around at the Python source now, I also wanna add support for mingw in vcpkg.

RussellHaley commented 3 years ago

Well this has ended bitterly. I'm back patching python source files.

1) I followed the autotools route. I just patched configure to let mingw through. 2) configure then errored when searching for readelf. It found a native readelf, gave a warning and then quit with an error. The error message was unintelligible so I just hacked the "readelf error" out of the configure file (HACK). 3) configure gave some weird message: "configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling". I found the solution buried in yet another mingw patch that was never accepted. (seriously?) https://bugs.python.org/issue3754. The solution was to create a config.site file.

osboxes@osboxes ~/Python-3.8.7 [2]> cat config.site
ac_cv_file__dev_ptmx=no
ac_cv_file__dev_ptc=no
osboxes@osboxes ~/Python-3.8.7 [2]> CONFIG_SITE=config.site ./configure --host=x86_64-w64-mingw32 --build=x86_64-pc-linux

I think there were other errors but I don't remember... Oh ya, it wouldn't build a Setup.config file or something.

4) It finally started to build but was missing a basic header file. So I added the "PC" directory to my make call:

osboxes@osboxes ~/Python-3.8.7> make "CFLAGS=-I./PC"

5) Then things started to really fall apart. There are a whole bunch of calls to _MSC_VER that muck up the defines....

At this point I am literally right back where I was with the original Python-3.6.7 cmake... before I started patching! I recognize the CMake structures that were put in place to deal with these errors that I'm seeing. For instance, the cmake has logic to include a custom mingw header file instead of the files in the PC folder. The cmake build already has a a python.h file that has _MSC_VER removed.

SO... ?

Here are some possible routes: 1) I will contact the lilypond team and see if they have something. They had offered mingw patches as I mentioned before. Maybe they have a complete functioning build? 2) I never looked at the patches from MSYS2. Perhaps I did something wrong or there are some other clues that reading the content a little closer might reveal. There may be a build script somewhere in the MSYS2 repository. 3) I have a candidate libpython36.a file we could try using. I will go back and review Martins suggestions and see if I can make that build work. However, it likely won't have the extensions built in and won't work with KDevelop. 4) I could attempt to put the patched 3.8.7 files into the cmake build. 5) We can continue patching with the autotools build. I just don't know. I think the pyconfig.h

Regardless of the route we finally pick we have another concern: we will not be able to trust the python binaries because we don't really know how well they work. We aren't just doing a little tinkering with a couple of lines of patches. This is serious manipulation of the source code with unknown side effects.

What we do know is the hocus pocus to get lldb to at least start a build that includes python. I think it would be wise to pull working DLLs or whatever out of a python installation and build lldb and lldb-mi with those. Obviously our final solution should build from source, but someone could test lldb/python in parallel to shorten our development time? It would also give us a golden image we could compare against, and allow us to work out any kinks. Who knows, maybe 3.8.7 won't work?

Okay, lunches...

longnguyen2004 commented 3 years ago

@RussellHaley Have you run autoreconf -fi to regenerate the configure script? Cross-compiling is working for me, aside from missing readelf. We can use binutils readelf in the meantime (install binutils-mingw-w64-x86-64)

Configure log: ``` ../configure CFLAGS='-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601 -I../PC' CXXFLAGS='-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601 -I../PC' --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 --enable-shared --with-nt-threads --without-ensurepip --without-c-locale-coercion --disable-ipv6 checking for git... found checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-w64-mingw32 checking for python3.8... python3.8 checking for python interpreter for cross build... python3.8 checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... "win" checking absolute host location of VPATH... /home/KurumiGaming/cpython checking absolute host location of prefix... ../configure: line 3553: cd: NONE: No such file or directory checking absolute host location of srcdir... /home/KurumiGaming/cpython checking absolute host location of abs_srcdir... /home/KurumiGaming/cpython checking Absolute host location of abs_builddir... /home/KurumiGaming/cpython/build checking for init system calls... nt checking for x86_64-w64-mingw32-gcc... x86_64-w64-mingw32-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.exe checking for suffix of executables... .exe checking whether we are cross compiling... yes checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether x86_64-w64-mingw32-gcc accepts -g... yes checking for x86_64-w64-mingw32-gcc option to accept ISO C89... none needed checking how to run the C preprocessor... x86_64-w64-mingw32-gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for a sed that does not truncate output... /usr/bin/sed checking for --with-cxx-main=... no checking for x86_64-w64-mingw32-c++... x86_64-w64-mingw32-c++ configure: By default, distutils will build C++ extension modules with "x86_64-w64-mingw32-c++". If this is not intended, then set CXX on the configure command line. checking for the platform triplet based on compiler characteristics... none configure: loading configure defaults from .../Misc/config_mingw" configure: loading cross defaults from .../Misc/cross_mingw32" checking for -Wl,--no-as-needed... no checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for the Android API level... not Android checking for --with-suffix... .exe checking for case-insensitive build directory... no checking LIBRARY... libpython$(VERSION)$(ABIFLAGS).a checking LINKCC... $(PURIFY) $(MAINCC) checking for GNU ld... no checking for --enable-shared... yes checking for --enable-profiling... no checking LDLIBRARY... libpython$(LDVERSION).dll.a checking for x86_64-w64-mingw32-ar... x86_64-w64-mingw32-ar checking for x86_64-w64-mingw32-readelf... x86_64-w64-mingw32-readelf checking for a BSD-compatible install... /usr/bin/install -c checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for --with-pydebug... no checking for --with-trace-refs... no checking for --with-assertions... no checking for --enable-optimizations... no checking PROFILE_TASK... -m test --pgo checking for --with-lto... no checking for x86_64-w64-mingw32-llvm-profdata... no checking for llvm-profdata... /home/KurumiGaming/llvm-mingw/bin/llvm-profdata configure: WARNING: using cross tools not prefixed with host triplet checking for -Wextra... yes checking whether x86_64-w64-mingw32-gcc accepts and needs -fno-strict-aliasing... no checking if we can turn off x86_64-w64-mingw32-gcc unused result warning... yes checking if we can turn off x86_64-w64-mingw32-gcc unused parameter warning... yes checking if we can turn off x86_64-w64-mingw32-gcc missing field initializers warning... yes checking if we can turn on x86_64-w64-mingw32-gcc mixed sign comparison warning... yes checking if we can turn on x86_64-w64-mingw32-gcc unreachable code warning... yes checking if we can turn on x86_64-w64-mingw32-gcc strict-prototypes warning... yes checking if we can make implicit function declaration an error in x86_64-w64-mingw32-gcc... yes checking for NT threads... yes checking whether x86_64-w64-mingw32-c++ also accepts flags for thread support... always checking for ANSI C header files... (cached) yes checking asm/types.h usability... no checking asm/types.h presence... no checking for asm/types.h... no checking crypt.h usability... no checking crypt.h presence... no checking for crypt.h... no checking conio.h usability... yes checking conio.h presence... yes checking for conio.h... yes checking direct.h usability... yes checking direct.h presence... yes checking for direct.h... yes checking for dlfcn.h... (cached) no checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking grp.h usability... no checking grp.h presence... no checking for grp.h... no checking ieeefp.h usability... yes checking ieeefp.h presence... yes checking for ieeefp.h... yes checking io.h usability... yes checking io.h presence... yes checking for io.h... yes checking langinfo.h usability... no checking langinfo.h presence... no checking for langinfo.h... no checking libintl.h usability... no checking libintl.h presence... no checking for libintl.h... no checking process.h usability... yes checking process.h presence... yes checking for process.h... yes checking shadow.h usability... no checking shadow.h presence... no checking for shadow.h... no checking signal.h usability... yes checking signal.h presence... yes checking for signal.h... yes checking stropts.h usability... no checking stropts.h presence... no checking for stropts.h... no checking termios.h usability... no checking termios.h presence... no checking for termios.h... no checking utime.h usability... yes checking utime.h presence... yes checking for utime.h... yes checking poll.h usability... no checking poll.h presence... no checking for poll.h... no checking sys/devpoll.h usability... no checking sys/devpoll.h presence... no checking for sys/devpoll.h... no checking sys/epoll.h usability... no checking sys/epoll.h presence... no checking for sys/epoll.h... no checking sys/poll.h usability... no checking sys/poll.h presence... no checking for sys/poll.h... no checking sys/audioio.h usability... no checking sys/audioio.h presence... no checking for sys/audioio.h... no checking sys/xattr.h usability... no checking sys/xattr.h presence... no checking for sys/xattr.h... no checking sys/bsdtty.h usability... no checking sys/bsdtty.h presence... no checking for sys/bsdtty.h... no checking sys/event.h usability... no checking sys/event.h presence... no checking for sys/event.h... no checking sys/file.h usability... yes checking sys/file.h presence... yes checking for sys/file.h... yes checking sys/ioctl.h usability... no checking sys/ioctl.h presence... no checking for sys/ioctl.h... no checking sys/kern_control.h usability... no checking sys/kern_control.h presence... no checking for sys/kern_control.h... no checking sys/loadavg.h usability... no checking sys/loadavg.h presence... no checking for sys/loadavg.h... no checking sys/lock.h usability... no checking sys/lock.h presence... no checking for sys/lock.h... no checking sys/mkdev.h usability... no checking sys/mkdev.h presence... no checking for sys/mkdev.h... no checking sys/modem.h usability... no checking sys/modem.h presence... no checking for sys/modem.h... no checking sys/param.h usability... yes checking sys/param.h presence... yes checking for sys/param.h... yes checking sys/random.h usability... no checking sys/random.h presence... no checking for sys/random.h... no checking sys/select.h usability... no checking sys/select.h presence... no checking for sys/select.h... no checking sys/sendfile.h usability... no checking sys/sendfile.h presence... no checking for sys/sendfile.h... no checking sys/socket.h usability... no checking sys/socket.h presence... no checking for sys/socket.h... no checking sys/statvfs.h usability... no checking sys/statvfs.h presence... no checking for sys/statvfs.h... no checking for sys/stat.h... (cached) yes checking sys/syscall.h usability... no checking sys/syscall.h presence... no checking for sys/syscall.h... no checking sys/sys_domain.h usability... no checking sys/sys_domain.h presence... no checking for sys/sys_domain.h... no checking sys/termio.h usability... no checking sys/termio.h presence... no checking for sys/termio.h... no checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking sys/times.h usability... no checking sys/times.h presence... no checking for sys/times.h... no checking for sys/types.h... (cached) yes checking sys/uio.h usability... no checking sys/uio.h presence... no checking for sys/uio.h... no checking sys/un.h usability... no checking sys/un.h presence... no checking for sys/un.h... no checking sys/utsname.h usability... no checking sys/utsname.h presence... no checking for sys/utsname.h... no checking sys/wait.h usability... no checking sys/wait.h presence... no checking for sys/wait.h... no checking pty.h usability... no checking pty.h presence... no checking for pty.h... no checking libutil.h usability... no checking libutil.h presence... no checking for libutil.h... no checking sys/resource.h usability... no checking sys/resource.h presence... no checking for sys/resource.h... no checking netpacket/packet.h usability... no checking netpacket/packet.h presence... no checking for netpacket/packet.h... no checking sysexits.h usability... no checking sysexits.h presence... no checking for sysexits.h... no checking bluetooth.h usability... no checking bluetooth.h presence... no checking for bluetooth.h... no checking linux/tipc.h usability... no checking linux/tipc.h presence... no checking for linux/tipc.h... no checking linux/random.h usability... no checking linux/random.h presence... no checking for linux/random.h... no checking spawn.h usability... no checking spawn.h presence... no checking for spawn.h... no checking util.h usability... no checking util.h presence... no checking for util.h... no checking alloca.h usability... no checking alloca.h presence... no checking for alloca.h... no checking endian.h usability... no checking endian.h presence... no checking for endian.h... no checking sys/endian.h usability... no checking sys/endian.h presence... no checking for sys/endian.h... no checking sys/sysmacros.h usability... no checking sys/sysmacros.h presence... no checking for sys/sysmacros.h... no checking linux/memfd.h usability... no checking linux/memfd.h presence... no checking for linux/memfd.h... no checking sys/memfd.h usability... no checking sys/memfd.h presence... no checking for sys/memfd.h... no checking sys/mman.h usability... no checking sys/mman.h presence... no checking for sys/mman.h... no checking for dirent.h that defines DIR... yes checking for library containing opendir... none required checking whether sys/types.h defines makedev... no checking for sys/mkdev.h... (cached) no checking for sys/sysmacros.h... (cached) no checking bluetooth/bluetooth.h usability... no checking bluetooth/bluetooth.h presence... no checking for bluetooth/bluetooth.h... no checking for net/if.h... no checking for linux/netlink.h... no checking for linux/qrtr.h... no checking for linux/vm_sockets.h... no checking for linux/can.h... no checking for linux/can/raw.h... no checking for linux/can/bcm.h... no checking for clock_t in time.h... yes checking for makedev... no checking for le64toh... no checking for mode_t... yes checking for off_t... yes checking for pid_t... yes checking for size_t... yes checking for uid_t in sys/types.h... no checking for ssize_t... yes checking for __uint128_t... yes checking size of int... 4 checking size of long... 4 checking size of long long... 8 checking size of void *... 8 checking size of short... 2 checking size of float... 4 checking size of double... 8 checking size of fpos_t... 8 checking size of size_t... 8 checking size of pid_t... 8 checking size of uintptr_t... 8 checking for long double... yes checking size of long double... 16 checking size of _Bool... 1 checking size of off_t... 8 checking whether to enable large file support... yes checking size of time_t... 8 checking for pthread_t... checking for --enable-framework... no checking for dyld... no checking the extension of shared libraries... .dll checking LDSHARED... $(CC) -shared -Wl,--enable-auto-image-base checking CCSHARED... checking LINKFORSHARED... checking CFLAGSFORSHARED... $(CCSHARED) checking SHLIBS... $(LIBS) checking for sendfile in -lsendfile... no checking for dlopen in -ldl... (cached) no checking for shl_load in -ldld... no checking uuid/uuid.h usability... no checking uuid/uuid.h presence... no checking for uuid/uuid.h... no checking uuid.h usability... no checking uuid.h presence... no checking for uuid.h... no checking for uuid_generate_time_safe... no checking for uuid_create... no checking for uuid_enc_be... no checking aligned memory access is required... yes checking for --with-hash-algorithm... default checking for --with-address-sanitizer... no checking for --with-memory-sanitizer... no checking for --with-undefined-behavior-sanitizer... no checking for t_open in -lnsl... no checking for socket in -lsocket... no checking for --with-libs... no ../configure: line 10919: PKG_PROG_PKG_CONFIG: command not found checking for --with-system-expat... no checking for --with-system-ffi... yes checking for --with-system-libmpdec... no checking for --with-decimal-contextvar... yes checking for --enable-loadable-sqlite-extensions... no checking for --with-tcltk-includes... default checking for --with-tcltk-libs... default checking for --with-dbmliborder... checking if --enable-ipv6 is specified... no checking for CAN_RAW_FD_FRAMES... no checking for --with-doc-strings... yes checking for --with-pymalloc... yes checking for --with-c-locale-coercion... no checking for --with-valgrind... no checking for --with-dtrace... no checking for dlopen... no checking DYNLOADFILE... dynload_win.o checking MACHDEP_OBJS... PC/dl_nt.o checking for alarm... (cached) ignore checking for accept4... no checking for setitimer... no checking for getitimer... no checking for bind_textdomain_codeset... no checking for chown... no checking for clock... yes checking for confstr... no checking for copy_file_range... no checking for ctermid... no checking for dup3... no checking for execv... yes checking for explicit_bzero... no checking for explicit_memset... no checking for faccessat... no checking for fchmod... no checking for fchmodat... no checking for fchown... no checking for fchownat... no checking for fdwalk... no checking for fexecve... no checking for fdopendir... no checking for fork... no checking for fpathconf... no checking for fstatat... no checking for ftime... yes checking for ftruncate... (cached) ignore checking for futimesat... no checking for futimens... no checking for futimes... no checking for gai_strerror... no checking for getentropy... no checking for getgrgid_r... no checking for getgrnam_r... no checking for getgrouplist... no checking for getgroups... no checking for getlogin... yes checking for getloadavg... no checking for getpeername... (cached) yes checking for getpgid... no checking for getpid... yes checking for getpriority... no checking for getresuid... no checking for getresgid... no checking for getpwent... no checking for getpwnam_r... no checking for getpwuid_r... no checking for getspnam... no checking for getspent... no checking for getsid... no checking for getwd... no checking for if_nameindex... no checking for initgroups... no checking for kill... no checking for killpg... no checking for lchown... no checking for lockf... no checking for linkat... no checking for lstat... no checking for lutimes... no checking for mmap... no checking for memrchr... no checking for mbrtowc... yes checking for mkdirat... no checking for mkfifo... no checking for madvise... no checking for mkfifoat... no checking for mknod... no checking for mknodat... no checking for mktime... no checking for mremap... no checking for nice... no checking for openat... no checking for pathconf... no checking for pause... no checking for pipe2... no checking for plock... no checking for poll... no checking for posix_fallocate... no checking for posix_fadvise... no checking for posix_spawn... no checking for posix_spawnp... no checking for pread... no checking for preadv... no checking for preadv2... no checking for pthread_condattr_setclock... no checking for pthread_init... no checking for pthread_kill... (cached) skip checking for putenv... yes checking for pwrite... no checking for pwritev... no checking for pwritev2... no checking for readlink... no checking for readlinkat... no checking for readv... no checking for realpath... no checking for renameat... no checking for sem_open... (cached) skip checking for sem_timedwait... no checking for sem_getvalue... no checking for sem_unlink... no checking for sendfile... no checking for setegid... no checking for seteuid... no checking for setgid... no checking for sethostname... no checking for setlocale... yes checking for setregid... no checking for setreuid... no checking for setresuid... no checking for setresgid... no checking for setsid... no checking for setpgid... no checking for setpgrp... no checking for setpriority... no checking for setuid... no checking for setvbuf... yes checking for sched_get_priority_max... no checking for sched_setaffinity... no checking for sched_setscheduler... (cached) skip checking for sched_setparam... no checking for sched_rr_get_interval... no checking for sigaction... no checking for sigaltstack... no checking for sigfillset... no checking for siginterrupt... no checking for sigpending... no checking for sigrelse... no checking for sigtimedwait... no checking for sigwait... no checking for sigwaitinfo... no checking for snprintf... yes checking for strftime... yes checking for strlcpy... no checking for strsignal... no checking for symlinkat... no checking for sync... no checking for sysconf... no checking for tcgetpgrp... no checking for tcsetpgrp... no checking for tempnam... yes checking for timegm... no checking for times... no checking for tmpfile... yes checking for tmpnam... yes checking for tmpnam_r... no checking for truncate... (cached) ignore checking for uname... no checking for unlinkat... no checking for unsetenv... no checking for utimensat... no checking for utimes... no checking for waitid... no checking for waitpid... no checking for wait3... no checking for wait4... no checking for wcscoll... yes checking for wcsftime... yes checking for wcsxfrm... yes checking for wmemcmp... yes checking for writev... no checking for _getpty... no checking for rtpSpawn... no checking for lchmod... no checking whether dirfd is declared... no checking for chroot... no checking for link... no checking for symlink... no checking for fchdir... no checking for fsync... no checking for fdatasync... no checking for epoll... no checking for epoll_create1... no checking for kqueue... no checking for prlimit... no checking for memfd_create... no checking for ctermid_r... no checking for flock declaration... no checking for getpagesize... no checking for broken unsetenv... no checking for true... true checking for inet_aton in -lc... no checking for inet_aton in -lresolv... no checking for chflags... cross checking for chflags... no checking for lchflags... cross checking for lchflags... no checking for inflateCopy in -lz... no checking for hstrerror... no checking for inet_aton... no checking for inet_pton... yes checking for setgroups... no checking for openpty... no checking for openpty in -lutil... no checking for openpty in -lbsd... no checking for forkpty... no checking for forkpty in -lutil... no checking for forkpty in -lbsd... no checking for fseek64... no checking for fseeko... yes checking for fstatvfs... no checking for ftell64... no checking for ftello... yes checking for statvfs... no checking for dup2... yes checking for strdup... yes checking for getpgrp... no checking for setpgrp... (cached) no checking for gettimeofday... yes checking for library containing crypt... no checking for library containing crypt_r... no checking for crypt_r... no checking for clock_gettime... no checking for clock_gettime in -lrt... no checking for clock_getres... no checking for clock_getres in -lrt... no checking for clock_settime... no checking for clock_settime in -lrt... no checking for major... no checking for getaddrinfo... no checking for getnameinfo... no checking whether time.h and sys/time.h may both be included... yes checking whether struct tm is in sys/time.h or time.h... time.h checking for struct tm.tm_zone... no checking whether tzname is declared... yes checking for tzname... yes checking for struct stat.st_rdev... yes checking for struct stat.st_blksize... no checking for struct stat.st_flags... no checking for struct stat.st_gen... no checking for struct stat.st_birthtime... no checking for struct stat.st_blocks... no checking for struct passwd.pw_gecos... no checking for struct passwd.pw_passwd... no checking for siginfo_t.si_band... no checking for time.h that defines altzone... no checking whether sys/select.h and sys/time.h may both be included... no checking ws2tcpip.h usability... yes checking ws2tcpip.h presence... yes checking for ws2tcpip.h... yes checking for addrinfo... yes checking for sockaddr_storage... yes checking for sockaddr_alg... no checking whether char is unsigned... no checking for an ANSI C-conforming const... yes checking for working signed char... yes checking for prototypes... yes checking for variable length prototypes and stdarg.h... yes checking for socketpair... no checking if sockaddr has sa_len member... no checking for gethostbyname_r... no checking for gethostbyname... no checking for __fpu_control... no checking for __fpu_control in -lieee... no checking for --with-libm=STRING... default LIBM="-lm" checking for --with-libc=STRING... default LIBC="" checking for x64 gcc inline assembler... yes checking whether float word ordering is bigendian... no checking whether we can use gcc inline assembler to get and set x87 control word... yes checking whether we can use gcc inline assembler to get and set mc68881 fpcr... no checking for x87-style double rounding... no checking for acosh... yes checking for asinh... yes checking for atanh... yes checking for copysign... yes checking for erf... yes checking for erfc... yes checking for expm1... yes checking for finite... yes checking for gamma... no checking for hypot... yes checking for lgamma... yes checking for log1p... yes checking for log2... yes checking for round... yes checking for tgamma... yes checking whether isinf is declared... yes checking whether isnan is declared... yes checking whether isfinite is declared... yes checking whether POSIX semaphores are enabled... (cached) no checking for broken sem_getvalue... (cached) skip checking whether RTLD_LAZY is declared... (cached) no checking whether RTLD_NOW is declared... (cached) no checking whether RTLD_GLOBAL is declared... (cached) no checking whether RTLD_LOCAL is declared... (cached) no checking whether RTLD_NODELETE is declared... (cached) no checking whether RTLD_NOLOAD is declared... (cached) no checking whether RTLD_DEEPBIND is declared... (cached) no checking whether RTLD_MEMBER is declared... (cached) no checking digit size for Python's longs... no value specified checking wchar.h usability... yes checking wchar.h presence... yes checking for wchar.h... yes checking size of wchar_t... 2 checking for UCS-4 tcl... no checking whether wchar_t is signed... (cached) no checking whether wchar_t is usable... yes checking whether byte ordering is bigendian... no checking ABIFLAGS... checking SOABI... cpython-38 checking LDVERSION... $(VERSION)$(ABIFLAGS) checking whether right shift extends the sign bit... yes checking for getc_unlocked() and friends... no checking how to link readline libs... none checking for rl_pre_input_hook in -lreadline... no checking for rl_completion_display_matches_hook in -lreadline... no checking for rl_resize_terminal in -lreadline... no checking for rl_completion_matches in -lreadline... no checking for append_history in -lreadline... no checking for broken nice()... no checking for broken poll()... no checking for working tzset()... (cached) no checking for tv_nsec in struct stat... no checking for tv_nsec2 in struct stat... no checking curses.h usability... no checking curses.h presence... no checking for curses.h... no checking ncurses.h usability... no checking ncurses.h presence... no checking for ncurses.h... no checking for term.h... no checking whether mvwdelch is an expression... no checking whether WINDOW has _flags... no checking for is_pad... no checking for is_term_resized... no checking for resize_term... no checking for resizeterm... no checking for immedok... no checking for syncok... no checking for wchgat... no checking for filter... no checking for has_key... no checking for typeahead... no checking for use_env... no configure: checking for device files checking for /dev/ptmx... (cached) ignore checking for /dev/ptc... (cached) no checking for %zd printf() format support... (cached) no checking for socklen_t... yes checking for broken mbstowcs... no checking for --with-computed-gotos... no value specified checking whether x86_64-w64-mingw32-gcc supports computed gotos... no checking for build directories... done checking for -O2... yes checking for glibc _FORTIFY_SOURCE/memmove bug... undefined checking for gcc ipa-pure-const bug... undefined checking for stdatomic.h... yes checking for GCC >= 4.7 __atomic builtins... yes checking for ensurepip... no checking if the dirent structure of a d_type field... no checking for the Linux getrandom() syscall... no checking for the getrandom() function... no checking for library containing shm_open... no checking for sys/mman.h... (cached) no checking for shm_open... no checking for shm_unlink... no checking for x86_64-w64-mingw32-pkg-config... no checking for pkg-config... no checking for openssl/ssl.h in /usr/local/ssl... no checking for openssl/ssl.h in /usr/lib/ssl... no checking for openssl/ssl.h in /usr/ssl... no checking for openssl/ssl.h in /usr/pkg... no checking for openssl/ssl.h in /usr/local... no checking for openssl/ssl.h in /usr... no checking whether compiling and linking against OpenSSL works... no checking for --with-ssl-default-suites... python configure: creating ./config.status config.status: creating Makefile.pre config.status: creating Modules/Setup.config config.status: creating Misc/python.pc config.status: creating Misc/python-embed.pc config.status: creating Misc/python-config.sh config.status: creating Modules/ld_so_aix config.status: creating pyconfig.h creating Modules/Setup.local creating Makefile If you want a release build with all stable optimizations active (PGO, etc), please run ./configure --enable-optimizations ```

(gcc symlinked to clang, c++ symlinked to clang++) You'll have to remove PC/pyconfig.h, or else the compiler will use the wrong config header. @mstorsjo llvm-readelf for the host is required to build Python, can we build it? For now I'm gonna use binutils readelf

There may be a build script somewhere in the MSYS2 repository.

Take a look at the PKGBUILD file, that's the build script

but someone could test lldb/python in parallel to shorten our development time

The prebuilt LLVM for Windows includes LLDB compiled with Python, we can use that.

mstorsjo commented 3 years ago

@mstorsjo llvm-readelf for the host is required to build Python, can we build it? For now I'm gonna use binutils readelf

Sure, it should be trivial to add, should be enough to add it to the existing list of tools to install in build-llvm.sh and the list of tools to keep in strip-llvm.sh. For existing installs, just add a symlink to llvm-readobj - they're the same tool, but taking different options depending on the tool name.

Where is it needed - is -readelf used for the cross compiled objects/executables? (It sounds a bit odd to use an -elf tool for coff, but maybe it still supports what's needed?)

longnguyen2004 commented 3 years ago

It sounds a bit odd to use an -elf tool for coff

Maybe because binutils doesn't have a generic readobj like LLVM, so the mingw-w64 folks hacked up readelf to accept COFF. This is just my speculation, but that's probably the case.

mstorsjo commented 3 years ago

It sounds a bit odd to use an -elf tool for coff

Maybe because binutils doesn't have a generic readobj like LLVM, so the mingw-w64 folks hacked up readelf to accept COFF. This is just my speculation, but that's probably the case.

Ok, but it's used like -readelf? In that case, install-wrapper.sh also needs a bit of additions.

longnguyen2004 commented 3 years ago

Yeah I figured it would be used like -readelf Also @RussellHaley I successfully cross-compiled the Python core from WSL, using the MSYS2 patches. I can guide you through the procedure.

RussellHaley commented 3 years ago

I contacted the lilypond team and they gave up trying to cross compile. They are taking a binary from the python project and embedding that in their application. From the response email:

If you succeed in cross-compiling Python 3 for mingw, please let me /
us know, that could be interesting for the future.
longnguyen2004 commented 3 years ago

@RussellHaley Currently building the extensions fails, because distutils assumes we're using GCC and ld. I just patched get_versions to return a fixed version for the time being. As for the Python core, it builds successfully without any errors. This is what i did.

  1. Clone cpython

    git clone --depth 1 https://github.com/python/cpython -b v3.8.7
  2. Get the patches from MSYS2

    git init python-patches
    cd python-patches
    git remote add origin https://github.com/msys2/MINGW-packages
    git sparse-checkout init --cone
    git sparse-checkout set mingw-w64-python # we only need mingw-w64-python
    git pull origin master # TODO: Change this to a specific commit
    cd ..
  3. Patch cpython

    cd cpython
    cat ../python-patches/mingw-w64-python/*.patch | patch -p1
    autoreconf -fi # IMPORTANT! This regenerates the configure script
    cd ..
  4. configure and make

    
    cd cpython
    rm -f PC/pyconfig.h # We use pyconfig.h from autotools

mkdir build && cd build

Taken from MSYS2 PKGBUILD

export ac_cv_working_tzset=no export ac_cv_header_dlfcn_h=no export ac_cv_lib_dl_dlopen=no export ac_cv_have_decl_RTLD_GLOBAL=no export ac_cv_have_decl_RTLD_LAZY=no export ac_cv_have_decl_RTLD_LOCAL=no export ac_cv_have_decl_RTLD_NOW=no export ac_cv_have_decl_RTLD_DEEPBIND=no export ac_cv_have_decl_RTLD_MEMBER=no export ac_cv_have_decl_RTLD_NODELETE=no export ac_cv_have_decl_RTLD_NOLOAD=no

export CC=x86_64-w64-mingw32-clang export CXX=x86_64-w64-mingw32-clang++ ../configure \ CFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601 -DNDEBUG -I../PC -Wno-ignored-attributes" \ CXXFLAGS=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601 -DNDEBUG -I../PC -Wno-ignored-attributes" \ --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 \ --enable-shared --with-nt-threads --without-ensurepip --without-c-locale-coercion

make -j4

longnguyen2004 commented 3 years ago
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel
_dbm                  _gdbm                 _hashlib
_lzma                 _sqlite3              _ssl
_tkinter              _uuid                 nis
ossaudiodev           readline              spwd
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                time

Failed to build these modules:
_crypt                _ctypes               _ctypes_test
_multiprocessing      _posixsubprocess      _socket
_testinternalcapi     fcntl                 grp
mmap                  pwd                   resource
select                syslog                termios

@mstorsjo @RussellHaley @cristianadam Are there any modules in this list that are required by LLDB/Qt Creator/KDevelop?

RussellHaley commented 3 years ago

Thanks @longnguyen2004, @mstorsjo. I appreciate having such patient teachers. :-)

longnguyen2004 commented 3 years ago

I'm just a high school student, but you get the point :) Most of the failed modules are Unix modules, so they're not that important. However, _ctypes, _multiprocessing and _testinternalcapi require a closer look.

Some other compiler flags that might be useful: -Wno-ignored-attributes: Suppress error about gnu_printf

@RussellHaley If you can add support for clang in distutils, I'd really appreciate it :)

longnguyen2004 commented 3 years ago

After some more patching, I managed to get most of the modules built, except for _ctypes Additional patch to setup.py:

--- cpython-msys2/setup.py      2021-01-24 12:00:01.170000000 +0700
+++ cpython/setup.py    2021-01-24 10:50:57.710000000 +0700
@@ -51,7 +51,7 @@

 CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ)
 HOST_PLATFORM = get_platform()
-MS_WINDOWS = (HOST_PLATFORM == 'win32')
+MS_WINDOWS = (HOST_PLATFORM == 'win32' or HOST_PLATFORM == 'mingw')
 CYGWIN = (HOST_PLATFORM == 'cygwin')
 MACOS = (HOST_PLATFORM == 'darwin')
 AIX = (HOST_PLATFORM.startswith('aix'))

Patch to Lib/distutils/cygwinccompiler.py:

--- cpython-msys2/Lib/distutils/cygwinccompiler.py      2021-01-24 12:00:01.150000000 +0700
+++ cpython/Lib/distutils/cygwinccompiler.py    2021-01-24 10:26:35.300000000 +0700
@@ -426,6 +426,8 @@
     If not possible it returns None for it.
     """
     gcc = os.environ.get('CC') or 'gcc'
+    if ('clang' in gcc):
+        return ('10.0.0', '3.0.0', '10.0.0') # Return a generic version string
     ld = 'ld'
     out = Popen(gcc+' --print-prog-name ld', shell=True, stdout=PIPE).stdout
     try:
@@ -439,5 +441,6 @@

 def is_cygwingcc():
     '''Try to determine if the gcc that would be used is from cygwin.'''
-    out_string = check_output(['gcc', '-dumpmachine'])
+    gcc = os.environ.get('CC') or 'gcc'
+    out_string = check_output([gcc, '-dumpmachine'])
     return out_string.strip().endswith(b'cygwin')

After those patches, the Python build succeed with this message

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _crypt                _curses
_curses_panel         _dbm                  _gdbm
_hashlib              _lzma                 _posixsubprocess
_sqlite3              _ssl                  _tkinter
_uuid                 fcntl                 grp
nis                   ossaudiodev           pwd
readline              resource              spwd
syslog                termios               zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                msvcrt
time

Failed to build these modules:
_ctypes
RussellHaley commented 3 years ago

I'm just a high school student, but you get the point :)

Yes, I know how old you are you little whipper-snapper! I was trying to accept being whipped by a Vietnamese high school student as graciously as possible.

Most of the failed modules are Unix modules, so they're not that important. However, _ctypes, _multiprocessing and _testinternalcapi require a closer look.

Some other compiler flags that might be useful: -Wno-ignored-attributes: Suppress error about gnu_printf

@RussellHaley If you can add support for clang in distutils, I'd really appreciate it :)

I'm not really sure what that means? Let me get lldb + python +lldm-mi put together with all the patches (I may have additional patches as well). You can school me again later on distutils. Darn kids these days... :-P

RussellHaley commented 3 years ago
cd cpython
patch -p1 < ../python-patches/mingw-w64-python/*.patch
osboxes@osboxes:~/Python-3.8.7$ patch -p1 < ../git/MINGW-packages/mingw-w64-python/*.patch
bash: ../git/MINGW-packages/mingw-w64-python/*.patch: ambiguous redirect

This is why I had to use a "bigpatchfile". What am I doing wrong?

RussellHaley commented 3 years ago

Patch to Lib/distutils/cygwinccompiler.py:

@longnguyen2004: Ah, yes, of course. I will also add/patch clang.

longnguyen2004 commented 3 years ago

What am I doing wrong?

Probably because I'm using zsh, which is a bit smarter than bash :)

Patch to Lib/distutils/cygwinccompiler.py:

This is a patch to distutils, to work around the lack of support for clang. I'm thinking of a better way to do this, instead of the hardcoded version tuple I put in there.

RussellHaley commented 3 years ago

What am I doing wrong?

Probably because I'm using zsh, which is a bit smarter than bash :)

That makes sense then because I was sure I had seen that done in a script on FreeBSD!

Patch to Lib/distutils/cygwinccompiler.py:

This is a patch to distutils, to work around the lack of support for clang. I'm thinking of a better way to do this, instead of the hardcoded version tuple I put in there.

I finally got python3.8.exe to work by setting the PYTHONHOME envirnoment variable. I now get some errors due to missing readline support:

C:\Users\russh\python-3.8.7-win32\bin> .\python3.8.exe
Python 3.8.7 (default, Jan 26 2021, 01:50:57)
[Clang 11.0.0 (https://github.com/llvm/llvm-project.git 176249bd6732a8044d45709 on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\Users\russh\python-3.8.7-win32\lib\python3.8\site.py", line 412, in register_readline
    import readline
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\readline.py", line 6, in <module>
    from pyreadline.rlmain import Readline
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\pyreadline\__init__.py", line 12, in <module>
    from . import logger, clipboard, lineeditor, modes, console
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\pyreadline\modes\__init__.py", line 3, in <module>
    from . import emacs, notemacs, vi
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\pyreadline\modes\emacs.py", line 16, in <module>
    from . import basemode
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\pyreadline\modes\basemode.py", line 14, in <module>
    from   pyreadline.keysyms.common import make_KeyPress_from_keydescr
  File "C:\Users\russh\AppData\Roaming\Python\Python38\site-packages\pyreadline\keysyms\__init__.py", line 23, in <module>
    raise ImportError("Could not import keysym for local pythonversion", x)
NameError: name 'x' is not defined
>>>

That also makes sense. MSYS2 would have readline! I will persist because the error may be irrelevant, but it does indicate there is further patching necessary for python to run properly on windows.

longnguyen2004 commented 3 years ago

Hmm that's weird, I didn't build Python with readline and it still runs fine (in WSL that is). I'm gonna get it over to Windows and test it out.

RussellHaley commented 3 years ago

lldb is sooo close:

lld-link: error: /home/osboxes/Python-3.8.7/build/deploy/usr/local/bin/libpython3.8.dll: bad file type. Did you specify a DLL instead of an import library?
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
[908/1100] Building CXX object tools/llvm-mca/CMakeFiles/llvm-mca.dir/Views/SchedulerStatistics.cpp.obj
ninja: build stopped: subcommand failed.
osboxes@osboxes ~/g/llvm-mingw (master) [1]>

I searched my python build directory and it didn't have a lib file:

osboxes@osboxes ~/P/build> pwd
/home/osboxes/Python-3.8.7/build
osboxes@osboxes ~/P/build> find . -type f -iname "*.lib"
osboxes@osboxes ~/P/build> 

Is there a way to generate one, or force one during a build?

longnguyen2004 commented 3 years ago

I searched my python build directory and it didn't have a lib file:

.lib is for MSVC, mingw import libraries are .a and .dll.a

RussellHaley commented 3 years ago

Hmm how can I propagate my environment variables to sudo? I'm having problems with sudo make install because CC and CXX aren't set in root

sudo -E might work?

RussellHaley commented 3 years ago

Woot woot! LLVM finished building and I saw it install a bunch of lldb python files. Woot woot!

Okay, lunches...

longnguyen2004 commented 3 years ago

Seems like we have a winner! I found out about sudo -E a few minutes after my comment, should have searched for it sooner. Ah well... Anyway now it's time to write the build scripts.

If you have problems with your Python build, you can ask me for a fresh build

HP@DESKTOP-194TAE9  G:\python-mingw  gci

    Directory: G:\python-mingw

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           27/1/2021    13:09                bin
d----           27/1/2021    12:56                include
d----           27/1/2021    12:56                lib
d----           27/1/2021    13:09                share

 HP@DESKTOP-194TAE9  G:\python-mingw  cd bin
 HP@DESKTOP-194TAE9  G:\..\bin  ./python3.8
Python 3.8.7 (tags/v3.8.7-dirty:6503f05, Jan 27 2021, 12:50:41)
[Clang 11.0.0 (https://github.com/llvm/llvm-project.git 176249bd6732a8044d45709 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
longnguyen2004 commented 3 years ago

@mstorsjo Can you do a build containing readelf? This is the last piece I need to go full LLVM.

mstorsjo commented 3 years ago

@mstorsjo Can you do a build containing readelf? This is the last piece I need to go full LLVM.

What kind of build do you want - a docker image, ubuntu x86_64 tar.xz or something else?

longnguyen2004 commented 3 years ago

Preferably Ubuntu .tar.gz, and maybe a native Windows build as well.

mstorsjo commented 3 years ago

Preferably Ubuntu .tar.gz, and maybe a native Windows build as well.

Ok, I can have them done in 6 hours or so

RussellHaley commented 3 years ago

I have a 32 core FreeBSD server with 78 GB of ram. I can create a "jail" (freebsd container) if anyone needs some horsepower.

mstorsjo commented 3 years ago

Preferably Ubuntu .tar.gz, and maybe a native Windows build as well.

https://martin.st/temp/llvm-mingw-11-readelf-ubuntu18.04-x86_64.tar.xz https://martin.st/temp/llvm-mingw-11-readelf-x86_64.zip

longnguyen2004 commented 3 years ago

@RussellHaley I'm working to get my setup.py patches to MSYS2 (https://github.com/msys2/MINGW-packages/pull/7819), and I'll also try to get proper Clang support into upstream distutils (or ask someone to do it), instead of this clutch that I did.

longnguyen2004 commented 3 years ago

And we're merged! Now we just need to think about adding Clang mingw support to distutils I already have a crude implementation ready, but we'll also have to write test cases for it, which I have no clues how to do. To be honest though, most of it was copy-pasted from the current CygwinCCompiler class, which already have test cases, so it might not be required? I'm gonna try submitting it anyway and see what they will say about it.

RussellHaley commented 3 years ago

Great news! Here is where I am at:

Attempted to build lldb-mi. The cmake script finds the *.cmake output files in the install directory but could not find library? I hard coded library path. Received include errors: Added needed directories to target_include_directories. Some of the missing header files are from the source directory, others are "configuration headers" in the build directories. Linking has errors in mingw math.h libraries. Suspicious, and I have no idea where to go from here ...

osboxes@osboxes ~/g/lldb-mi (master)> git diff
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 38bd1b9..52c0287 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,8 +85,19 @@ else()
   find_library(lib_lldb NAMES lldb liblldb HINTS ${LLVM_LIBRARY_DIRS})
 endif()

-find_library(lib_llvm_shared LLVM HINTS ${LLVM_LIBRARY_DIRS})
+set(LLVM_SOURCE_DIR "/home/osboxes/git/llvm-mingw/llvm-project/")
+target_include_directories(lldb-mi PRIVATE 
+"${LLVM_SOURCE_DIR}/llvm/include" 
+"${LLVM_SOURCE_DIR}/lldb/include"
+"${LLVM_SOURCE_DIR}/llvm/build-x86_64-w64-mingw32/tools/lldb/include"
+"${LLVM_SOURCE_DIR}/llvm/build-x86_64-w64-mingw32/include/"
+)
+
+#~ set(LLVM_LIBRARY_DIRS "~/llvm-mingw-w64-x86_64/bin")
+#~ message(STATUS "WHO DAT: ${LLVM_LIBRARY_DIRS}")
+#~ find_library(lib_llvm_shared LLVM HINTS ${LLVM_LIBRARY_DIRS})

+set(lib_llvm_shared "/home/osboxes/llvm-mingw-w64-x86_64/bin/liblldb.dll")
 if (lib_llvm_shared)
   set(lib_llvm "${lib_llvm_shared}")
 else()
osboxes@osboxes ~/g/lldb-mi (master)> 

I used ninja -k 0 , which keeps building files until it exhausts possibilities.

osboxes@osboxes ~/g/l/build-x86_64-w64 (master)> cmake -DCMAKE_TOOLCHAIN_FILE=~/x86_64-w64-mingw32.cmake -DCMAKE_PREFIX_PATH=~/llvm-mingw-w64-x86_64  -GNinja ..
-- The C compiler identification is Clang 11.0.0
-- The CXX compiler identification is Clang 11.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LLVM 11.0.0
-- Using LLVMConfig.cmake in: /home/osboxes/llvm-mingw-w64-x86_64/lib/cmake/llvm
-- Performing Test LLVM_LIBSTDCXX_MIN
-- Performing Test LLVM_LIBSTDCXX_MIN - Success
-- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
-- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Success
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Success
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/osboxes/git/lldb-mi/build-x86_64-w64
osboxes@osboxes ~/g/l/build-x86_64-w64 (master)> ninja -k 0
[17/75] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdCmdData.cpp.obj
FAILED: src/CMakeFiles/lldb-mi.dir/MICmdCmdData.cpp.obj 
/home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-g++ -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS="64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/osboxes/llvm-mingw-w64-x86_64/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/include -I/home/osboxes/git/llvm-mingw/llvm-project/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/tools/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/include -Wa,-mbig-obj -Werror=date-time -Werror=unguarded-availability-new -w -fno-exceptions -std=gnu++14 -MD -MT src/CMakeFiles/lldb-mi.dir/MICmdCmdData.cpp.obj -MF src/CMakeFiles/lldb-mi.dir/MICmdCmdData.cpp.obj.d -o src/CMakeFiles/lldb-mi.dir/MICmdCmdData.cpp.obj -c ../src/MICmdCmdData.cpp
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:597:22: note: '__signbit' declared here
  extern int __cdecl __signbit (double);
                     ^
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:399:22: note: '__fpclassify' declared here
  extern int __cdecl __fpclassify (double);
                     ^
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace; did you mean '_isnan'?
using ::isnan;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:294:23: note: '_isnan' declared here
  _CRTIMP int __cdecl _isnan (double);
                      ^
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MICmdCmdData.cpp:26:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
[33/75] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdCmdSymbol.cpp.obj
FAILED: src/CMakeFiles/lldb-mi.dir/MICmdCmdSymbol.cpp.obj 
/home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-g++ -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS="64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/osboxes/llvm-mingw-w64-x86_64/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/include -I/home/osboxes/git/llvm-mingw/llvm-project/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/tools/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/include -Wa,-mbig-obj -Werror=date-time -Werror=unguarded-availability-new -w -fno-exceptions -std=gnu++14 -MD -MT src/CMakeFiles/lldb-mi.dir/MICmdCmdSymbol.cpp.obj -MF src/CMakeFiles/lldb-mi.dir/MICmdCmdSymbol.cpp.obj.d -o src/CMakeFiles/lldb-mi.dir/MICmdCmdSymbol.cpp.obj -c ../src/MICmdCmdSymbol.cpp
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:597:22: note: '__signbit' declared here
  extern int __cdecl __signbit (double);
                     ^
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:399:22: note: '__fpclassify' declared here
  extern int __cdecl __fpclassify (double);
                     ^
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace; did you mean '_isnan'?
using ::isnan;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:294:23: note: '_isnan' declared here
  _CRTIMP int __cdecl _isnan (double);
                      ^
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MICmdCmdSymbol.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
[66/75] Building CXX object src/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj
FAILED: src/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj 
/home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-g++ -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS="64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/osboxes/llvm-mingw-w64-x86_64/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/include -I/home/osboxes/git/llvm-mingw/llvm-project/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/tools/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/include -Wa,-mbig-obj -Werror=date-time -Werror=unguarded-availability-new -w -fno-exceptions -std=gnu++14 -MD -MT src/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj -MF src/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj.d -o src/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj -c ../src/MIDriverMain.cpp
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:597:22: note: '__signbit' declared here
  extern int __cdecl __signbit (double);
                     ^
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:399:22: note: '__fpclassify' declared here
  extern int __cdecl __fpclassify (double);
                     ^
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace; did you mean '_isnan'?
using ::isnan;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:294:23: note: '_isnan' declared here
  _CRTIMP int __cdecl _isnan (double);
                      ^
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MIDriverMain.cpp:31:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
[71/75] Building CXX object src/CMakeFiles/lldb-mi.dir/MIUtilFileStd.cpp.obj
FAILED: src/CMakeFiles/lldb-mi.dir/MIUtilFileStd.cpp.obj 
/home/osboxes/llvm-mingw-host/bin/x86_64-w64-mingw32-g++ -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS="64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/osboxes/llvm-mingw-w64-x86_64/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/include -I/home/osboxes/git/llvm-mingw/llvm-project/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/tools/lldb/include -I/home/osboxes/git/llvm-mingw/llvm-project/llvm/build-x86_64-w64-mingw32/include -Wa,-mbig-obj -Werror=date-time -Werror=unguarded-availability-new -w -fno-exceptions -std=gnu++14 -MD -MT src/CMakeFiles/lldb-mi.dir/MIUtilFileStd.cpp.obj -MF src/CMakeFiles/lldb-mi.dir/MIUtilFileStd.cpp.obj.d -o src/CMakeFiles/lldb-mi.dir/MIUtilFileStd.cpp.obj -c ../src/MIUtilFileStd.cpp
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:597:22: note: '__signbit' declared here
  extern int __cdecl __signbit (double);
                     ^
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:399:22: note: '__fpclassify' declared here
  extern int __cdecl __fpclassify (double);
                     ^
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace; did you mean '_isnan'?
using ::isnan;
      ~~^
/home/osboxes/llvm-mingw-w64-x86_64/include/math.h:294:23: note: '_isnan' declared here
  _CRTIMP int __cdecl _isnan (double);
                      ^
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ../src/MIUtilFileStd.cpp:18:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/FileSystem.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Host/File.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/Utility/IOObject.h:16:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private.h:15:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:13:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/FormatProviders.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/Twine.h:12:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/ADT/SmallVector.h:20:
In file included from /home/osboxes/git/llvm-mingw/llvm-project/llvm/include/llvm/Support/MathExtras.h:20:
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/home/osboxes/llvm-mingw-host/x86_64-w64-mingw32/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
[74/75] Building CXX object src/CMakeFiles/lldb-mi.dir/MIUtilString.cpp.obj
ninja: build stopped: cannot make progress due to previous errors.
osboxes@osboxes ~/g/l/build-x86_64-w64 (master) [1]> 
RussellHaley commented 3 years ago

Hmmm. I am just trying to get the debugger working in VS code or on the command line. I found a post where somebody had entered "script mode" in lldb so I started it from the command line and tried.Note the hard coded unix path that has been tacked onto the end of everything? ha ha!

C:\Users\russh\lldb-vscode-test> lldb.exe
(lldb) script
Python path configuration:
  PYTHONHOME = 'C:\Users\russh\VirtualBox VMs\Ubuntu20\shared\llvm-mingw-x86_64-win32\bin/home/osboxes/python-cmake-install/bin'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin\\lldb.exe'
  sys.base_prefix = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin'
  sys.base_exec_prefix = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin'
  sys.executable = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin\\lldb.exe'
  sys.prefix = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin'
  sys.exec_prefix = 'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin'
  sys.path = [
    'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin\\home\\osboxes\\python-cmake-install\\bin\\lib\\python38.zip',
    'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin\\lib\\python3.8',
    'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin\\lib\\python3.8',
    'C:\\Users\\russh\\VirtualBox VMs\\Ubuntu20\\shared\\llvm-mingw-x86_64-win32\\bin/home/osboxes/python-cmake-install/bin\\lib\\python3.8\\lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00004f24 (most recent call first):
<no Python frame>
C:\Users\russh\lldb-vscode-test>
longnguyen2004 commented 3 years ago

@mstorsjo Are the math functions imported from UCRT or implemented by mingw-w64? @RussellHaley Let me try building lldb and lldb-mi with my build of Python. For now, can you set PYTHONHOME to the correct path?

mstorsjo commented 3 years ago

Great news! Here is where I am at:

  • python 8.6.7 built
  • lldb built with python option enabled. The python installs with lldb/llvm
  • removed strip from the llvm-mingw build process to ensure I "get everything"

Attempted to build lldb-mi. The cmake script finds the *.cmake output files in the install directory but could not find library?

FWIW, I tried building lldb-mi earlier, and got it working pretty nicely, see https://github.com/mstorsjo/llvm-mingw/commit/e9a2f7602b02ded3aa959cd0a0143e3a19795e39 (the branch lldb-mi in this repo), but I didn't merge it, as in the end nobody said that it provided any actual benefit (yet).

Those build errors look quite odd, but I haven't tried to figure out what's going wrong in your setup.

@mstorsjo Are the math functions imported from UCRT or implemented by mingw-w64?

On x86, most math functions are provided by libmingwex.a. UCRT also provides equally functional ones - it's just a historical thing, where the ones provided by msvcrt.dll aren't C99 compliant in all aspects, at least on older versions of windows, so mingw-w64 provides their own - and making them only available for msvcrt.dll but not UCRT makes a pretty big mess in mingw-w64's Makefile.am, so it's not necessarily worth it to clean it up. For arm/aarch64, most math functions are imported from msvcrt.dll or UCRT (as the expectation is that the ones in msvcrt.dll are mostly C99 compliant at the baseline of arm based windows versions), with a small handful being provided in libmingwex.a.

longnguyen2004 commented 3 years ago

@RussellHaley I would like to borrow some CPU time, I'm too impatient to wait for the entire build :) My computer also doesn't have enough RAM anyway, so it'll most likely crash. 4-8 cores with 16GB of RAM is probably enough.

RussellHaley commented 3 years ago

@longnguyen2004 I sent you an email. 👍

RussellHaley commented 3 years ago

Great news! Here is where I am at:

  • python 8.6.7 built
  • lldb built with python option enabled. The python installs with lldb/llvm
  • removed strip from the llvm-mingw build process to ensure I "get everything"

Attempted to build lldb-mi. The cmake script finds the *.cmake output files in the install directory but could not find library?

FWIW, I tried building lldb-mi earlier, and got it working pretty nicely, see e9a2f76 (the branch lldb-mi in this repo), but I didn't merge it, as in the end nobody said that it provided any actual benefit (yet).

Thanks Martin. I'll try applying my python switch patch to the commit you provided.

Those build errors look quite odd, but I haven't tried to figure out what's going wrong in your setup.

No need: the error is behind the keyboard. (rolling of eyes)

@mstorsjo Are the math functions imported from UCRT or implemented by mingw-w64?

On x86, most math functions are provided by libmingwex.a. UCRT also provides equally functional ones - it's just a historical thing, where the ones provided by msvcrt.dll aren't C99 compliant in all aspects, at least on older versions of windows, so mingw-w64 provides their own - and making them only available for msvcrt.dll but not UCRT makes a pretty big mess in mingw-w64's Makefile.am, so it's not necessarily worth it to clean it up. For arm/aarch64, most math functions are imported from msvcrt.dll or UCRT (as the expectation is that the ones in msvcrt.dll are mostly C99 compliant at the baseline of arm based windows versions), with a small handful being provided in libmingwex.a.

longnguyen2004 commented 3 years ago

Polished my distutils patch up a bit, now it gets the compiler from the CC and CXX environment variables. This helps me avoid duplicating code. Currently testing...

RussellHaley commented 3 years ago

@longnguyen2004 I don't write any python. Are you also going to patch the _ctypes? I was able to get libffi to build for 3.6.7.

longnguyen2004 commented 3 years ago

I haven't tried building libffi yet, but I guess it would also succeed, I'm currently focusing on distutils though.

longnguyen2004 commented 3 years ago

@RussellHaley I'm getting weird link errors when building the modules. Have you stumbled across this before? @mstorsjo What could be the cause of this? If you need, I can provide you with the object files from the build.

lld-link: error: unknown file type: abstract.o
lld-link: error: unknown file type: boolobject.o
lld-link: error: unknown file type: call.o
lld-link: error: unknown file type: complexobject.o
lld-link: error: unknown file type: floatobject.o
lld-link: error: unknown file type: listobject.o
lld-link: error: unknown file type: longobject.o
lld-link: error: unknown file type: dictobject.o
lld-link: error: unknown file type: moduleobject.o
lld-link: error: unknown file type: object.o
lld-link: error: unknown file type: obmalloc.o
lld-link: error: unknown file type: tupleobject.o
lld-link: error: unknown file type: typeobject.o
lld-link: error: unknown file type: unicodeobject.o
lld-link: error: unknown file type: unicodectype.o
lld-link: error: unknown file type: context.o
lld-link: error: unknown file type: errors.o
lld-link: error: unknown file type: getargs.o
lld-link: error: unknown file type: import.o
lld-link: error: unknown file type: modsupport.o

I've checked them with llvm-readobj and they're normal x86_64 COFF object files

File: Objects/abstract.o
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit

Command line output from -v:

"/home/lnguyen/llvm-mingw-build/bin/ld.lld" -s -m i386pep --shared -Bdynamic -e DllMainCRTStartup --enable-auto-image-base -o build/lib.mingw-3.8/_decimal-cpython-38.dll -s /home/lnguyen/llvm-mingw-build/x86_64-w64-mingw32/lib/dllcrt2.o /home/lnguyen/llvm-mingw-build/x86_64-w64-mingw32/lib/crtbegin.o -L/usr/local/lib/python3.8/config-3.8 -L. -L/home/lnguyen/llvm-mingw-build/x86_64-w64-mingw32/lib -L/home/lnguyen/llvm-mingw-build/lib -L/home/lnguyen/llvm-mingw-build/x86_64-w64-mingw32/sys-root/mingw/lib -L/home/lnguyen/llvm-mingw-build/lib/clang/11.0.0/lib/windows --enable-auto-image-base build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/_decimal.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/basearith.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/constants.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/context.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/convolute.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/crt.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/difradix2.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/fnt.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/fourstep.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/io.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/memory.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/mpdecimal.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/numbertheory.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/sixstep.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/libmpdec/transpose.o build/temp.mingw-3.8/usr/home/lnguyen/llvm-mingw/cpython/Modules/_decimal/_decimal-cpython-38.def -lm -lpython3.8 -lm -lversion -lshlwapi -lmingw32 /home/lnguyen/llvm-mingw-build/lib/clang/11.0.0/lib/windows/libclang_rt.builtins-x86_64.a -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 /home/lnguyen/llvm-mingw-build/lib/clang/11.0.0/lib/windows/libclang_rt.builtins-x86_64.a -lmoldname -lmingwex -lmsvcrt -lkernel32 /home/lnguyen/llvm-mingw-build/x86_64-w64-mingw32/lib/crtend.o
longnguyen2004 commented 3 years ago

Still trying to find out where the /usr/local/lib path comes from. There was an incorrect libpython3.8.a in that directory, which messes up the linking.

longnguyen2004 commented 3 years ago

At last...I found out the culprit. It's related to patch 0920-mingw-add-LIBPL-to-library-dirs.patch, which mistakenly add the system include path to the link options, messing everything up. I'm gonna try reproducing it in WSL.

longnguyen2004 commented 3 years ago

@mstorsjo Can we defer building LLDB to build-cross-tools.sh? We have to build a separate Python and libffi for 4 architectures, and the fact that a debugger for the cross toolchain is kinda pointless, so it should be moved to build-cross-tools.sh

mstorsjo commented 3 years ago

@mstorsjo I've seen libtool using linker scripts before, but not version scripts. Do you know how it's used in libtool?

Version scripts are used for setting symbol versions, which is an ELF feature (that allows you to e.g. have multiple copies of the same symbol in a binary, for backwards binary compatibility). For COFF targets, the only thing that version scripts allow you to do is choose what symbols to export using wildcard expressions (instead of in e.g. a def file, where you have to literally list all the symbols to export).

For building libffi, just add --disable-symvers. The latest git version of libffi supports building for aarch64-w64-mingw32 too, but there's no public release with that included yet. For those build setups, you'll want to cherrypick https://github.com/libffi/libffi/commit/c06468fa6674d3783a0edb1d0fae9afc8bc28513 and https://github.com/libffi/libffi/commit/15d3ea31a53bd0e5b828c90a9f7c4285c58f73e1.

@mstorsjo Can we defer building LLDB to build-cross-tools.sh? We have to build a separate Python and libffi for 4 architectures, and the fact that a debugger for the cross toolchain is kinda pointless, so it should be moved to build-cross-tools.sh

I agree that there's not very much use for LLDB in the cross toolchain, but there is some (you can inspect crash dumps and binaries, and it's useful when developing LLDB itself).

For building a python-enabled LLDB in the cross setups, I don't see what harm it does to have it included in the native build and what you concretely would gain - you don't need to build python for the host environment anyway. It shoudl be enough to just pass the flags for enabling/locating the newly built python if we're cross building (or building natively on msys2) in build-llvm.sh. (Since 4b063063f22fdd84bae0c41195f7e96722cd97f8, we don't explicitly disable python, but just let it autodetect things, so it's enabled for the host build if it happens to be available.)

Can you clarify which bit of it that you find problematic, and maybe I can help with a better fix for how to tweak build-llvm.sh for your purposes?

longnguyen2004 commented 3 years ago

Hmm..after thinking about it, I realized we can build libffi and Python before we build LLVM (for the cross build), and let CMake auto-detect it. So build-llvm.sh can stay unmodified, and we only need a build-python.sh before that.