gollvm build fails

309 views
Skip to first unread message

张勇强

unread,
Jan 31, 2023, 1:04:08 AM1/31/23
to golang-nuts
I build gollvm on linux.  Is gollvm depend on a fiexed version of llvm? what's the version? thx
-- Retry after 5 seconds (attempt #3) ...
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp:47:3: 错误:‘Optional’不是一个类型名
   47 |   Optional<bool> isGCManagedPointer(const Type *Ty) const override {
      |   ^~~~~~~~
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp: 在函数‘void emitCallsiteEntries(llvm::StackMaps&, llvm::MCStreamer&)’中:
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp:174:29: 错误:cannot convert ‘int’ to ‘llvm::Align’
  174 |     OS.emitValueToAlignment(8);
      |                             ^
      |                             |
      |                             int
In file included from /home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp:25:
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/include/llvm/MC/MCStreamer.h:861:43: 附注:  初始化‘virtual void llvm::MCStreamer::emitValueToAlignment(llvm::Align, int64_t, unsigned int, unsigned int)’的实参 1
  861 |   virtual void emitValueToAlignment(Align Alignment, int64_t Value = 0,
      |                                     ~~~~~~^~~~~~~~~
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp: 在成员函数‘virtual bool {anonymous}::GoGCPrinter::emitStackMaps(llvm::StackMaps&, llvm::AsmPrinter&)’中:
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GC.cpp:186:6: 错误:‘class llvm::MCStreamer’ has no member named ‘SwitchSection’; did you mean ‘switchSection’?
  186 |   OS.SwitchSection(StackMapSection);
      |      ^~~~~~~~~~~~~
      |      switchSection
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GoStatepoints.cpp:1265:15: 错误:‘ArgMemOnly’不是‘llvm::Attribute’的成员
 1265 |    Attribute::ArgMemOnly, Attribute::InaccessibleMemOnly,
      |               ^~~~~~~~~~
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GoStatepoints.cpp:1265:38: 错误:‘InaccessibleMemOnly’不是‘llvm::Attribute’的成员
 1265 |    Attribute::ArgMemOnly, Attribute::InaccessibleMemOnly,
      |                                      ^~~~~~~~~~~~~~~~~~~
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GoStatepoints.cpp:1266:15: 错误:‘InaccessibleMemOrArgMemOnly’不是‘llvm::Attribute’的成员
 1266 |    Attribute::InaccessibleMemOrArgMemOnly,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GoStatepoints.cpp: 在函数‘void makeStatepointExplicitImpl(llvm::CallBase*, llvm::SmallVectorImpl<llvm::Value*>&, llvm::SmallVectorImpl<llvm::Value*>&, {anonymous}::PartiallyConstructedSafepointRecord&, std::vector<{anonymous}::DeferredReplacement>&)’中:
/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/passes/GoStatepoints.cpp:1433:50: 错误:‘class llvm::PointerType’ has no member named ‘getElementType’; did you mean ‘getArrayElementType’?
 1433 |       Type *T = cast<PointerType>(V->getType())->getElementType();
      |                                                  ^~~~~~~~~~~~~~
      |                                                  getArrayElementType

Than McIntosh

unread,
Feb 1, 2023, 9:05:31 AM2/1/23
to 张勇强, golang-nuts
Hello,

The gollvm build with LLVM tip is currently broken; there have been some upstream LLVM changes that aren't compatible with the Gollvm bridge code (notably the opaque pointer migration), which causes build failures.  This is a known problem, I haven't had enough free time to fix it recently.

I suggest building with slightly older versions of the LLVM and related repos. For example, this should work:

gollvm commit:  3452ec6bebaa1b432aabed1991475f4444c1775e
libbacktrace commit:  fd9442f7b5413e7788dfcf356f6261afcedb56e8
libffi commit:  2e825e219fa06d308b9a9863d70320606d67490d
gofrontend commit 1c5bfd57131b68b91d8400bb017f35d416f7aa7b
llvm-project commit 09629215c272f09e3ebde6cc7eac9625d28910ff

Let me know if you have issues building with this setup.

Thanks, Than


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2d6a3e36-ea7a-475e-9994-5ecf1d393021n%40googlegroups.com.

张勇强

unread,
Feb 14, 2023, 9:28:14 PM2/14/23
to golang-nuts
Hi,I got other errors。 error: undefined symbol: __morestack

[zyq@dev01 ~/strength/gollvm/workarea/build.rel]$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=lld -DCMAKE_C_COMPILER=/opt/compiler/clang-14/bin/clang -DCMAKE_CXX_COMPILER=/opt/compiler/clang-14/bin/clang++  ../llvm-project/llvm -DGOLLVM_DEFAULT_LINKER=lld -DCMAKE_INSTALL_PREFIX=/home/zyq/strength/gollvm/workarea/output -G Ninja  -DCMAKE_INCLUDE_PATH=/opt/compiler/clang-14/include -DCMAKE_LIBRARY_PATH=/opt/compiler/clang-14/lib -DCMAKE_C_FLAGS="-I/opt/compiler/clang-14/include" -DCMAKE_CXX_FLAGS="-I/opt/compiler/clang-14/include" -DC_INCLUDE_DIRS=/opt/compiler/clang-14/include/

[1/6] cd /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/gotools && /home/zyq/strength/gollvm/workarea/build.rel/./bin/llvm-goc -o /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/gotools/test2json test2json_.o -I /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo -L /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo/libgotool.a
FAILED: tools/gollvm/gotools/test2json /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/gotools/test2json
cd /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/gotools && /home/zyq/strength/gollvm/workarea/build.rel/./bin/llvm-goc -o /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/gotools/test2json test2json_.o -I /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo -L /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo /home/zyq/strength/gollvm/workarea/build.rel/tools/gollvm/libgo/libgotool.a
ld.lld: error: undefined symbol: __morestack
>>> referenced by main.go:0 (/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/cmd/test2json/main.go:0)
>>>               test2json_.o:(__go_init_main)
>>> referenced by proc.go:0 ( /home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/os/proc.go:0)
>>>               test2json_.o:(main.usage)
>>> referenced by main.go:0 (/home/zyq/strength/gollvm/workarea/llvm-project/llvm/tools/gollvm/gofrontend/libgo/go/cmd/test2json/main.go:0)
>>>               test2json_.o:(main.main)
>>> referenced 54 more times


I don't know why. and I do some tries.

[zyq@dev01 ~/strength/gollvm/workarea/build.rel]$ clang++ main.cc -fsplit-stack -Wl,-y,__morestack
/opt/compiler/clang-14/bin/ld: /tmp/main-d3384e.o: reference to __morestack
/opt/compiler/clang-14/bin/ld: /opt/compiler/clang-14/bin/../lib64/gcc/x86_64-unknown-linux-gnu/12.1.0/libgcc.a(morestack.o): definition of __morestack
[zyq@dev01 ~/strength/gollvm/workarea/build.rel]$ clang --print-libgcc-file-name
/opt/compiler/clang-14/bin/../lib64/gcc/x86_64-unknown-linux-gnu/12.1.0/libgcc.a
[zyq@dev01 ~/strength/gollvm/workarea/build.rel]$ which clang++
/opt/compiler/clang-14/bin/clang++

modify build.ninjia and add /opt/compiler/clang-14/bin/../lib64/gcc/x86_64-unknown-linux-gnu/12.1.0/libgcc.a to linker.
WechatIMG46.png

compile pass. but when I run llvm-goc. I still get this error

[zyq@dev01 ~/strength/gollvm/workarea/gollvm/bin]$ ls
a.out  gccgo  go  llvm-goc  main.go
[zyq@dev01 ~/strength/gollvm/workarea/gollvm/bin]$ llvm-goc main.go
bash: llvm-goc: command not found
[zyq@dev01 ~/strength/gollvm/workarea/gollvm/bin]$ ./llvm-goc main.go
ld.lld: error: undefined symbol: __morestack
>>> referenced by <built-in>:0
>>>               /tmp/compile+assemble-1ab03d.o:(__go_init_main)
>>> referenced by main.go:0
>>>               /tmp/compile+assemble-1ab03d.o:(main.main)
>>> referenced by <built-in>:0
>>>               /tmp/compile+assemble-1ab03d.o:(main.struct_4runtime_0gList_cruntime_0n_bint32_5..eq)
>>> referenced 23 more times


and I must add libgcc.a manually!!

[zyq@dev01 ~/strength/gollvm/workarea/gollvm/bin]$ ./llvm-goc main.go /opt/compiler/clang-14/bin/../lib64/gcc/x86_64-unknown-linux-gnu/12.1.0/libgcc.a


My bin compiled with clang14 toolchain has default rpath and interpreter。 but llvm-goc does not. I don't know why. Do you have any idea(by modify some code?)

[zyq@dev01 ~/strength/gollvm/workarea/xsxs/gollvm/bin]$ readelf -d go
 0x0000000000000001 (NEEDED)             Shared library: [libgo.so.15git]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]

[zyq@dev01 ~/strength/gollvm/workarea/xsxs/gollvm/bin]$ readelf -l go
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

My self example is ok:

[zyq@dev01 ~/strength/gollvm/workarea/xsxs/gollvm/bin]$ /opt/compiler/clang-14/bin/clang++ main.cc
[zyq@dev01 ~/strength/gollvm/workarea/xsxs/gollvm/bin]$ readelf -l a.out
      [Requesting program interpreter: /opt/compiler/clang-14/lib64/ld-linux-x86-64.so.2]
[zyq@dev01 ~/strength/gollvm/workarea/xsxs/gollvm/bin]$ readelf -d a.out
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN:$ORIGIN/lib:$ORIGIN/lib64:/opt/compiler/clang-14/lib:/opt/compiler/clang-14/lib/x86_64-unknown-linux-gnu:$ORIGIN/../lib:$ORIGIN/../lib64]

Adam Malcontenti-Wilson

unread,
May 25, 2023, 8:36:09 AM5/25/23
to golang-nuts
Coming here also trying to build gollvm master branch with the same above failure, suggesting that this info and the pinned commits should probably end up in the project's README.
Reply all
Reply to author
Forward
0 new messages