I need to compile go amd64 to big-endian. Is it attainable?
Hello @adeshk, welcome to the discussion board.
I’m not that deep in to HW structure particulars, however AFAIK, endianness shouldn’t be a difficulty, besides maybe for particular encoding or decoding operation, and right here the
encoding/binary package deal ought to have you ever lined.
amd64 is an prolonged
x86 and as such at all times little-endian by definition.
Are you able to clarify in additional particulars what precisely you need to compile for which structure?
Sorry for the delayed response.
That is the package deal i obtain go1.16.6.linux-amd64.tar.gz.
I’m attempting to compile it utilizing the musl device chain for openwrt and that i see the next error:
go.o: compiled for a bit of endian system and goal is massive endian
Are you able to present the complete error?
I’m attempting to compile GO from supply for amd64 structure.
I used to be questioning if i might set the ARCH to compile for Large endian.
I got here throughout this web page which says Large endian shouldn’t be supported for amd64 Putting in Go from supply – The Go Programming Language. Can I depend on this?
It’s the official documentation
To compile Go AMD64 to big-endian, you’ll need to set the suitable atmosphere variables and use the right compiler flags. Right here’s an instance command:
GOARCH=ppc64 GOOS=linux GOMIPS=softfloat CGO_ENABLED=0 go construct -ldflags=“-s -w” -o your_program_name
On this command,
GOARCH specifies the goal structure (on this case, PowerPC 64-bit),
GOOS specifies the goal working system (on this case, Linux), and
GOMIPS specifies the floating-point instruction set (on this case, softfloat).
Notice that you could be additionally want to switch your code to make sure that it’s appropriate with big-endian structure, resembling utilizing community byte order for multi-byte knowledge varieties.