334 lines
11 KiB
Bash
334 lines
11 KiB
Bash
SUMMARY="C/C++ compiler for target ${effectiveTargetMachineTriple}"
|
|
DESCRIPTION="The standard compiler for non-legacy Haiku (i.e. for all \
|
|
architectures other than x86_gcc2)."
|
|
HOMEPAGE="http://gcc.gnu.org"
|
|
COPYRIGHT="1988-2017 Free Software Foundation, Inc."
|
|
LICENSE="GNU GPL v3
|
|
GNU LGPL v3
|
|
"
|
|
REVISION="1"
|
|
srcGitRev="f58f40a3b2e1e6b1e8c4d83388d2ec76275764d8"
|
|
SOURCE_URI="https://github.com/korli/gcc/archive/$srcGitRev.tar.gz"
|
|
CHECKSUM_SHA256="5af819d0d81ca1defcd0de33b49dd58efa3b229f33b775b197bfa0772d95601c"
|
|
SOURCE_DIR="gcc-$srcGitRev"
|
|
PATCHES="gcc-$portVersion.patchset"
|
|
|
|
ARCHITECTURES="?all !x86_gcc2"
|
|
SECONDARY_ARCHITECTURES="?x86"
|
|
|
|
libatomicSoVersion="1"
|
|
libatomicLibVersion="1.2.0"
|
|
|
|
libgccSoVersion="1"
|
|
libgccLibVersion="1"
|
|
|
|
libstdcxxSoVersion="6"
|
|
libstdcxxLibVersion="6.0.23"
|
|
|
|
PROVIDES="
|
|
gcc8$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:c++$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:cc$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:cpp$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:g++$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:gcc$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:gcc_8.0.0$secondaryArchSuffix = $portVersion compat >= 8
|
|
cmd:gcov$secondaryArchSuffix = $portVersion compat >= 8
|
|
"
|
|
REQUIRES="
|
|
haiku$secondaryArchSuffix
|
|
cmd:as$secondaryArchSuffix
|
|
lib:libgmp$secondaryArchSuffix
|
|
lib:libmpc$secondaryArchSuffix
|
|
lib:libmpfr$secondaryArchSuffix
|
|
lib:libz$secondaryArchSuffix
|
|
"
|
|
|
|
SUMMARY_syslibs="C/C++-runtime shared libraries, needed to execute C/C++ programs"
|
|
DESCRIPTION_syslibs="The C/C++-runtime libraries that are part of the gcc \
|
|
distribution. This package contains the shared libraries for the runtime \
|
|
loader, so it is required for executing most c/c++ programs."
|
|
PROVIDES_syslibs="
|
|
gcc8${secondaryArchSuffix}_syslibs = $portVersion compat >= 8
|
|
lib:libatomic$secondaryArchSuffix = $libatomicLibVersion compat >= $libatomicSoVersion
|
|
lib:libgcc_s$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
|
|
lib:libstdc++$secondaryArchSuffix = $libstdcxxLibVersion compat >= $libstdcxxSoVersion
|
|
lib:libsupc++$secondaryArchSuffix = $portVersion compat >= 8
|
|
"
|
|
REQUIRES_syslibs="
|
|
haiku$secondaryArchSuffix
|
|
"
|
|
|
|
SUMMARY_syslibs_devel="C/C++-runtime static libraries and C++ headers, needed to build Haiku"
|
|
DESCRIPTION_syslibs_devel="This package is not of general interest - it \
|
|
contains the set of gcc's C/C++-runtime libraries and headers that is \
|
|
required by Haiku's build system when building Haiku."
|
|
PROVIDES_syslibs_devel="
|
|
gcc8${secondaryArchSuffix}_syslibs_devel = $portVersion compat >= 8
|
|
devel:libatomic$secondaryArchSuffix = $libatomicLibVersion compat >= $libatomicSoVersion
|
|
devel:libgcc_kernel$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
|
|
devel:libgcc$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
|
|
devel:libgcc_eh_kernel$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
|
|
devel:libgcc_eh$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
|
|
devel:libstdc++$secondaryArchSuffix = $libstdcxxLibVersion compat >= $libstdcxxSoVersion
|
|
devel:libsupc++$secondaryArchSuffix = $portVersion compat >= 8
|
|
devel:libsupc++_kernel$secondaryArchSuffix = $portVersion compat >= 8
|
|
"
|
|
REQUIRES_syslibs_devel=""
|
|
|
|
BUILD_REQUIRES="
|
|
haiku${secondaryArchSuffix}_devel
|
|
devel:libgmp$secondaryArchSuffix >= 10.3.0
|
|
devel:libmpc$secondaryArchSuffix >= 3.0.0
|
|
devel:libmpfr$secondaryArchSuffix >= 4.1.4
|
|
devel:libz$secondaryArchSuffix
|
|
"
|
|
BUILD_PREREQUIRES="
|
|
cmd:autoconf
|
|
cmd:awk
|
|
cmd:find
|
|
cmd:flex
|
|
cmd:gcc$secondaryArchSuffix
|
|
cmd:ld$secondaryArchSuffix
|
|
cmd:make
|
|
cmd:makeinfo
|
|
cmd:sed
|
|
cmd:strip
|
|
cmd:tar
|
|
cmd:xargs
|
|
"
|
|
|
|
sourceDir=$(pwd)
|
|
relativeInstallDir="develop/tools$secondaryArchSubDir"
|
|
installDir="$prefix/$relativeInstallDir"
|
|
objectsDir=$(pwd)/../${portVersionedName}-obj
|
|
gccVersion=$(echo $portVersion | cut -d_ -f1)
|
|
|
|
BUILD()
|
|
{
|
|
rm -rf $objectsDir
|
|
|
|
# Touch some files generated by bison, so that bison won't run to update
|
|
# them. Fixes issues with newer bison versions.
|
|
# And while at it, touch gperf target, too (as gperf may not be installed).
|
|
(cd $sourceDir/gcc; touch c-parse.c c-parse.h cexp.c cp/parse.c \
|
|
cp/parse.h c-gperf.h)
|
|
|
|
mkdir -p $objectsDir
|
|
cd $objectsDir
|
|
|
|
local additionalConfigureFlags
|
|
if [ -n "$secondaryArchSuffix" ]; then
|
|
additionalConfigureFlags="\
|
|
--with-hybrid-secondary=${effectiveTargetArchitecture}"
|
|
fi
|
|
local kernelCcFlags="-D_KERNEL_MODE"
|
|
if [ $effectiveTargetArchitecture == x86_64 ]; then
|
|
# disable multilib support, as x86_64 by default tries to build the
|
|
# 32-bit libraries, too, which fails as no 32-bit libroot is available
|
|
additionalConfigureFlags+=" --disable-multilib"
|
|
|
|
# deactivate red zone for x86_64
|
|
kernelCcFlags="$kernelCcFlags -mno-red-zone"
|
|
fi
|
|
|
|
"$sourceDir/configure" \
|
|
--build=$effectiveTargetMachineTriple \
|
|
--prefix=$installDir --libexecdir=$installDir/lib --mandir=$manDir \
|
|
--docdir=$docDir --enable-threads=posix \
|
|
--disable-nls --enable-shared --with-gnu-ld --with-gnu-as \
|
|
--enable-version-specific-runtime-libs \
|
|
--enable-languages=c,c++ --enable-lto --enable-frame-pointer \
|
|
--with-pkgversion=$(echo $portVersion | cut -d_ -f2-) \
|
|
--enable-__cxa-atexit --with-system-zlib --enable-checking=release \
|
|
--with-bug-url=http://dev.haiku-os.org/ \
|
|
--with-default-libstdcxx-abi=gcc4-compatible \
|
|
$additionalConfigureFlags
|
|
|
|
make $jobArgs
|
|
|
|
echo "######################## building special libraries ################"
|
|
|
|
echo "### libgcc"
|
|
|
|
# build kernel versions of libgcc.a and libgcc_eh.a (no threads or TLS)
|
|
cd $objectsDir/$effectiveTargetMachineTriple/libgcc
|
|
mkdir -p saved
|
|
mv libgcc.a libgcc_eh.a libgcc_s* libgcov* saved/
|
|
make clean
|
|
ln -sfn "$sourceDir/libgcc/gthr-single.h" gthr-default.h
|
|
make CFLAGS="-O2 $kernelCcFlags" CXXFLAGS="-O2 $kernelCcFlags"
|
|
mv libgcc.a libgcc-kernel.a
|
|
mv libgcc_eh.a libgcc_eh-kernel.a
|
|
ln -sfn "$sourceDir/libgcc/gthr-posix.h" gthr-default.h
|
|
mv saved/* .
|
|
rmdir saved
|
|
|
|
# build kernel version of libsupc++.a (without threads or TLS)
|
|
cd $objectsDir/$effectiveTargetMachineTriple/libstdc++-v3/libsupc++
|
|
mkdir -p saved
|
|
mv .libs/libsupc++* saved/
|
|
cp "../include/$effectiveTargetMachineTriple/bits/gthr-default.h" \
|
|
"../config.h" \
|
|
"../include/$effectiveTargetMachineTriple/bits/c++config.h" \
|
|
saved/
|
|
make clean
|
|
cp "../include/$effectiveTargetMachineTriple/bits/gthr-single.h" \
|
|
"../include/$effectiveTargetMachineTriple/bits/gthr-default.h"
|
|
sed -i -e 's,#define _GLIBCXX_HAS_GTHREADS 1,/* #undef _GLIBCXX_HAS_GTHREADS */,' \
|
|
"../config.h"
|
|
sed -i -e 's,#define _GLIBCXX_HAVE_TLS 1,/* #undef _GLIBCXX_HAVE_TLS */,' \
|
|
"../include/$effectiveTargetMachineTriple/bits/c++config.h"
|
|
make CFLAGS="-O2 $kernelCcFlags" CXXFLAGS="-O2 $kernelCcFlags"
|
|
mv .libs/libsupc++.a .libs/libsupc++-kernel.a
|
|
mv saved/libsupc++* .libs/
|
|
mv saved/gthr-default.h "../include/$effectiveTargetMachineTriple/bits/"
|
|
mv saved/config.h ..
|
|
mv saved/c++config.h "../include/$effectiveTargetMachineTriple/bits/"
|
|
rmdir saved
|
|
}
|
|
|
|
INSTALL()
|
|
{
|
|
cd $objectsDir
|
|
|
|
make install
|
|
make install-html
|
|
|
|
### HTML documentation ####################################
|
|
|
|
echo "Organizing HTML documentation..."
|
|
cd $docDir
|
|
for dir in libquadmath; do
|
|
mv ${dir}.html $dir
|
|
ln -s $dir/index.html ${dir}.html
|
|
done
|
|
|
|
### Libraries #############################################
|
|
|
|
echo "Moving libraries around"
|
|
|
|
# Move/copy libraries such that copies of the runtime (shared) libs exist
|
|
# in $libDir and copies of static libraries exist in $developLibDir. These
|
|
# are put into separate packages gcc_syslibs and gcc_syslibs_devel, which
|
|
# are both used by Haiku's build system.
|
|
mkdir -p $libDir
|
|
mkdir -p $developLibDir
|
|
cd $installDir
|
|
gccLibDir=lib/gcc/$effectiveTargetMachineTriple/$gccVersion
|
|
|
|
# libatomic
|
|
strip --strip-debug $gccLibDir/libatomic.so.$libatomicLibVersion
|
|
cp -d $gccLibDir/libatomic.so \
|
|
$gccLibDir/libatomic.so.$libatomicSoVersion \
|
|
$gccLibDir/libatomic.so.$libatomicLibVersion \
|
|
$libDir/
|
|
cp $gccLibDir/libatomic*.a $developLibDir/
|
|
|
|
# libstdc++
|
|
strip --strip-debug $gccLibDir/libstdc++.so.$libstdcxxLibVersion
|
|
cp -d $gccLibDir/libstdc++.so \
|
|
$gccLibDir/libstdc++.so.$libstdcxxSoVersion \
|
|
$gccLibDir/libstdc++.so.$libstdcxxLibVersion \
|
|
$libDir/
|
|
cp $gccLibDir/libstdc++*.a $developLibDir/
|
|
|
|
# libsupc++
|
|
libstdcxxDir=$objectsDir/$effectiveTargetMachineTriple/libstdc++-v3
|
|
cp $libstdcxxDir/libsupc++/.libs/libsupc++-kernel.a \
|
|
$gccLibDir/
|
|
ln -s libstdc++.so $libDir/libsupc++.so
|
|
cp $gccLibDir/libsupc++*.a $developLibDir/
|
|
|
|
# libgcc
|
|
cp $objectsDir/$effectiveTargetMachineTriple/libgcc/libgcc-kernel.a \
|
|
$objectsDir/$effectiveTargetMachineTriple/libgcc/libgcc_eh-kernel.a \
|
|
$gccLibDir/
|
|
strip --strip-debug $gccLibDir/libgcc_s.so.$libgccSoVersion
|
|
cp -d $gccLibDir/libgcc_s.so \
|
|
$gccLibDir/libgcc_s.so.$libgccSoVersion \
|
|
$libDir/
|
|
cp $gccLibDir/libgcc*.a $developLibDir/
|
|
|
|
# gcc and c++ headers
|
|
mkdir -p $includeDir/gcc
|
|
cp -r $gccLibDir/include $includeDir/gcc/
|
|
cp -r $gccLibDir/include-fixed $includeDir/gcc/
|
|
mv $includeDir/gcc/include/c++ $includeDir/
|
|
|
|
### Strip #################################################
|
|
|
|
echo "Strip"
|
|
|
|
cd $installDir
|
|
strip bin/*
|
|
for f in cc1 cc1plus collect2 lto1 lto-wrapper; do
|
|
strip $gccLibDir/$f
|
|
done
|
|
|
|
strip --strip-debug \
|
|
$gccLibDir/*.a \
|
|
$developLibDir/*.a
|
|
|
|
### Disable ASLR ##########################################
|
|
|
|
echo "Add SYS:ENV attribute to disable ASLR"
|
|
|
|
cd $installDir
|
|
for f in bin/*; do
|
|
if [ -r "$f" ]; then
|
|
addattr SYS:ENV DISABLE_ASLR=1 $f
|
|
fi
|
|
done
|
|
for f in cc1 cc1plus collect2 lto1; do
|
|
addattr SYS:ENV DISABLE_ASLR=1 \
|
|
$gccLibDir/$f
|
|
done
|
|
|
|
### Symlinks ##############################################
|
|
|
|
echo "Creating required symlinks"
|
|
|
|
# create missing cc symlink
|
|
ln -sf gcc $installDir/bin/cc
|
|
|
|
# make all tools available via default paths
|
|
mkdir -p $binDir
|
|
for f in c++ cc cpp g++ gcc gcov; do
|
|
symlinkRelative -sfn $installDir/bin/$f $binDir
|
|
done
|
|
|
|
### Cleanup ###############################################
|
|
|
|
echo "Cleanup"
|
|
rm -rf $installDir/info
|
|
rm -rf $installDir/share
|
|
|
|
### Sub Packages ##########################################
|
|
|
|
packageEntries "syslibs" \
|
|
$relativeLibDir/libatomic.so \
|
|
$relativeLibDir/libatomic.so.$libatomicSoVersion \
|
|
$relativeLibDir/libatomic.so.$libatomicLibVersion \
|
|
$relativeLibDir/libgcc_s.so \
|
|
$relativeLibDir/libgcc_s.so.$libgccSoVersion \
|
|
$relativeLibDir/libstdc++.so \
|
|
$relativeLibDir/libstdc++.so.$libstdcxxSoVersion \
|
|
$relativeLibDir/libstdc++.so.$libstdcxxLibVersion \
|
|
$relativeLibDir/libsupc++.so
|
|
|
|
packageEntries "syslibs_devel" \
|
|
$relativeDevelopLibDir/libatomic.a \
|
|
$relativeDevelopLibDir/libgcc.a \
|
|
$relativeDevelopLibDir/libgcc-kernel.a \
|
|
$relativeDevelopLibDir/libgcc_eh.a \
|
|
$relativeDevelopLibDir/libgcc_eh-kernel.a \
|
|
$relativeDevelopLibDir/libstdc++.a \
|
|
$relativeDevelopLibDir/libsupc++.a \
|
|
$relativeDevelopLibDir/libsupc++-kernel.a \
|
|
$relativeIncludeDir
|
|
|
|
rm -rf $includeDir
|
|
rm -rf $developLibDir
|
|
}
|