tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

tinygo:ld.lld: error: undefined symbol: crypto/aes.encryptBlockAsm

Open d33tah opened this issue 3 years ago • 7 comments

I tried to give tinygo a try by building a simple "hello world" web service. Instead, I found that crypto/aes doesn't compile:

> sudo docker run --rm tinygo/tinygo:0.22.0 tinygo test crypto/aes 
tinygo:ld.lld: error: undefined symbol: crypto/aes.encryptBlockAsm
>>> referenced by cipher_asm.go:69 (/usr/local/go/src/crypto/aes/cipher_asm.go:69)
>>>               /tmp/tinygo3958504993/main.o:((*crypto/aes.aesCipherAsm).Encrypt)

tinygo:ld.lld: error: undefined symbol: crypto/aes.decryptBlockAsm
>>> referenced by cipher_asm.go:82 (/usr/local/go/src/crypto/aes/cipher_asm.go:82)
>>>               /tmp/tinygo3958504993/main.o:((*crypto/aes.aesCipherAsm).Decrypt)
failed to run tool: ld.lld
FAIL
error: failed to link /tmp/tinygo3958504993/main: exit status 1

It looks like those packages are on the list of the ones supported by TinyGo, so what's the problem?

d33tah avatar Apr 15 '22 13:04 d33tah

You need to read the large type at the top of that page :-)

A PR is pending to update that page to show which packages actually pass tests, which ought to help clear up the confusion.

The tests that pass in the dev branch (which will soon become the next version, 0.23) on darwin, linux, wasi, and windows can be found by checking out that branch and typing "make report-stdlib-tests-pass". Here's what it currently says:

report.txt

Note that net/http is not in the list whose tests pass. So, you can import it, but you can't use all the functions in it yet.

fmt is also not in the list, probably because %v doesn't pass tests (because reflection is not fully supported), but it's useful otherwise.

dkegel-fastly avatar Apr 15 '22 15:04 dkegel-fastly

Got it. Thanks for pointing that out! I guess that the issue can be closed then.

d33tah avatar Apr 15 '22 15:04 d33tah

It's a real enough bug. Easier way to demonstrate it is:

C02DG0QJMD6R:tinygo dkegel$ build/tinygo test crypto/aes
tinygo:ld.lld: error: undefined symbol: _crypto/aes.encryptBlockAsm
>>> referenced by /var/folders/v0/0k9hwftd29b18z9z7s2g2sfc0000gn/T/tinygo2654768174/main.o

tinygo:ld.lld: error: undefined symbol: _crypto/aes.decryptBlockAsm
>>> referenced by /var/folders/v0/0k9hwftd29b18z9z7s2g2sfc0000gn/T/tinygo2654768174/main.o
failed to run tool: ld.lld
error: failed to link /var/folders/v0/0k9hwftd29b18z9z7s2g2sfc0000gn/T/tinygo2654768174/main: exit status 1
FAIL

You might tidy up this bug report by editing down the long log in your initial comment, though.

dkegel-fastly avatar Apr 15 '22 15:04 dkegel-fastly

btw, the missing symbol comes from regular go, and isn't picked up because it is in assembly and we don't quite support that yet; https://github.com/tinygo-org/tinygo/pull/2688 may eventually fix that.

dkegel-fastly avatar Apr 15 '22 15:04 dkegel-fastly

You might tidy up this bug report by editing down the long log in your initial comment, though.

@dkegel-fastly done. does it look OK now?

d33tah avatar Apr 15 '22 15:04 d33tah

This issue would be fixed with #3103.

aykevl avatar Aug 28 '22 21:08 aykevl

Also affects go-jose and golang-jwt, unsurprisingly.

dkegel-fastly avatar Sep 20 '22 14:09 dkegel-fastly