Thank you for your advice!
I compared the good and the bad build log and found out the lack of rule zgoarchat all. So I mentioned the difference in makefiles and it turned out that I used different revisions of gollvm. It is interesting that with gcc this problem did not appear (but in both gcc and llvm cases I got the linkage problem described below).
After that I got the next problem: cmake failed to set the SIZEOF_STRUCT_EPOLL_EVENT and STRUCT_EPOLL_EVENT_FD_OFFSET. I do not know what to do with it. So I just hardcoded them in the cmake/modules/AutoGenGo.cmake (values 12 and 4 respectively). After that, the cmake worked fine.
Then the build failed with other problem:
/home/alex/test/
gollvm/build-debug/./bin/llvm-goc -o /home/alex/test/
gollvm/build-de
bug/tools/
gollvm/
gotools/go go_.o -I /home/alex/test/
gollvm/build-debug/tools/
gollvm/
libgo -L /home/alex/test/
gollvm/build-debug/tools/
gollvm/
libgo /home/ale
x/test/
gollvm/build-debug/tools/
gollvm/
libgo/libgotool.a
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot open crtn.o: Нет такого файла или каталога
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: warning: skipping incompatible /usr/lib/libm.so while searching for m
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot find -lm
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: warning: skipping incompatible /usr/lib/libc.so while searching for c
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot find -lc
/usr/lib64/crt1.o:function _start: error: undefined reference to '__libc_start_main'
/home/alex/test/
gollvm/llvm-project/llvm/tools/
gollvm/gofrontend/
libgo/runtime/go-main.c:59: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'writev'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'syscall'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
...
That was even more weird. And also that was almost like the issue 26405 (
https://github.com/golang/go/issues/26405). I do not know the good way to solve it so I just hardcoded in the file driver/
GnuTools.cpp the following things:
cmdArgs.push_back(args.MakeArgString(toolchain().getFilePath(/usr/lib64/crt1.o)));
cmdArgs.push_back(args.MakeArgString("/usr/lib64/crti.o"));
cmdArgs.push_back(args.MakeArgString("-L/usr/lib64/"));
cmdArgs.push_back(args.MakeArgString("/usr/lib64/crtn.o"));
After that my build finished successfully.
Again, thank you for your help.