From b10377b53ec5a0fbe1aea24d5785fe38dcb9a2fb Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Thu, 5 May 2016 21:35:41 +0000 Subject: [PATCH] gcc7: add git recipe. --- sys-devel/gcc/gcc7-7.0.0_2016_02_29.recipe | 333 ++++++++++++++++++ .../gcc/patches/gcc-7.0.0_2016_02_29.patchset | 84 +++++ 2 files changed, 417 insertions(+) create mode 100644 sys-devel/gcc/gcc7-7.0.0_2016_02_29.recipe create mode 100644 sys-devel/gcc/patches/gcc-7.0.0_2016_02_29.patchset diff --git a/sys-devel/gcc/gcc7-7.0.0_2016_02_29.recipe b/sys-devel/gcc/gcc7-7.0.0_2016_02_29.recipe new file mode 100644 index 000000000..3787f420f --- /dev/null +++ b/sys-devel/gcc/gcc7-7.0.0_2016_02_29.recipe @@ -0,0 +1,333 @@ +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" + +srcGitRev="abb80251080239f8e058dea1ae0ca011e2c72816" +SOURCE_URI="https://github.com/korli/gcc/archive/$srcGitRev.tar.gz" +CHECKSUM_SHA256="0176a47c07cf0e7229b5f8e6d00d05b544f15145313c986117e94ef4775a3ed2" +REVISION="1" +LICENSE=" + GNU GPL v3 + GNU LGPL v3 + " +COPYRIGHT="1988-2016 Free Software Foundation, Inc." + +PATCHES="gcc-7.0.0_2016_02_29.patchset" + +ARCHITECTURES="!x86_gcc2 ?x86 ?x86_64 ?arm" +SECONDARY_ARCHITECTURES="?x86" + +libatomicSoVersion="1" +libatomicLibVersion="1.2.0" + +libstdcxxSoVersion="6" +libstdcxxLibVersion="6.0.22" + +libgccSoVersion="1" +libgccLibVersion="1" + +PROVIDES=" + gcc7$secondaryArchSuffix = $portVersion compat >= 7 + cmd:c++$secondaryArchSuffix = $portVersion compat >= 7 + cmd:cc$secondaryArchSuffix = $portVersion compat >= 7 + cmd:cpp$secondaryArchSuffix = $portVersion compat >= 7 + cmd:g++$secondaryArchSuffix = $portVersion compat >= 7 + cmd:gcc$secondaryArchSuffix = $portVersion compat >= 7 + cmd:gcc_7.0.0$secondaryArchSuffix = $portVersion compat >= 7 + cmd:gcov$secondaryArchSuffix = $portVersion compat >= 7 + " +REQUIRES=" + haiku$secondaryArchSuffix + cmd:as$secondaryArchSuffix + lib:libgmp$secondaryArchSuffix >= 10.3.0 + lib:libmpc$secondaryArchSuffix >= 3.0.0 + lib:libmpfr$secondaryArchSuffix >= 4.1.4 + lib:libz$secondaryArchSuffix + " +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 + " + +SOURCE_DIR="gcc-$srcGitRev" + +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/libstdc++.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.$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 +} + +# ----- syslibs package ----------------------------------------------------- + +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=" + gcc7${secondaryArchSuffix}_syslibs = $portVersion compat >= 7 + lib:libatomic$secondaryArchSuffix = $libatomicLibVersion compat >= $libatomicSoVersion + lib:libgcc_s$secondaryArchSuffix = $portVersion compat >= 7 + lib:libstdc++$secondaryArchSuffix = $portVersion compat >= 7 + lib:libsupc++$secondaryArchSuffix = $portVersion compat >= 7 + " +REQUIRES_syslibs=" + haiku$secondaryArchSuffix + " + +# ----- syslibs_devel package ----------------------------------------------- + +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=" + gcc7${secondaryArchSuffix}_syslibs_devel = $portVersion compat >= 7 + " +REQUIRES_syslibs_devel="" diff --git a/sys-devel/gcc/patches/gcc-7.0.0_2016_02_29.patchset b/sys-devel/gcc/patches/gcc-7.0.0_2016_02_29.patchset new file mode 100644 index 000000000..5bd8df0b5 --- /dev/null +++ b/sys-devel/gcc/patches/gcc-7.0.0_2016_02_29.patchset @@ -0,0 +1,84 @@ +From c57c54c34af0144fd63f0947baaee835d55df2ec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= +Date: Mon, 27 Jul 2015 16:32:32 +0200 +Subject: Haiku: disable -fno-PIE as this fails on x86_64. + + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index 87e7a16..6d469b8 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -264,7 +264,7 @@ NO_PIE_CFLAGS = @NO_PIE_CFLAGS@ + NO_PIE_FLAG = @NO_PIE_FLAG@ + + # We don't want to compile the compilers with -fPIE, it make PCH fail. +-COMPILER += $(NO_PIE_CFLAGS) ++#COMPILER += $(NO_PIE_CFLAGS) + + # Link with -no-pie since we compile the compiler with -fno-PIE. + LINKER += $(NO_PIE_FLAG) +@@ -764,9 +764,9 @@ NO_PIE_CFLAGS_FOR_BUILD = @NO_PIE_CFLAGS_FOR_BUILD@ + NO_PIE_FLAG_FOR_BUILD = @NO_PIE_FLAG_FOR_BUILD@ + BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR_FILE + BUILD_CXXFLAGS = @BUILD_CXXFLAGS@ -DGENERATOR_FILE +-BUILD_NO_PIE_CFLAGS = @BUILD_NO_PIE_CFLAGS@ +-BUILD_CFLAGS += $(BUILD_NO_PIE_CFLAGS) +-BUILD_CXXFLAGS += $(BUILD_NO_PIE_CFLAGS) ++#BUILD_NO_PIE_CFLAGS = @BUILD_NO_PIE_CFLAGS@ ++#BUILD_CFLAGS += $(BUILD_NO_PIE_CFLAGS) ++#BUILD_CXXFLAGS += $(BUILD_NO_PIE_CFLAGS) + + # Native compiler that we use. This may be C++ some day. + COMPILER_FOR_BUILD = $(CXX_FOR_BUILD) +-- +2.2.2 + + +From 7c3527abcfe31de1c85ad133a4df3f79d94076f2 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Thu, 5 May 2016 09:03:06 +0000 +Subject: fix for libstdc++/69506 + + +diff --git a/libstdc++-v3/config/os/haiku/os_defines.h b/libstdc++-v3/config/os/haiku/os_defines.h +index 4674f7b..02c8693 100644 +--- a/libstdc++-v3/config/os/haiku/os_defines.h ++++ b/libstdc++-v3/config/os/haiku/os_defines.h +@@ -42,4 +42,7 @@ + #define _GLIBCXX_USE_CLOCK_REALTIME 1 + #endif + ++// See libstdc++/69506 ++#define _GLIBCXX_USE_WEAK_REF 0 ++ + #endif +-- +2.2.2 + + +From b6a24621d51c5d01cd1c91596d74d47678756bf7 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Thu, 5 May 2016 15:52:08 +0000 +Subject: rename x86_elf_aligned_common. + + +diff --git a/gcc/config/i386/haiku64.h b/gcc/config/i386/haiku64.h +index 76ba48e..4fb337d 100644 +--- a/gcc/config/i386/haiku64.h ++++ b/gcc/config/i386/haiku64.h +@@ -112,9 +112,9 @@ Boston, MA 02111-1307, USA. */ + #define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} \ + %{Wa,*:%*} %{" SPEC_32 ":--32} %{" SPEC_64 ":--64}" + +-#undef ASM_OUTPUT_ALIGNED_COMMON +-#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ +- x86_elf_aligned_common (FILE, NAME, SIZE, ALIGN); ++#undef ASM_OUTPUT_ALIGNED_DECL_COMMON ++#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ ++ x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN); + + + /* i386 System V Release 4 uses DWARF debugging info. +-- +2.2.2 +