mirror of
https://github.com/dslm4515/BMLFS.git
synced 2025-08-20 14:31:47 +00:00
167 lines
6.1 KiB
Bash
167 lines
6.1 KiB
Bash
#! /bin/bash
|
|
|
|
# GCC Go Compiler Frontend
|
|
# Source: https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
|
|
# Source: https://libisl.sourceforge.io/isl-0.24.tar.xz
|
|
#
|
|
# $BUILD = Directory to temporarily install
|
|
# $PKGS = Directory to store built packages
|
|
#
|
|
# DEPS
|
|
# Required: NONE
|
|
# Recommended: NONE
|
|
# Optional: NONE
|
|
#
|
|
# NOTE
|
|
# Even if you specify only languages other than C and C++ to the
|
|
# ./configure command below, the installation process will
|
|
# overwrite your existing GCC C and C++ compilers and libraries
|
|
|
|
# Options based on architecture
|
|
case $(uname -m) in
|
|
x86_64) export TRUPLE="x86_64-linux-musl"
|
|
export EXTRA_CONFIG=" --with-arch=x86-64"
|
|
;;
|
|
i686) export TRUPLE="i686-linux-musl"
|
|
export EXTRA_CONFIG=" --with-arch=pentium3 --with-tune=pentium-m"
|
|
;;
|
|
armv7l) export TRUPLE="armv7l-linux-musleabihf"
|
|
export EXTRA_CONFIG=" --with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfp v3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb"
|
|
;;
|
|
armv6l) export TRUPLE="armv6l-linux-musleabihf"
|
|
export EXTRA_CONFIG=" --with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux"
|
|
;;
|
|
aarch64) export TRUPLE="aarch64-linux-musleabihf"
|
|
export EXTRA_CONFIG=" --with-arch=armv8-a --with-abi=lp64 --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419"
|
|
sed -i '/m64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux
|
|
;;
|
|
esac &&
|
|
|
|
# libitm has TEXTRELs in ARM build, so disable for now
|
|
case $(uname -m) in
|
|
arm*) export LIBITM=false ;;
|
|
esac &&
|
|
|
|
# Add isl source
|
|
tar -xf ../isl-0.24.tar.xz &&
|
|
mv -v isl-0.24 isl &&
|
|
|
|
# Apply patches [from alpine-linux]
|
|
bash ../patches/gcc-alpine/apply_patches_ct.sh
|
|
patch -Np1 -i ../patches/gcc-alpine/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
|
|
|
|
# Apply one more patch for go
|
|
patch -Np1 -i ../patches/gcc-alpine/0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch
|
|
|
|
# Configure source in dedicated build directory:
|
|
mkdir -v build && cd build
|
|
|
|
# Disable features not used
|
|
export NOFF="--disable-libstdcxx-pch "
|
|
export NOFF+="--disable-nls "
|
|
export NOFF+="--disable-multilib "
|
|
export NOFF+="--disable-bootstrap "
|
|
export NOFF+="--disable-symvers "
|
|
export NOFF+="--disable-libsanitizer "
|
|
export NOFF+="--disable-libssp "
|
|
export NOFF+="--disable-libmpx "
|
|
export NOFF+="--disable-libmudflap "
|
|
export NOFF+="--disable-fixed-point "
|
|
export NOFF+="--disable-sjlj-exceptions "
|
|
export NOFF+="--disable-werror "
|
|
|
|
# Enable graphite
|
|
export XCONFIG="--with-ppl=yes --with-cloog=yes "
|
|
|
|
# Enable features for x86_54
|
|
export XTRA86="--with-arch=x86-64 "
|
|
|
|
# Enable features
|
|
export FON="--enable-threads=posix "
|
|
export FON+="--enable-clocale=generic "
|
|
export FON+="--enable-tls "
|
|
export FON+="--enable-libstdcxx-time "
|
|
export FON+="--enable-fully-dynamic-string "
|
|
export FON+="--enable-default-pie "
|
|
export FON+="--enable-default-ssp "
|
|
export FON+="--enable-linker-build-id "
|
|
export FON+="--enable-checking=release "
|
|
export FON+="--enable-cloog-backend "
|
|
export FON+="--enable-__cxa_atexit "
|
|
export FON+="--enable-lto "
|
|
export FON+="--enable-plugins "
|
|
export FON+="--with-system-zlib "
|
|
export FON+="--with-linker-hash-style=gnu "
|
|
export FON+="--with-isl "
|
|
|
|
SED=sed libat_cv_have_ifunc=no \
|
|
../configure --prefix=/usr \
|
|
--build="${TRUPLE}" \
|
|
--enable-languages=c,c++,go,lto \
|
|
--with-pkgversion="MLFS+Go 10.0.0" $NOFF $XTRA86 $XCONFIG $FON
|
|
|
|
read -p "Compile?" && make -j2 &&
|
|
|
|
sudo -S make DESTDIR=$BUILD install && \
|
|
|
|
# Build useful utilities
|
|
cc -fpie ../../files/musl/getent.c -o getent
|
|
cc -fpie ../../files/musl/getconf.c -o getconf
|
|
cc -fpie ../../files/musl/iconv.c -o iconv
|
|
|
|
sudo -S cp -v getent $BUILD/usr/bin/
|
|
sudo -S cp -v getconf $BUILD/usr/bin/
|
|
sudo -S cp -v iconv $BUILD/usr/bin/
|
|
sudo -S cp -v ../../files/musl/getent.1 $BUILD/usr/share/man/man1/
|
|
sudo -S cp -v ../../files/musl/getconf.1 $BUILD/usr/share/man/man1/
|
|
|
|
# Create a symlink required by the FHS for "historical" reasons
|
|
sudo -S ln -sv ../bin/cpp $BUILD/usr/lib
|
|
|
|
# Many packages use the name cc to call the C compiler. To
|
|
# satisfy those packages, create a symlink
|
|
sudo -S ln -sv gcc $BUILD/usr/bin/cc
|
|
|
|
# Add a compatibility symlink to enable building programs with
|
|
# Link Time Optimization (LTO):
|
|
sudo -S install -v -dm755 $BUILD/usr/lib/bfd-plugins
|
|
sudo -S ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/11.2.0/liblto_plugin.so \
|
|
$BUILD/usr/lib/bfd-plugins/
|
|
sudo -S mkdir -pv $BUILD/usr/share/gdb/auto-load/usr/lib
|
|
sudo -S mv -v $BUILD/usr/lib/*gdb.py $BUILD/usr/share/gdb/auto-load/usr/lib
|
|
|
|
cd $BUILD && sudo -S mkdir -v ${BUILD}/install &&
|
|
cat > /tmp/slack-desc << "EOF"
|
|
# HOW TO EDIT THIS FILE:
|
|
# The "handy ruler" below makes it easier to edit a package description. Line
|
|
# up the first '|' above the ':' following the base package name, and the '|'
|
|
# on the right side marks the last column you can put a character in. You must
|
|
# make exactly 11 lines for the formatting to be correct. It's also
|
|
# customary to leave one space after the ':' except on otherwise blank lines.
|
|
|
|
|-----handy-ruler------------------------------------------------------|
|
|
gcc-go: GCC Compiler with Go Frontend
|
|
gcc-go:
|
|
gcc-go: This package contains parts for the Go compiler collection needed to
|
|
gcc-go: compile Go code. C/C++ compiler frontend included.
|
|
gcc-go:
|
|
gcc-go: Go is a statically typed, compiled programming language designed
|
|
gcc-go: at Google. It is syntactically similar to C, but with memory safety,
|
|
gcc-go: garbage collection, structural typing, and CSP-style concurrency.
|
|
gcc-go: The language is often referred to as Golang.
|
|
gcc-go:
|
|
EOF
|
|
sudo -S mv -v /tmp/slack-desc install/ &&
|
|
sudo -S makepkg -l y -c n $PKGS/gcc-go-11.2.0-$(uname -m)-mlfs.txz &&
|
|
cd /BMAN && \
|
|
cat > /tmp/slack-desc << "EOF"
|
|
gcc-go-doc: Manuals for GCC Compiler with Go Frontend
|
|
gcc-go-doc:
|
|
gcc-go-doc: This package contains parts for the Go compiler collection needed to
|
|
gcc-go-doc: compile Go code. C/C++ compiler frontend included.
|
|
gcc-go-doc:
|
|
EOF
|
|
sudo -S mv -v /tmp/slack-desc install/ && \
|
|
sudo -S makepkg -l y -c n $PKGS/gcc-go-doc-11.2.0-noarch-mlfs.txz && \
|
|
sudo -S rm -rf ${BUILD}/* /BMAN/*
|