Add new gcc packages that build syslibs.

* Build shared and static syslibs packages along with gcc. These
  packages will be used by Haiku's build system.
This commit is contained in:
Oliver Tappe
2014-08-11 21:52:16 +02:00
parent 0ae14925ba
commit 415330eafd
3 changed files with 608 additions and 0 deletions

View File

@@ -0,0 +1,193 @@
SUMMARY="C/C++ compiler"
DESCRIPTION="
Standard compiler for x86_gcc2 platform, ABI-compatible with BeOS R5.
"
HOMEPAGE="http://gcc.gnu.org"
LICENSE="
GNU GPL v2
GNU LGPL v2
"
COPYRIGHT="1988-2000 Free Software Foundation, Inc."
srcGitRev="e5a1aa929a5e26ccff8d56228634ef6ba0078212"
SRC_URI="https://github.com/haiku/buildtools/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="1e19de45203765ff494649b25df44aa1cb13a787c55ed57d3d18f8d95ff72397"
REVISION="1"
ARCHITECTURES="x86_gcc2"
if [ $effectiveTargetArchitecture = x86_gcc2 -a $targetArchitecture = x86 ]
then
ARCHITECTURES="$ARCHITECTURES x86"
fi
SECONDARY_ARCHITECTURES="x86_gcc2"
PROVIDES="
gcc$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:cc$secondaryArchSuffix
cmd:c++$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:c++filt$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:cpp$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:g++$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:gcc$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:gcov$secondaryArchSuffix = 1.5 compat >= 1.5
cmd:i586_pc_haiku_gcc$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:protoize$secondaryArchSuffix = $portVersion compat >= 2.95.3
cmd:unprotoize$secondaryArchSuffix = $portVersion compat >= 2.95.3
"
REQUIRES="
haiku$secondaryArchSuffix >= $haikuVersion
binutils$secondaryArchSuffix
"
BUILD_REQUIRES="
"
BUILD_PREREQUIRES="
haiku${secondaryArchSuffix}_devel >= $haikuVersion
cmd:autoconf
gcc$secondaryArchSuffix
cmd:find
cmd:flex
cmd:make
cmd:sed
cmd:tar
cmd:makeinfo
"
SOURCE_DIR="buildtools-$srcGitRev/legacy/gcc"
BUILD_PACKAGE_ACTIVATION_PHASE=INSTALL
gccDir=$(pwd)
relativeGccInstallDir="develop/tools$secondaryArchSubDir"
gccInstallDir="$prefix/$relativeGccInstallDir"
gccObjectsDir=$gccDir/../gcc-obj
BUILD()
{
rm -rf $gccObjectsDir
# 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 gcc; touch c-parse.c c-parse.h cexp.c cp/parse.c \
cp/parse.h c-gperf.h)
mkdir -p $gccObjectsDir
cd $gccObjectsDir
local additionalConfigureFlags
if [ -n "$secondaryArchSuffix" ]; then
additionalConfigureFlags="\
--with-hybrid-secondary=${effectiveTargetArchitecture}"
fi
CFLAGS="-O2" CXXFLAGS="-O2" "$gccDir/configure" \
--prefix=$gccInstallDir \
--disable-nls --enable-shared --enable-languages=c,c++ \
$additionalConfigureFlags
make bootstrap
}
INSTALL()
{
cd $gccObjectsDir
make install
rm $gccInstallDir/lib/libiberty.a
# only needed for building gcc
### HTML documentation ####################################
local html_base=$docDir
if [ ! -d "$html_base" ]; then
echo "Building HTML documentation..."
mkdir -p $html_base
cd $html_base
makeinfo --html "$gccDir/gcc/cpp.texi"
makeinfo --html "$gccDir/gcc/gcc.texi"
makeinfo --force --html "$gccDir/libio/iostream.texi" \
&& true
# some errors
ln -sf cpp/index.html $html_base/cpp.html
ln -sf gcc/index.html $html_base/gcc.html
ln -sf iostream/index.html $html_base/iostream.html
fi
### Symlinks ##############################################
echo "Creating required symlinks"
# convert to absolute links to relative ones
cd $gccInstallDir/bin
ln -sfn g++ c++
ln -sfn gcc cc
ln -sfn gcc $effectiveTargetMachineTriple-gcc
# make all tools available via default paths
echo "Symlinking binaries into default path"
mkdir -p $binDir
symlinkRelative -s $gccInstallDir/bin/* $binDir
### Libraries #############################################
echo "Moving libraries around"
# Move/copy libraries such that copies of static libraries (libgcc.a)
# exist in $developLibDir. These are put into a separate package
# (gcc_syslibs_devel), which is used by Haiku's build system.
mkdir -p $libDir
mkdir -p $developLibDir
cd $gccInstallDir
gccLibDir=lib/gcc-lib/$effectiveTargetMachineTriple/2.95.3-*
# libgcc
cp $gccLibDir/libgcc.a $developLibDir/
### Strip #################################################
echo "Strip debug info"
cd $gccInstallDir
strip --strip-debug bin/*
strip --strip-debug $gccLibDir/* &>/dev/null || true
### Cleanup ###############################################
echo "Cleanup"
cd $gccInstallDir
rm -rf info
rm -rf share
rm man/man1/cccp.1
### C++ includes ##########################################
echo "Install C++ includes & library"
rm -rf $gccInstallDir/include/g++
ln -snf /boot/system/develop/headers/c++/2.95.3 $gccInstallDir/include/g++
ln -snf /boot/system/lib$secondaryArchSubDir/libstdc++.r4.so $gccInstallDir/lib/
### Sub Packages ##########################################
packageEntries "syslibs_devel" \
$relativeDevelopLibDir/libgcc.a
rm -rf $libDir
rm -rf $developLibDir
}
# ----- syslibs_devel package -----------------------------------------------
SUMMARY_syslibs_devel="\
GCC c/c++-runtime static libraries, 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 that is required by Haiku's build system when building \
Haiku."
PROVIDES_syslibs_devel="
gcc_syslibs_devel$secondaryArchSuffix = $portVersion compat >= 2.95.3
"
REQUIRES_syslibs_devel=""

View File

@@ -0,0 +1,320 @@
SUMMARY="C/C++ compiler for target ${effectiveTargetMachineTriple}"
DESCRIPTION="
Standard compiler for non-legacy Haiku (i.e. for all architectures other than \
x86_gcc2).
"
HOMEPAGE="http://gcc.gnu.org"
srcGitRev="4947d64591fdd9764dad9ff6835ffbef1618e17f"
SRC_URI="https://github.com/haiku/buildtools/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="cb9261a3d3ab6e9c4ca5f2cd772a46439490ce525062c5fd2b2d04f50ad45619"
REVISION="1"
LICENSE="
GNU GPL v2
GNU LGPL v2
"
COPYRIGHT="1988-2013 Free Software Foundation, Inc."
if [ $effectiveTargetArchitecture = x86_64 ]; then
PATCHES="gcc-4.8.3_buildfixes_for_x86_64.patchset"
fi
ARCHITECTURES="x86 x86_64 arm"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
# x86_gcc2 is fine as primary target architecture as long as we're building
# for a different secondary architecture.
ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"
libstdcxxSoVersion="6"
libstdcxxLibVersion="6.0.19"
libgccSoVersion="1"
libgccLibVersion="1"
PROVIDES="
gcc$secondaryArchSuffix = $portVersion compat >= 4
cmd:c++$secondaryArchSuffix = $portVersion compat >= 4
cmd:cc$secondaryArchSuffix = $portVersion compat >= 4
cmd:cpp$secondaryArchSuffix = $portVersion compat >= 4
cmd:g++$secondaryArchSuffix = $portVersion compat >= 4
cmd:gcc$secondaryArchSuffix = $portVersion compat >= 4
cmd:gcc_4.8.3$secondaryArchSuffix = $portVersion compat >= 4
cmd:gcov$secondaryArchSuffix = $portVersion compat >= 4
"
REQUIRES="
haiku$secondaryArchSuffix >= $haikuVersion
cmd:as$secondaryArchSuffix
"
BUILD_REQUIRES="
"
BUILD_PREREQUIRES="
haiku${secondaryArchSuffix}_devel >= $haikuVersion
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
"
SOURCE_DIR="buildtools-$srcGitRev/gcc"
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 \
$additionalConfigureFlags
make $jobArgs
# 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
mv saved/* .
rmdir saved
# Build a shared libsupc++ from libsupc++.a (hacking the gcc build system
# to build a shared libsupc++ yields pretty much the same result, so we
# use this simpler approach).
cd $objectsDir/$effectiveTargetMachineTriple/libstdc++-v3/libsupc++
gcc -nodefaultlibs -shared -o .libs/libsupc++.so -Xlinker --whole-archive \
.libs/libsupc++.a
# build kernel version of libsupc++.a (without threads or TLS)
mkdir -p saved
mv .libs/libsupc++* saved/
make clean
# deactivate threads and tls support
cp "../include/$effectiveTargetMachineTriple/bits/gthr-single.h" \
"../include/$effectiveTargetMachineTriple/bits/gthr-default.h"
sed -i -e 's,#define _GLIBCXX_HAVE_TLS 1,/* #undef _GLIBCXX_HAVE_TLS */,' \
"../include/$effectiveTargetMachineTriple/bits/c++config.h"
sed -i -e 's,#define _GLIBCXX_HAS_GTHREADS 1,/* #undef _GLIBCXX_HAS_GTHREADS */,' \
"../config.h"
make CFLAGS="-O2 $kernelCcFlags" CXXFLAGS="-O2 $kernelCcFlags"
mv .libs/libsupc++.a .libs/libsupc++-kernel.a
mv saved/* .libs/
rmdir saved
}
INSTALL()
{
cd $objectsDir
make install
make install-html
### HTML documentation ####################################
echo "Organizing HTML documentation..."
cd $docDir
for dir in gmp libquadmath mpc mpfr; 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
# 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 \
$libstdcxxDir/libsupc++/.libs/libsupc++.so \
$gccLibDir/
strip --strip-debug $gccLibDir/libsupc++.so
cp $gccLibDir/libsupc++.so $libDir/
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 lib/*.a \
$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/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/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
}
# ----- syslibs package -----------------------------------------------------
SUMMARY_syslibs="\
GCC 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="
gcc_syslibs$secondaryArchSuffix = $portVersion compat >= 4
lib:libgcc_s$secondaryArchSuffix = $portVersion compat >= 4
lib:libstdc++$secondaryArchSuffix = $portVersion compat >= 4
lib:libsupc++$secondaryArchSuffix = $portVersion compat >= 4
"
REQUIRES_syslibs="
haiku$secondaryArchSuffix >= $haikuVersion
"
# ----- syslibs_devel package -----------------------------------------------
SUMMARY_syslibs_devel="\
GCC 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="
gcc_syslibs_devel$secondaryArchSuffix = $portVersion compat >= 4
"
REQUIRES_syslibs_devel=""

View File

@@ -0,0 +1,95 @@
From e9e78f55996c23624ebd792eed57dd60a571daaa Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Tue, 22 Jul 2014 01:32:29 +0000
Subject: Specify -save-temps for libgcc during dependency phase
This works around an internal compiler error when building
gcc for x86_64 with thread local storage enabled.
diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
index 2353c9c..93eada2 100644
--- a/libcpp/Makefile.in
+++ b/libcpp/Makefile.in
@@ -207,7 +207,7 @@ ifeq ($(DEPMODE),depmode=gcc3)
# Note that we put the dependencies into a .Tpo file, then move them
# into place if the compile succeeds. We need this because gcc does
# not atomically write the dependency output file.
-COMPILE = $(COMPILE.base) -o $@ -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Tpo
+COMPILE = $(COMPILE.base) -o $@ -save-temps -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Tpo
POSTCOMPILE = @mv $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
else
COMPILE = source='$<' object='$@' libtool=no DEPDIR=$(DEPDIR) $(DEPMODE) \
--
1.8.3.4
From fc3eb46b47136ae82418e2a6f63f3e3d8e918c1f Mon Sep 17 00:00:00 2001
From: Oliver Tappe <zooey@hirschkaefer.de>
Date: Sat, 26 Jul 2014 13:19:29 +0200
Subject: Circumvent build problems on x86_64.
* Due to some yet unknown cause, --as-needed does not seem to work as
expected on x86_64, which causes the gcc build to fail when it checks
if it can execute built programs (as libgcc_s.so is needed by those
programs and can't be found). Circumvent the problem for now by creating
appropriate 'lib' symlinks such that libgcc_s.so will be found by
runtime_loader.
diff --git a/gmp/configure b/gmp/configure
index e8378cc..68c8d69 100755
--- a/gmp/configure
+++ b/gmp/configure
@@ -9378,7 +9378,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
esac
-
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../prev-gcc lib
# The C compiler on the build system, and associated tests.
diff --git a/libquadmath/configure b/libquadmath/configure
index 76dfbdf..e58cf46 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -3381,6 +3381,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
fi
ac_exeext=$ac_cv_exeext
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
diff --git a/libssp/configure b/libssp/configure
index c42affe..20e2b87 100755
--- a/libssp/configure
+++ b/libssp/configure
@@ -3361,6 +3361,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
fi
ac_exeext=$ac_cv_exeext
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6479114..72e04bd 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -3997,6 +3997,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
fi
ac_exeext=$ac_cv_exeext
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
--
1.8.3.4