Build fails when using gollvm toolchain instead of go

97 views
Skip to first unread message

sit...@gmail.com

unread,
May 25, 2020, 11:55:05 AM5/25/20
to golang-nuts
Hi,

I've been trying to make this project https://github.com/intel-go/nff-go using a freshly built gollvm to get the code compiled into LLVM IR. The project builds fine when using the regular go toolchain, but when trying to build with gollvm, I get errors such as below:

../../asm/asm.s: Assembler messages:
../../asm/asm.s:6: Error: no such instruction: `text ·RteCompilerRmb(SB),NOSPLIT,$0-0'
../../asm/asm.s:9: Error: no such instruction: `
text ·RteCompilerWmb(SB),NOSPLIT,$0-0'
../../asm/asm.s:12: Error: no such instruction: `text ·Prefetcht0(SB),NOSPLIT,$0-8'

../../asm/asm.s:13: Error: junk `(FP)' after expression
../../asm/asm.s:13: Error: too many memory references for `
movq'
../../asm/asm.s:16: Error: no such instruction: `text ·GenerateMask(SB),NOSPLIT,$0-33'

../../asm/asm.s:17: Error: junk `(FP)' after expression
../../asm/asm.s:17: Error: too many memory references for `
movq'
../../asm/asm.s:18: Error: junk `(FP)'
after expression
../../asm/asm.s:18: Error: too many memory references for `movq'
../../asm/asm.s:19: Error: junk `
(FP)' after expression
../../asm/asm.s:19: Error: too many memory references for `movq'

../../asm/asm.s:20: Error: junk `(FP)' after expression
../../asm/asm.s:20: Error: too many memory references for `
movq'
../../asm/asm.s:21: Error: too many memory references for `vmovdqu'

../../asm/asm.s:22: Error: too many memory references for `vmovdqu'
../../asm/asm.s:23: Error: too many memory references for `
vmovdqu'
../../asm/asm.s:24: Error: too many memory references for `vpcmpeqb'

../../asm/asm.s:25: Error: too many memory references for `vpand'
../../asm/asm.s:26: Error: too many memory references for `
vptest'
../../asm/asm.s:27: Error: junk `(FP)'
after expression
../../asm/asm.s:27: Error: invalid instruction suffix for `sete'
../../asm/asm.s:28: Error: too many memory references for `
vmovdqu'


Ian Lance Taylor

unread,
May 25, 2020, 4:26:55 PM5/25/20
to sit...@gmail.com, golang-nuts
The assembler syntax used by the gc toolchain and the assembler syntax
used by GoLLVM are not compatible. Here you are trying to assemble
code written for the gc assembler with the GoLLVM assembler. That
won't work.

While the syntax differences are in some ways annoying, in other ways
they are good, because gc and GoLLVM use different calling
conventions. That means that assembler code written for gc and GoLLVM
are not compatible (except for functions that take no arguments and
return no results).

What this means for your code is that you need to rewrite this code
into GoLLVM assembler (changing the calling convention as you go) or
you need to rewrite it into Go. You can use build tags to select the
version to use for each compiler.

Sorry for these difficulties. They are hard to avoid.

Ian

Martins Eglitis

unread,
May 26, 2020, 3:41:43 AM5/26/20
to Ian Lance Taylor, sit...@gmail.com, golang-nuts
Hi,

Thank you for the kind answer. I can not see the asm tool in the gollvm
toolchain. Or should I use something else?

This is the go snippet:

package asm

// RteCompilerRmb is lfence
func RteCompilerRmb()

// RteCompilerWmb is sfence
func RteCompilerWmb()

// Prefetcht0 is prefetch
func Prefetcht0(addr uintptr)

func GenerateMask(v1 *([32]uint8), v2 *([32]uint8), previousMask
*([32]bool), result *([32]bool)) bool


Thank you!
--
Best regards,
Martins Eglitis

Ian Lance Taylor

unread,
May 26, 2020, 3:09:44 PM5/26/20
to Martins Eglitis, sit...@gmail.com, golang-nuts
On Tue, May 26, 2020 at 12:41 AM Martins Eglitis <mar...@sitilge.id.lv> wrote:
>
> Thank you for the kind answer. I can not see the asm tool in the gollvm
> toolchain. Or should I use something else?

There is no asm tool in the GoLLVM toolchain. When building for
GoLLVM the go tool will build assembly code using clang directly.

> This is the go snippet:
>
> package asm
>
> // RteCompilerRmb is lfence
> func RteCompilerRmb()
>
> // RteCompilerWmb is sfence
> func RteCompilerWmb()
>
> // Prefetcht0 is prefetch
> func Prefetcht0(addr uintptr)
>
> func GenerateMask(v1 *([32]uint8), v2 *([32]uint8), previousMask
> *([32]bool), result *([32]bool)) bool

OK, based on that you are going to have to rewrite those functions in
standard assembly language, and use build tags to select the specific
.s file that should be built.

Ian
Reply all
Reply to author
Forward
0 new messages