Last active
September 6, 2024 21:07
-
-
Save samm-git/7470fbfedcc61f67af31e2df042e3810 to your computer and use it in GitHub Desktop.
FreeBSD crossbuild with GCC on Linux host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
RUN apt-get update | |
# install dependencies | |
RUN apt-get install --yes gcc g++ bison make wget xz-utils | |
# Compile binutils | |
RUN mkdir /build && cd /build && \ | |
wget https://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.xz && \ | |
tar -xf binutils-2.29.tar.xz && cd binutils-2.29 && \ | |
./configure --enable-libssp --enable-gold --enable-ld \ | |
--target=x86_64-pc-freebsd10 --prefix=/opt/cross-freebsd && make -j4 && \ | |
make install && \ | |
rm -rf /build && mkdir /build | |
# Get FreeBSD libs/headers, extract and fix broken links | |
RUN cd /build/ && \ | |
wget http://ftp.plusline.de/FreeBSD/releases/amd64/10.4-RELEASE/base.txz && \ | |
cd /opt/cross-freebsd/x86_64-pc-freebsd10 && \ | |
tar -xf /build/base.txz ./lib/ ./usr/lib/ ./usr/include/ && \ | |
cd /opt/cross-freebsd/x86_64-pc-freebsd10/usr/lib && \ | |
find . -xtype l|xargs ls -l|grep ' /lib/' \ | |
| awk '{print "ln -sf /opt/cross-freebsd/x86_64-pc-freebsd10"$11 " " $9}' \ | |
| /bin/sh && \ | |
rm -rf /build && mkdir /build | |
# Compile GMP | |
RUN cd /build && \ | |
wget https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz && \ | |
tar -xf gmp-6.1.2.tar.xz && \ | |
cd gmp-6.1.2 && \ | |
./configure --prefix=/opt/cross-freebsd --enable-shared --enable-static \ | |
--enable-fft --enable-cxx --host=x86_64-pc-freebsd10 && \ | |
make -j4 && make install && \ | |
rm -rf /build && mkdir /build | |
# Compile MPFR | |
RUN cd /build && \ | |
wget https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.6.tar.xz && tar -xf mpfr-3.1.6.tar.xz && \ | |
cd mpfr-3.1.6 && \ | |
./configure --prefix=/opt/cross-freebsd --with-gnu-ld --enable-static \ | |
--enable-shared --with-gmp=/opt/cross-freebsd --host=x86_64-pc-freebsd10 && \ | |
make -j4 && make install && \ | |
rm -rf /build && mkdir /build | |
# Compile MPC | |
RUN cd /build && \ | |
wget https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz && tar -xf mpc-1.0.3.tar.gz && \ | |
cd mpc-1.0.3 && \ | |
./configure --prefix=/opt/cross-freebsd --with-gnu-ld --enable-static \ | |
--enable-shared --with-gmp=/opt/cross-freebsd \ | |
--with-mpfr=/opt/cross-freebsd --host=x86_64-pc-freebsd10 && \ | |
make -j4 && make install && \ | |
rm -rf /build && mkdir /build | |
# 1. Configure GCC | |
# 2. Fix GCC for the failed aligned_alloc detection | |
# 3. Build and install | |
RUN cd /build && \ | |
wget https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz && \ | |
tar xf gcc-7.2.0.tar.xz && \ | |
cd gcc-7.2.0 && mkdir build && cd build && \ | |
../configure --without-headers --with-gnu-as --with-gnu-ld --disable-nls \ | |
--enable-languages=c,c++ --enable-libssp --enable-gold --enable-ld \ | |
--disable-libitm --disable-libquadmath --target=x86_64-pc-freebsd10 \ | |
--prefix=/opt/cross-freebsd --with-gmp=/opt/cross-freebsd \ | |
--with-mpc=/opt/cross-freebsd --with-mpfr=/opt/cross-freebsd --disable-libgomp \ | |
--with-sysroot=/opt/cross-freebsd/x86_64-pc-freebsd10 \ | |
--with-build-sysroot=/opt/cross-freebsd/x86_64-pc-freebsd10 && \ | |
cd /build/gcc-7.2.0 && \ | |
echo '#define HAVE_ALIGNED_ALLOC 1' >> libstdc++-v3/config.h.in && \ | |
cd /build/gcc-7.2.0/build && \ | |
make -j4 && make install && \ | |
rm -rf /build | |
## Configure run | |
## ./configure CC=/opt/cross-freebsd/bin/x86_64-pc-freebsd10-gcc CXX=/opt/cross-freebsd/bin/x86_64-pc-freebsd10-g++ \ | |
## --host=x86_64-pc-freebsd10 LDFLAGS="-nodefaultlibs -lc++ -lm -lc -lgcc_s -lgcc" \ | |
## CXXFLAGS="-std=c++11 -I/opt/cross-freebsd/x86_64-pc-freebsd10/usr/include/c++/v1 -nostdinc++" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/mcandre/snek/blob/master/docker/freebsd/Dockerfile
https://hub.docker.com/layers/167700801/mcandre/snek/freebsd/images/sha256-6b5e5c796dd46aa10ba10606c08e7fadbbef86d46427572ab99849474187e723?context=repo