golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.92k stars 17.65k forks source link

gollvm: assertion failed when compiling golang.org/x/mod/semver on Ubuntu 20.04 #47570

Open u2400 opened 3 years ago

u2400 commented 3 years ago

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
(base) root@7e4c15edc8bd:~/workdir/build-debug# cat /etc/issue
Ubuntu 20.04.2 LTS \n \l

What did you do?

I followed the instructions on the gollvm page.

What did you expect to see?

The project builds cleanly.

What did you see instead?

I built gollvm in docker, and got the following error message

Error message:
(base) root@7e4c15edc8bd:~/workdir/build-debug# cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_LINKER=gold -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++  -G Ninja ../llvm-project/llvm
...

(base) root@7e4c15edc8bd:~/workdir/build-debug# ninja gollvm 
...
[2466/3746] Building Go package 'golang.org/x/mod/semver' (non-PIC)
FAILED: tools/gollvm/libgo/golang.org/x/mod/semver.o /root/workdir/build-debug/tools/gollvm/libgo/golang.org/x/mod/semver.o 
cd /root/workdir/build-debug/tools/gollvm/libgo && /usr/local/bin/cmake-3.21.1-linux-x86_64/bin/cmake -E make_directory ./golang.org/x/mod && /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/golang.org/x/mod/semver.o -fgo-pkgpath=golang.org/x/mod/semver -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/golang.org/x/mod/semver/semver.go
llvm-goc: /root/workdir/llvm-project/llvm/include/llvm/IR/Attributes.h:844: llvm::AttrBuilder &llvm::AttrBuilder::addAttribute(Attribute::AttrKind): Assertion `Attribute::isEnumAttrKind(Val) && "Adding integer/type attribute without an argument!"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/root/workdir/build-debug/./bin/llvm-goc[0x304676a]
/root/workdir/build-debug/./bin/llvm-goc[0x304693b]
/root/workdir/build-debug/./bin/llvm-goc[0x3044f0b]
/root/workdir/build-debug/./bin/llvm-goc[0x30470b1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f10378513c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f103730118b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f10372e0859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7f10372e0729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7f10372f1f36]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2a8c]
/root/workdir/build-debug/./bin/llvm-goc[0x6ddceb]
/root/workdir/build-debug/./bin/llvm-goc[0x6def99]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea885]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea497]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2f0a]
/root/workdir/build-debug/./bin/llvm-goc[0x6d8423]
/root/workdir/build-debug/./bin/llvm-goc[0x5d64d1]
/root/workdir/build-debug/./bin/llvm-goc[0x672b75]
/root/workdir/build-debug/./bin/llvm-goc[0x64bbca]
/root/workdir/build-debug/./bin/llvm-goc[0x55dad1]
/root/workdir/build-debug/./bin/llvm-goc[0x558861]
/root/workdir/build-debug/./bin/llvm-goc[0x4e3325]
/root/workdir/build-debug/./bin/llvm-goc[0x4e2c2d]
/root/workdir/build-debug/./bin/llvm-goc[0x4d0bdb]
/root/workdir/build-debug/./bin/llvm-goc[0x4cf7f7]
/root/workdir/build-debug/./bin/llvm-goc[0x4c6d10]
/root/workdir/build-debug/./bin/llvm-goc[0x4a6cf0]
/root/workdir/build-debug/./bin/llvm-goc[0x4a48e1]
/root/workdir/build-debug/./bin/llvm-goc[0x4a84e6]
/root/workdir/build-debug/./bin/llvm-goc[0x496a76]
/root/workdir/build-debug/./bin/llvm-goc[0x496c7c]
/root/workdir/build-debug/./bin/llvm-goc[0x48908e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f10372e20b3]
/root/workdir/build-debug/./bin/llvm-goc[0x48843e]
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/golang.org/x/mod/semver.o -fgo-pkgpath=golang.org/x/mod/semver -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/golang.org/x/mod/semver/semver.go
Aborted
[2470/3746] Building Go package 'hash/maphash' (non-PIC)
FAILED: tools/gollvm/libgo/hash/maphash.o /root/workdir/build-debug/tools/gollvm/libgo/hash/maphash.o 
cd /root/workdir/build-debug/tools/gollvm/libgo && /usr/local/bin/cmake-3.21.1-linux-x86_64/bin/cmake -E make_directory ./hash && /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/hash/maphash.o -fgo-pkgpath=hash/maphash -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/hash/maphash/maphash.go
llvm-goc: /root/workdir/llvm-project/llvm/include/llvm/IR/Attributes.h:844: llvm::AttrBuilder &llvm::AttrBuilder::addAttribute(Attribute::AttrKind): Assertion `Attribute::isEnumAttrKind(Val) && "Adding integer/type attribute without an argument!"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/root/workdir/build-debug/./bin/llvm-goc[0x304676a]
/root/workdir/build-debug/./bin/llvm-goc[0x304693b]
/root/workdir/build-debug/./bin/llvm-goc[0x3044f0b]
/root/workdir/build-debug/./bin/llvm-goc[0x30470b1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f77f20623c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f77f1b1218b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f77f1af1859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7f77f1af1729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7f77f1b02f36]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2a8c]
/root/workdir/build-debug/./bin/llvm-goc[0x6ddceb]
/root/workdir/build-debug/./bin/llvm-goc[0x6def99]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea885]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea497]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea36e]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea36e]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2f0a]
/root/workdir/build-debug/./bin/llvm-goc[0x6d8423]
/root/workdir/build-debug/./bin/llvm-goc[0x5d64d1]
/root/workdir/build-debug/./bin/llvm-goc[0x55b2be]
/root/workdir/build-debug/./bin/llvm-goc[0x558861]
/root/workdir/build-debug/./bin/llvm-goc[0x4e3325]
/root/workdir/build-debug/./bin/llvm-goc[0x55dcf1]
/root/workdir/build-debug/./bin/llvm-goc[0x558861]
/root/workdir/build-debug/./bin/llvm-goc[0x4e3325]
/root/workdir/build-debug/./bin/llvm-goc[0x4e2c2d]
/root/workdir/build-debug/./bin/llvm-goc[0x4d0bdb]
/root/workdir/build-debug/./bin/llvm-goc[0x4cf7f7]
/root/workdir/build-debug/./bin/llvm-goc[0x4c6d10]
/root/workdir/build-debug/./bin/llvm-goc[0x4a6cf0]
/root/workdir/build-debug/./bin/llvm-goc[0x4a48e1]
/root/workdir/build-debug/./bin/llvm-goc[0x4a84e6]
/root/workdir/build-debug/./bin/llvm-goc[0x496a76]
/root/workdir/build-debug/./bin/llvm-goc[0x496c7c]
/root/workdir/build-debug/./bin/llvm-goc[0x48908e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f77f1af30b3]
/root/workdir/build-debug/./bin/llvm-goc[0x48843e]
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/hash/maphash.o -fgo-pkgpath=hash/maphash -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/hash/maphash/maphash.go
Aborted
[2471/3746] Building Go package 'hash/maphash' (PIC)
FAILED: tools/gollvm/libgo/hash/.pic/maphash.o /root/workdir/build-debug/tools/gollvm/libgo/hash/.pic/maphash.o 
cd /root/workdir/build-debug/tools/gollvm/libgo && /usr/local/bin/cmake-3.21.1-linux-x86_64/bin/cmake -E make_directory ./hash/.pic && /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/hash/.pic/maphash.o -fPIC -fgo-pkgpath=hash/maphash -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/hash/maphash/maphash.go
llvm-goc: /root/workdir/llvm-project/llvm/include/llvm/IR/Attributes.h:844: llvm::AttrBuilder &llvm::AttrBuilder::addAttribute(Attribute::AttrKind): Assertion `Attribute::isEnumAttrKind(Val) && "Adding integer/type attribute without an argument!"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/root/workdir/build-debug/./bin/llvm-goc[0x304676a]
/root/workdir/build-debug/./bin/llvm-goc[0x304693b]
/root/workdir/build-debug/./bin/llvm-goc[0x3044f0b]
/root/workdir/build-debug/./bin/llvm-goc[0x30470b1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fab3011a3c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fab2fbca18b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7fab2fba9859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7fab2fba9729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7fab2fbbaf36]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2a8c]
/root/workdir/build-debug/./bin/llvm-goc[0x6ddceb]
/root/workdir/build-debug/./bin/llvm-goc[0x6def99]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea885]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea497]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea36e]
/root/workdir/build-debug/./bin/llvm-goc[0x6ea36e]
/root/workdir/build-debug/./bin/llvm-goc[0x6e2f0a]
/root/workdir/build-debug/./bin/llvm-goc[0x6d8423]
/root/workdir/build-debug/./bin/llvm-goc[0x5d64d1]
/root/workdir/build-debug/./bin/llvm-goc[0x55b2be]
/root/workdir/build-debug/./bin/llvm-goc[0x558861]
/root/workdir/build-debug/./bin/llvm-goc[0x4e3325]
/root/workdir/build-debug/./bin/llvm-goc[0x55dcf1]
/root/workdir/build-debug/./bin/llvm-goc[0x558861]
/root/workdir/build-debug/./bin/llvm-goc[0x4e3325]
/root/workdir/build-debug/./bin/llvm-goc[0x4e2c2d]
/root/workdir/build-debug/./bin/llvm-goc[0x4d0bdb]
/root/workdir/build-debug/./bin/llvm-goc[0x4cf7f7]
/root/workdir/build-debug/./bin/llvm-goc[0x4c6d10]
/root/workdir/build-debug/./bin/llvm-goc[0x4a6cf0]
/root/workdir/build-debug/./bin/llvm-goc[0x4a48e1]
/root/workdir/build-debug/./bin/llvm-goc[0x4a84e6]
/root/workdir/build-debug/./bin/llvm-goc[0x496a76]
/root/workdir/build-debug/./bin/llvm-goc[0x496c7c]
/root/workdir/build-debug/./bin/llvm-goc[0x48908e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7fab2fbab0b3]
/root/workdir/build-debug/./bin/llvm-goc[0x48843e]
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /root/workdir/build-debug/./bin/llvm-goc -c -o /root/workdir/build-debug/tools/gollvm/libgo/hash/.pic/maphash.o -fPIC -fgo-pkgpath=hash/maphash -I . /root/workdir/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/hash/maphash/maphash.go
Aborted
[2479/3746] Building Go package 'unicode' (non-PIC)
ninja: build stopped: subcommand failed.

Other Environmental information

(base) root@7e4c15edc8bd:~/workdir/build-debug# ninja --version
1.10.0

(base) root@7e4c15edc8bd:~/workdir/build-debug# python --version
Python 3.9.5

(base) root@7e4c15edc8bd:~/workdir/build-debug# cmake --version
cmake version 3.21.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

(base) root@7e4c15edc8bd:~/workdir/build-debug# clang --version
Ubuntu clang version 11.1.0-++20210801112124+1fdec59bffc1-1~exp1~20210801092747.168
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

This issues(#42843) mentioned the same problem

ianlancetaylor commented 3 years ago

CC @thanm

gopherbot commented 3 years ago

Change https://golang.org/cl/340124 mentions this issue: gollvm: update struct ret attribute construction

thanm commented 3 years ago

I sent https://go-review.googlesource.com/c/gollvm/+/340124, which should resolve this particular problem once it is submitted.

For the time being I would recommend RelWithDebInfo with -DCMAKE_BUILD_TYPE= as opposed to Debug, since there seems to be another issue there with Debug that I haven't had a chance to look over.

u2400 commented 3 years ago

Cool! Although I haven't tried to run it yet, but the build succeeded.

(base) root@7e4c15edc8bd:~/workdir/build-debug# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_USE_LINKER=gold -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++  -G Ninja ../llvm-project/llvm
...
(base) root@7e4c15edc8bd:~/workdir/build-debug# ninja gollvm 
...
[3763/3763] Building go program cgo

Thank you very much!