I want to compile go amd64 to big-endian. Is it possible?
Hi @adeshk, welcome to the forum.
I am not that deep in to HW architecture details, but AFAIK, endianness is not an issue, except perhaps for specific encoding or decoding operation, and here the
encoding/binary package should have you covered.
amd64 is an extended
x86 and as such always little-endian by definition.
Can you explain in more details what exactly you want to compile for which architecture?
Sorry for the delayed response.
This is the package i download go1.16.6.linux-amd64.tar.gz.
I’m trying to compile it using the musl tool chain for openwrt and i see the following error:
go.o: compiled for a little endian system and target is big endian
Can you show the full error?
I’m trying to compile GO from source for amd64 architecture.
I was wondering if i could set the ARCH to compile for Big endian.
I came across this page which says Big endian is not supported for amd64 Installing Go from source - The Go Programming Language. Can I rely on this?
It is the official documentation
To compile Go AMD64 to big-endian, you will need to set the appropriate environment variables and use the correct compiler flags. Here’s an example command:
GOARCH=ppc64 GOOS=linux GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags=“-s -w” -o your_program_name
In this command,
GOARCH specifies the target architecture (in this case, PowerPC 64-bit),
GOOS specifies the target operating system (in this case, Linux), and
GOMIPS specifies the floating-point instruction set (in this case, softfloat).
Note that you may also need to modify your code to ensure that it is compatible with big-endian architecture, such as using network byte order for multi-byte data types.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.