在Ubuntu 20.04上编译golang.org/x/mod/semver时,出现了Assert失败,

2nc8po8w  于 6个月前  发布在  Go
关注(0)|答案(4)|浏览(51)

这个问题在最新版本中是否重现?

是的。

你正在使用什么操作系统和处理器架构( go env )?

go env 输出

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

你做了什么?

我按照 gollvm page 上的说明操作。

你期望看到什么?

项目构建干净。

你看到了什么?

我在Docker中构建了gollvm,并得到了以下错误信息
错误信息:

(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/](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/](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.

其他环境信息

(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

这个问题( #42843 )提到了相同的问题

ws51t4hk

ws51t4hk2#

https://golang.org/cl/340124提到了这个问题:gollvm: update struct ret attribute construction

q9yhzks0

q9yhzks03#

我发送了 https://go-review.googlesource.com/c/gollvm/+/340124,一旦提交,它应该解决这个问题。
目前,我建议使用 RelWithDebInfo 与 -DCMAKE_BUILD_TYPE= 而不是 Debug,因为似乎在 Debug 模式下还有另一个问题,我没有机会仔细查看。

gab6jxml

gab6jxml4#

太酷了!虽然我还没有尝试运行它,但是构建成功了。

(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

非常感谢!

相关问题