简体   繁体   中英

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM