gollvm: sys/unix error with LLVM10

69 views
Skip to first unread message

Khanh TN

unread,
May 5, 2021, 8:12:37 AM5/5/21
to golang-nuts
Hi, I'm building a tool to analyze the LLVM bitcode of some Go code with gollvm.
We are currently running LLVM10. We will migrate to LLVM11/12 but not sure when.
I followed Than's instruction to build LLVM10-compatible gollvm from https://groups.google.com/g/golang-nuts/c/dMZ7vk_Rjzw/m/b1zYDOxLAAAJ

It worked out great until recently. Code that imports golang.org/x/sys/unix will cause errors when "go build". I looked around and found out the error message is the same as in https://github.com/mainflux/coap-cli/issues/3 to the line number of gccgo.go.

A suggested fix is getting CGO_ENABLED=1 but "go env" shows CGO_ENABLED=1 and "set CGO_ENABLED=1" does not help.

The latest gollvm commit works fine though but it requires LLVM13.

Is there any known fix or workaround for my situation? Should I set CGO_ENABLED somewhere else?

Thanks,
Khanh

Than McIntosh

unread,
May 5, 2021, 8:47:11 AM5/5/21
to Khanh TN, golang-nuts
Hi,

I think what you are seeing is basically a consequence of building an older version of gollvm -- the version you are building doesn't include newer bug fixes in the gofrontend version of the go command.  The fix you need is in a gofrontend commit ( c948c2d770122932a05b62f653efa2c51f72d3ae ) that dates to fall of 2020. The older version of gofrontend you are picking up doesn't include this fix. 

Not sure if there is an easy workaround here-- when building older versions of the tools you have to be prepared for this sort of thing. I am sure that there are LLVM bugs fixed in version 11 that are still present in V10, for example.

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/a92eb44d-73c6-43dd-9f1a-551b06589a78n%40googlegroups.com.

Khanh TN

unread,
May 5, 2021, 9:06:39 AM5/5/21
to golang-nuts
Thank you.
I will try this gofrontend commit as a temporary fix.

Khanh

Reply all
Reply to author
Forward
0 new messages