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.

вт, 25 окт. 2022 г. в 17:04, Than McIntosh <th...@google.com>:

> Weird. I am scratching my head.
>
> At this point if I was debugging it myself on your system I would rerun
> cmake passing it the "--trace-expand" flag (which will generate giant
> volumes of output), then look in the trace to see what is happening when
> the cmake rules in question fire. You should see something like
>
> ...
> /mybuildarea/llvm-project/llvm/tools/gollvm/libgo/CMakeLists.txt(232):
>  set(zgoarchdotgo ${libgo_binroot}/zgoarch.go )
> /mybuildarea/llvm-project/llvm/tools/gollvm/libgo/CMakeLists.txt(233):
>  set(zgoarchtmp ${libgo_binroot}/zgoarch.go.tmp )
> /mybuildarea/llvm-project/llvm/tools/gollvm/libgo/CMakeLists.txt(234):
>  mkzgoarch(${goarch} ${zgoarchtmp} ${libgo_scriptroot} )
> /mybuildarea/llvm-project/llvm/tools/gollvm/cmake/modules/AutoGenGo.cmake(75):
>  file(REMOVE ${outfile} )
> /mybuildarea/llvm-project/llvm/tools/gollvm/cmake/modules/AutoGenGo.cmake(76):
>  file(WRITE ${outfile} package goarch\n\n )
> /mybuildarea/llvm-project/llvm/tools/gollvm/cmake/modules/AutoGenGo.cmake(78):
>  file(APPEND ${outfile} const GOARCH = \"${goarch}\"\n\n )
> ...
>
> If these rules are not firing, then hopefully the trace output will have
> some suggestion as to why.
>
> Thanks, Than
>
>
>
>
> On Tue, Oct 25, 2022 at 3:29 AM Alex Markin <alexan...@gmail.com> wrote:
>
>> > Do you have tools/gollvm/libgo/zgoarch.go.tmp in your build area? What
>> sort of content is in that file?
>>
>> No
>>
>> $ ninja -v -d explain tools/gollvm/libgo/zgoarch.go
>> ninja: error: unknown target 'tools/gollvm/libgo/zgoarch.go'
>>
>> $ gcc -dumpmachine
>> x86_64-pc-linux-gnu
>>
>> $ clang -dumpmachine
>> x86_64-pc-linux-gnu
>>
>> I tried manually setting up different target triples (for example the
>> same as on a working machine) but
>> it did not help.
>>
>>
>> чт, 20 окт. 2022 г. в 15:48, Than McIntosh <th...@google.com>:
>>
>>> >There is no zgoarch.go file in the build area. It seems that it was not
>>> created by the build system.
>>>
>>> I've oversimplified things a bit -- what cmake does is write
>>> out tools/gollvm/libgo/zgoarch.go.tmp, and then add a build rule
>>> for zgoarch.go that copies the *.tmp file to the *.go file if they are
>>> different.
>>>
>>> Do you have tools/gollvm/libgo/zgoarch.go.tmp in your build area? What
>>> sort of content is in that file? What happens when you do
>>>
>>>    $ ninja -v -d explain tools/gollvm/libgo/zgoarch.go
>>>
>>> You should see something like
>>>
>>> ninja explain: output tools/gollvm/libgo/zgoarch.go doesn't exist
>>> [1/1] cd /x/llvm-project/build-relwithdbg/tools/gollvm/libgo &&
>>> /usr/bin/cmake -E copy_if_different
>>> /x/llvm-project/build-relwithdbg/tools/gollvm/libgo/zgoarch.go.tmp
>>> /x/llvm-project/build-relwithdbg/tools/gollvm/libgo/zgoarch.go
>>>
>>> Thanks, Than
>>>
>>>
>>>
>>>
>>> On Wed, Oct 19, 2022 at 5:42 PM Alex Markin <alexan...@gmail.com> wrote:
>>>
>>>> There is no zgoarch.go file in the build area. It seems that it was not
>>>> created by the build system. I watched the logs and there were no lines to
>>>> create it. In the directory libgo I have only the following *go files:
>>>>
>>>> epoll.go  goroot.go  libcalls.go  syscall_arch.go  tmp-libcalls.go
>>>>
>>>> So I can't understand why the rule for zgoarch is not called. Probably
>>>> some env variable?
>>>>
>>>> ср, 19 окт. 2022 г. в 16:47, Than McIntosh <th...@google.com>:
>>>>
>>>>> Hi,
>>>>>
>>>>> Those constants are supposed to be defined in the generated file
>>>>> <buildarea>/tools/gollvm/libgo/zgoarch.go, which is written as out part of
>>>>> the gollvm build process, e.g. here
>>>>>
>>>>>
>>>>> https://go.googlesource.com/gollvm/+/253c122ed62d5e9a32a9806e83c47a389a6435bf/cmake/modules/AutoGenGo.cmake#63
>>>>>
>>>>> What does the zgoarch.go file look like in your build area?
>>>>>
>>>>> Thanks, Than
>>>>>
>>>>>
>>>>> On Wed, Oct 19, 2022 at 8:20 AM Alex Markin <alexan...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hello.
>>>>>>
>>>>>> I'm trying to build gollvm on my gentoo system and get the following
>>>>>> error:
>>>>>>
>>>>>> FAILED: tools/gollvm/libgo/internal/.pic/goarch.o
>>>>>> /home/alex/test/gollvm/build-debug/tools/gollvm/libgo/internal/.pic/goarch.o
>>>>>>
>>>>>> cd /home/alex/test/gollvm/build-debug/tools/gollvm/libgo &&
>>>>>> /usr/bin/cmake -E make_directory ./internal/.pic &&
>>>>>> /home/alex/test/gollvm/build-debug/./bin/llvm
>>>>>> -goc -c -o
>>>>>> /home/alex/test/gollvm/build-debug/tools/gollvm/libgo/internal/.pic/goarch.o
>>>>>> -fPIC -fgo-pkgpath=internal/goarch -I . /home/alex/test/gollvm/llvm-p
>>>>>> roject/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:15:35:
>>>>>> error: reference to undefined name '_ArchFamily'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:18:19:
>>>>>> error: reference to undefined name '_BigEndian'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:21:29:
>>>>>> error: reference to undefined name '_DefaultPhysPa
>>>>>> geSize'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:25:19:
>>>>>> error: reference to undefined name '_PCQuantum'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:28:20:
>>>>>> error: reference to undefined name '_Int64Align'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:35:22:
>>>>>> error: reference to undefined name '_MinFrameSize'
>>>>>> /home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/internal/goarch/goarch.go:39:20:
>>>>>> error: reference to undefined name '_StackAlign'
>>>>>>
>>>>>> What can be the reason of such error? On another ubuntu system
>>>>>> everything goes correctly.
>>>>>>
>>>>>> The cmake line:
>>>>>>
>>>>>> cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++
>>>>>> -DCMAKE_C_COMPILER=clang -G Ninja ../llvm-project/llvm
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "golang-nuts" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to golang-nuts+unsubscr...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/golang-nuts/9ad0d8dc-d118-45d2-984e-9cdf36ab4f28n%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/golang-nuts/9ad0d8dc-d118-45d2-984e-9cdf36ab4f28n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAAgqtbVr4QNQWgiPZLN01x81S_C-EZTQ%3D%2BseZvDdVPiSiJbX8g%40mail.gmail.com.

Reply via email to