How to compile GCC on x86 for Sun4v?

I am writing a programming assignment using C ++. The instructor for this course requires that all code be compiled and run on a UNIX server. The server is a SunOS machine. I wrote all my code on my personal laptop with GCC 5.2, which supports most of the functions of C ++ 11. However, when I upload my code to the server and try to compile it, I suddenly found that the version of g ++ on the server is 4.2.1, released in mid-2007. Many of the features of C ++ 11 are not supported. Even the argument is -stdnot accepted.

I tried to download the source code of the latest GCC and compile it on the server. Unfortunately, the disk quota is limited to 500 M per account. I'm just wondering if it is possible to cross-compile GCC on my x86 machine and upload the binary to the server so that I can compile my C ++ code.

By the way, I contacted the IT department for software updates, but they replied that they did not have such plans in the near future.

I did cross-compilation research online and found a couple of tutorials. But they are not easy to follow. In addition to binaries, there are also many dependencies such as headers and libraries. So before I give up and change my code to fit the old compiler, can anyone give me some suggestions?

Thanks.

uname -a returns the following result

SunOS 5.10 Generic_147147-26 sun4v sparc SUNW,T5240
+4
1

, , , , .

, binutils . , !

export PREFIX="$HOME/opt" # All the stuff will get installed here!
export TARGET=sparc-sun-solaris  # I'm not *100%* sure if this is correct, check it yourself
export PATH="$PREFIX/bin:$PATH"  # If you forget this/close the terminal, you're doomed!

, ... binutils!

cd $HOME/src # Or where you have the sources
mkdir binutils-build
cd binutils-build
../binutils-src/configure --target=$TARGET --prefix="$PREFIX" --disable-nls
make
make install

--disable-nls (a.k.a: !) . , , , binutils.

GCC , , , ! ( ), , LLVM + Clang ;).

cd $HOME/src
cd gcc-src
./contrib/download_prerequisites # Get GMP, MPFR, and MPC
cd ..
mkdir gcc-build
cd gcc-build
../gcc-src/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

( , ), , , SunOS/SPARC! BTW, --enable-languages=c,c++ , GCC C ++. , . ...

sparc-sun-solaris-g++ --version

, , , . , ...

export PREFIX="$HOME/some-holy-directory" # This path *must* be the same for both your machine and the target server!
export HOST=$TARGET

, --host=$HOST configure! some-holy-directory . 500 , , , , , . ++ 98.

BTW. : - GCC . , . , - , - ;).

. -, Glibc ...

, !

+3

Source: https://habr.com/ru/post/1615540/


All Articles