Skip to content

Instantly share code, notes, and snippets.

@jen20
Forked from AlainODea/hello.c
Created March 16, 2016 09:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jen20/afb4db65d37b7422c139 to your computer and use it in GitHub Desktop.
Save jen20/afb4db65d37b7422c139 to your computer and use it in GitHub Desktop.
Cross-compiler from x86_64 Linux to x86_64 Illumos on Ubuntu (works for Hello World and possibly more)
#include<stdio.h>
main()
{
printf("Hello World");
}
#!/bin/bash
export TARGET=x86_64-sun-solaris2.11
export PREFIX=$HOME/Documents/gcc/cross/$TARGET
export SYSROOT=$PREFIX/sysroot
export PATH=$PATH:$PREFIX/bin
export SCRATCH=$HOME/Documents/gcc/scratch
export BINUTILS=binutils-2.23.2
export GCC=gcc-4.7.3
sudo apt-get install texinfo binutils build-essential libgmp-dev libmpfr-dev libmpc-dev
mkdir $PREFIX
mkdir $SYSROOT
pushd $SYSROOT/
ssh root@ns2 "pkgin -y up && pkgin -y ug && pkgin -y in gmp"
ssh root@ns2 "tar -cf - /usr/include" | tar -xvf -
ssh root@ns2 "tar -cf - /opt/local/include" | tar -xvf -
ssh root@ns2 "tar -cf - /opt/local/gcc47/include" | tar -xvf -
ssh root@ns2 "tar -cf - /lib" | tar -xvf -
ssh root@ns2 "tar -cf - /usr/lib" | tar -xvf -
ssh root@ns2 "tar -cf - /usr/gnu/lib" | tar -xvf -
mkdir $SCRATCH
pushd $SCRATCH/
wget http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.gz
tar -xvzf $BINUTILS.tar.gz
mkdir $SCRATCH/build-binutils
pushd $SCRATCH/build-binutils/
../$BINUTILS/configure -target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT -v
make all && make install
popd
wget http://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.gz
tar -xvzf $GCC.tar.gz
mkdir $SCRATCH/build-gcc
pushd $SCRATCH/build-gcc/
../$GCC/configure --target=$TARGET --with-gnu-as --with-gnu-ld --with-gmp \
--with-mpfr --with-mpc --prefix=$PREFIX --with-sysroot=$SYSROOT \
--disable-libgcj --enable-languages=c,c++ -v
make all && make install
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment