Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packages for bootstrapping Clang subsystem #2230

Merged
merged 1 commit into from
Dec 11, 2020
Merged

Conversation

mati865
Copy link
Collaborator

@mati865 mati865 commented Nov 4, 2020

Surely some of the patches are unnecessary for MSYS2 package but I included them from MINGW package so the are more "in-line".

Clang's msys target doesn't support using GCC's libstdc++ but it's not necessary for bootstrapping.
Headers and CRT use _variant=gcc so they have to built locally and uploaded (their pkgname differs if _variant=clang is chosen).

@lazka
Copy link
Member

lazka commented Nov 5, 2020

(rebased on top of master so we get more disk space in CI)

@mati865
Copy link
Collaborator Author

mati865 commented Nov 5, 2020

mingw-w64-cross-headers-git and mingw-w64-cross-crt-git have to built manually (with _variant=clang).

@mati865
Copy link
Collaborator Author

mati865 commented Nov 6, 2020

Had to fix patches a bit for dynamic linking to even succeed.

Static vs dynamic size:

Total Installed Size:    667.66 MiB
Net Upgrade Size:      -2369.18 MiB

The saving is neat but unfortunately Clang crashes when building libc++. There must be something else missing in the patches but it's a needle in a haystack.

Clang has extracted 13 MiB C++ source file that reproduces the crash so I can reliably reproduce the crash. However I have notices something weird, it doesn't crash when calling /usr/bin/clang++ through /usr/bin/gdb.
The best I could get is WinDbg dump:
clang.zip

It might be not worth the trouble though so I kept static version for now.

@mati865
Copy link
Collaborator Author

mati865 commented Nov 6, 2020

According to the stacktrace it seems to crash somewhere here: https://github.com/llvm/llvm-project/blob/176249bd6732a8044d457092ed932768724a6f06/llvm/lib/CodeGen/AsmPrinter/DIE.cpp#L214-L219 called from https://github.com/llvm/llvm-project/blob/176249bd6732a8044d457092ed932768724a6f06/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L1238

Getting debug build will be hard because of the MSYS overhead (this "minimal" release build already takes much longer than all LLVM related tools when building with MinGW).

@jeremyd2019
Copy link
Member

According to the stacktrace it seems to crash somewhere here: https://github.com/llvm/llvm-project/blob/176249bd6732a8044d457092ed932768724a6f06/llvm/lib/CodeGen/AsmPrinter/DIE.cpp#L214-L219

Actually disassembly looks suspiciously like https://github.com/llvm/llvm-project/blob/176249bd6732a8044d457092ed932768724a6f06/llvm/lib/CodeGen/AsmPrinter/DIE.cpp#L203-L212, except for some reason the initial NULL check of the while (p) loop was elided, so there was a NULL-pointer dereference. Maybe there's something in the language spec that allows the compiler to assume this cannot be NULL. I see the caller doesn't check for a NULL Die pointer other than by an assert

@mati865
Copy link
Collaborator Author

mati865 commented Nov 6, 2020

Actually disassembly looks suspiciously like llvm/llvm-project@176249b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp#L203-L212

Yeah, you are right. I looked at this code locally but posted wrong snippet.
AFAIK this cannot be null unless there is UB somewhere.

@jeremyd2019
Copy link
Member

AFAIK this cannot be null unless there is UB somewhere.

Yup, I guess the proper question would be how an Entity with a NULL DIE * got in there in the first place - it seems this code assumes that can't happen... But like you said, probably not worth spending time investigating, as this package is intended only to bootstrap a clang subsystem not many will be bothered by the size

@mati865
Copy link
Collaborator Author

mati865 commented Nov 6, 2020

WOW, this explains a lot:

mateusz@DESKTOP-mati MSYS /d/tmp
$ clang -target x86_64-w64-mingw32 -v hello.c
clang version 11.0.0 (https://github.com/mati865/msys2-packages 65a38d271ebae7d8122723b9ce8945c678aa1a1d)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -mms-bitfields -munwind-tables -target-cpu x86-64 -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/11.0.0 -internal-isystem /usr/lib/clang/11.0.0/include -internal-isystem /mingw64/x86_64-w64-mingw32/sys-root/mingw/include -internal-isystem /mingw64/x86_64-w64-mingw32/include -internal-isystem /mingw64/include -fdebug-compilation-dir /d/tmp -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fseh-exceptions -fcolor-diagnostics -faddrsig -o /tmp/hello-cd9a81.o -x c hello.c
clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target x86_64-pc-msys
ignoring nonexistent directory "/mingw64/x86_64-w64-mingw32/sys-root/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/11.0.0/include
 /mingw64/x86_64-w64-mingw32/include
 /mingw64/include
End of search list.
 "/usr/bin/ld" -m i386pep -Bdynamic -o a.exe /mingw64/x86_64-w64-mingw32/lib/crt2.o /mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0/crtbegin.o -L/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0 -L/mingw64/x86_64-w64-mingw32/lib -L/mingw64/lib -L/mingw64/x86_64-w64-mingw32/sys-root/mingw/lib /tmp/hello-cd9a81.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 /mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0/crtend.o

@mati865
Copy link
Collaborator Author

mati865 commented Nov 14, 2020

Finally fixed the build.

@lazka how do we want to build it?
a05b762 switches the variant so if we want to build it entirely on CI we will have to revert it afterward. Alternatively we can duplicate Clang version of mingw-w64-cross-headers-git and mingw-w64-cross-crt-git to separate directories to avoid shuffling _variant.

@mati865 mati865 marked this pull request as ready for review November 14, 2020 15:45
@lazka
Copy link
Member

lazka commented Nov 28, 2020

Not sure if we can do bootstrapping in CI anyway.. so having that _variant thing seems fine (although defaulting to gcc).

@lazka
Copy link
Member

lazka commented Nov 28, 2020

hm, on a second thought duplicating with different package names sounds like a good idea too.. if that works for you.

@mati865
Copy link
Collaborator Author

mati865 commented Dec 10, 2020

I've split out changes for non Clang mingw-w64 packages, hopefully CI will succeed now.

@jeremyd2019
Copy link
Member

It appears that mingw-w64-cross-clang package failed to build in msys2-autobuild: https://github.com/msys2/msys2-autobuild/runs/1540405115?check_suite_focus=true#step:14:9264

  CMake Error at /c/_/S/mingw-w64-cross-clang/src/libunwind/src/CMakeLists.txt:92 (message):
    Compiler doesn't support generation of unwind tables if exception support
    is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
    library is not supported.

I am more than a little suspicious that there was a missing (make)depends that resulted in the compiler just being broken, because it seemed like pretty much every test CMake did failed.

@mati865
Copy link
Collaborator Author

mati865 commented Dec 15, 2020

-- Detecting C compiler ABI info - failed

Yeah the compiler is broken but it worked in this PR.

Can I somehow download packages that were build by autobuild but are not yet in the repo?

@jeremyd2019
Copy link
Member

You can grab them manually from https://github.com/msys2/msys2-autobuild/releases/tag/staging-msys (and probably rename them), or use autobuild.py fetch-assets from that repo to grab all staged assets properly named.

@jeremyd2019
Copy link
Member

It looks like the packages that built are now in the repo

@jeremyd2019
Copy link
Member

Makedepends tweak in #2272

@mati865
Copy link
Collaborator Author

mati865 commented Dec 21, 2020

Thank you for looking into this, I was busy last week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants