psparago
psparago

Reputation: 1113

How to cross compile solaris 32-bit

We are currently building our Go executables for several platforms including Solaris 64-bit. We have requests for a 32-bit Solaris executable version as well and I am unable to get this to work (the person who setup the Solaris 64-bit cross compiler is gone and unreachable).

I tried just setting -m32 flag on go build using our existing solaris cross compilation, but that didn't work, so I am attempting to build a Solaris 32-bit specific cross compiler.

I googled and found some vague examples, so I am following this process:

  1. Copy headers and libraries from a 32-bit Solaris machine to my Linux build machine.
  2. D/L and build binutils and gcc pointing SYSROOT to the downloaded 32-bit Solaris headers and libraries where:

$TARGET=sparc-sun-solaris2.10

$SYSROOT=/path/to/solaris32/includes

$PREFIX=/path/to/gcc-output

binutils-2.31/configure -target=$TARGET --prefix=$PREFIX -with-sysroot=$SYSROOT -v

gcc-8.2.0/configure --target=$TARGET --with-gnu-as --with-gnu-ld  --prefix=$PREFIX -with-sysroot=$SYSROOT --disable-libgcj --enable-languages=c,c++,go -v
  1. Create a symlink to gogcc and put GCC on the path
  2. Compile a trivial test go program like this:

    go build --compiler gccgo --gccgoflags "-m32 -O3 -static-libgo -Wl,-dy -lnsl -lsocket -lrt -lsendfile" -o ${GOTOOLS}/${BINARIES}/${PROJECT_NAME}/test/solaris_sparc32 test/main.go

This fails as follows:

go build: when using gccgo toolchain, please pass compiler flags using -gccgoflags, not -gcflags

command-line-arguments

gccgo: error: may not use both -m32 and -m64

Clearly I don't know what I'm doing. Can anyone point me in the right direction?

Upvotes: 2

Views: 1320

Answers (1)

maerics
maerics

Reputation: 156592

Solaris 32-bit does not appear to be supported, according to the list of supported OS/arch targets:

The valid combinations of $GOOS and $GOARCH are:

$GOOS     $GOARCH
...
solaris   amd64
...

That is, Solaris 64-bit is explicitly listed as a supported platform but Solaris 32-bit is not listed.

As such, there is good reason to believe that go programs will not run reliably on Solaris 32-bit systems and you probably should not agree to support that platform (if you do happen to get that cross compilation working) mainly because the go team itself does not support it!

Upvotes: 5

Related Questions