mmcloughlin / avo

Generate x86 Assembly with Go
BSD 3-Clause "New" or "Revised" License
2.74k stars 90 forks source link

Fails to build under architectures other than amd64 #152

Open rogers0 opened 4 years ago

rogers0 commented 4 years ago

I packaged this git into debian:

However, it builds successfully only on amd64, but fails on other architectures:

e.g.

It may be related to #134 Please kindly help to fix, if possible. Thank you!

dgryski commented 4 years ago

Seems like this can be solved with some build tags to avoid trying to build the examples on non-amd64 architectures.

mmcloughlin commented 4 years ago

@rogers0 Thanks for reaching out. As @dgryski says we may be able to fix this with build tags, however I also wonder if it's possible for you to simply not build avo for those other architectures?

The purpose of avo is a developer tool to assist with code generation for amd64 platforms. I guess someone might work on a different architecture and write assembly for amd64, but that's likely not the common use case.

Ticket https://bugs.debian.org/965065 mentions that avo is required because it's a circl dependency. Not sure if it makes a difference, but avo is a developer dependency for circl, not a runtime dependency. I actually worked with them to ensure that avo did not appear in their main go.mod. Instead, avo only appears in the go.mod files for their keccak and dilithium assembly generators.

https://github.com/cloudflare/circl/blob/d004263612c5ecc3f650012406c253276fb78585/simd/keccakf1600/internal/asm/go.mod https://github.com/cloudflare/circl/tree/b8e907cafa61319bb0cbb3987cb5ace52c9c25a4/sign/dilithium/internal/common/asm

If it's still important for avo to build on those other platforms, let me know and I'll see what I can do.

rogers0 commented 4 years ago

@mmcloughlin @dgryski thanks for your feedback!

There're two binary package (in debian) for this source package:

for avo I can set it only builds on amd64 (x86 64bit), however for golang-github-mmcloughlin-avo-dev, it should be able to build in various architecture, which currently seems not.

e.g. for i386 (x86 32-bit), the build log is like:

# github.com/mmcloughlin/avo/tests/alloc/gp8
asm: invalid instruction: 00020 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/gp8/gp8.s:14)   MOVB    $8, R8
asm: invalid instruction: 00020 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/gp8/gp8.s:15)   MOVB    $9, R9
...
# github.com/mmcloughlin/avo/tests/alloc/masks
asm: asmins: illegal 64: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/masks/masks.s:7) MOVQ    $65578, AX
asm: asmins: illegal 64: 00005 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/masks/masks.s:8) MOVQ    $131114, CX
...
# github.com/mmcloughlin/avo/tests/alloc/upper32
asm: asmins: illegal 64: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/upper32/upper32.s:8) XORQ    AX, AX
asm: asmins: illegal in mode 32: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/alloc/upper32/upper32.s:8) XORQ    AX, AX (14 14)
...
# github.com/mmcloughlin/avo/tests/cast
asm: asmins: illegal 64: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/cast/cast.s:7) MOVQ    x+4(FP), AX
asm: asmins: illegal in mode 32: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/cast/cast.s:7) MOVQ    x+4(FP), AX (24 14)
...
# github.com/mmcloughlin/avo/tests/fixedbugs/issue100/minrepro
asm: asmins: illegal 64: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/fixedbugs/issue100/minrepro/minrepro.s:7)  XORQ    AX, AX
asm: asmins: illegal in mode 32: 00000 (/build/golang-github-mmcloughlin-avo-0.0~git20200523.4439b6b/obj-i686-linux-gnu/src/github.com/mmcloughlin/avo/tests/fixedbugs/issue100/minrepro/minrepro.s:7)  XORQ    AX, AX (14 14)
...
rogers0 commented 4 years ago

another one fails on i386 (x86 32-bit):

# github.com/mmcloughlin/avo/internal/gen
src/github.com/mmcloughlin/avo/internal/gen/asmtest.go:118:24: constant 9223372036854775807 overflows int