# -*- mode: sh; sh-shell: bash -*-
BUILD_REQUIRES=""
################################################################################
#
# Cygport control script for gcc.
#
# Copyright (C) 2008, 2009, 2010 Dave Korn
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script. If not, see .
#
################################################################################
TOOLCHAIN_TARGET="native"
inherit toolchain python3
NAME="gcc"
VERSION="11.4.0"
RELEASE="1"
CATEGORY="Devel"
SUMMARY="GNU Compiler Collection"
DESCRIPTION="The GNU Compiler Collection includes front ends for C, C++,
Objective-C, Fortran, and Go, as well as libraries for these
languages (libstdc++, libgcj,...)."
HOMEPAGE="https://gcc.gnu.org/"
LICENSE="GPL-3.0-or-later"
GFMABI="15"
PVmaj=${PV%%.*}
case ${PV} in
*+20[1-9][0-9][0-1][0-9][0-3][0-9]) # snapshot
SD=${PV##*+}
SRC_URI=" mirror://gcc/snapshots/${PVmaj}-${SD}/gcc-${PVmaj}-${SD}.tar.xz"
SRC_URI+=" mirror://gcc/snapshots/${PVmaj}-${SD}/sha512.sum#/gcc-${PVmaj}-${SD}.tar.xz.sha512"
SRC_DIR="gcc-${PVmaj}-${SD}"
;;
*) # release
SRC_URI=" mirror://gnu/gcc/gcc-${PV}/gcc-${PV}.tar.xz"
SRC_URI+=" mirror://gnu/gcc/gcc-${PV}/gcc-${PV}.tar.xz.sig"
SRC_DIR="gcc-${PV}"
;;
esac
SRC_URI+=" Cygwin-libstdc++-locale.patch"
# patches re-created in cygwin-gcc git branch cygwin-11.3.1
PATCH_URI="
0001-Cygwin-use-SysV-ABI-on-x86_64.patch
0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch
0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch
0004-Cygwin-MinGW-skip-test.patch
0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch
0007-Cygwin-__cxa-atexit.patch
0008-Cygwin-libgomp-soname.patch
0009-Cygwin-g-time.patch
0010-Cygwin-newlib-ftm.patch
0011-Cygwin-define-STD_UNIX.patch
"
# already fixed in snapshot
# 0006-Cygwin-fix-some-implicit-declaration-warnings-and-re.patch
#DISABLE_BOOTSTRAP=1
defined DISABLE_BOOTSTRAP &&
inform "Disable Bootstrapping."
LIBGCCJIT=1
if defined DISABLE_LIBGCCJIT
then
inform "Support for libgccjit disabled."
else
PATCH_URI+="
0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch
0102-Cygwin-testsuite-fixes-for-libgccjit.patch
"
inform "Support for libgccjit enabled."
fi
# Ada
PATCH_URI+="
0201-Cygwin-ada-shared-prefix.patch
"
# CI hints
SCALLYWAG="nobuild notest nodeploy"
# new files created by patches, need to be removed if re-prep'ing
DISTCLEANFILES="config/mt-cygwin gcc/ada/system-cygwin-x86_64.ads libgomp/config/cygwin/plugin-suffix.h"
# These must not be set in the environment, but main cygport
# script tries to be too helpful here and confuses auto-detection
# process during gcc build stages.
unset CC CXX F77 FC GCJ GOC OBJC OBJCXX FCFLAGS FFLAGS CFLAGS CXXFLAGS
CYGPORT_USE_UNSTABLE_API=1
src_unpack_hook() {
chmod a+x gcc/testsuite/ada/acats/run_test.exp
}
# gccgo: requires
# libexecdir: http://cygwin.com/ml/cygwin/2013-11/msg00018.html et al
# libssp: conflicts with builtin SSP
CYGCONF_ARGS="
--libexecdir=/usr/lib
--with-gcc-major-version-only
--enable-shared --enable-shared-libgcc --enable-static
--enable-version-specific-runtime-libs
$(cross_compiling || echo --enable-bootstrap)
--enable-__cxa_atexit
--with-dwarf2
${ARCH_i686+--with-arch=i686} --with-tune=generic
${ARCH_i686+--disable-sjlj-exceptions}
${DISABLE_BOOTSTRAP+--disable-bootstrap}
--enable-languages=ada,c,c++,d,fortran,lto,objc,obj-c++${LIBGCCJIT+,jit}
--enable-graphite
--enable-threads=posix
--enable-libatomic
--enable-libgomp
--enable-libquadmath
--enable-libquadmath-support
--disable-libssp
--enable-libada
--disable-symvers
--disable-multilib
--with-gnu-ld --with-gnu-as
--with-cloog-include=$(${TOOLCHAIN_TARGET}-gcc -print-sysroot)/usr/include/cloog-isl
--without-libiconv-prefix
--without-libintl-prefix
--with-system-zlib
--enable-linker-build-id
--with-default-libstdcxx-abi=gcc4-compatible
--enable-libstdcxx-filesystem-ts
"
MAKEOPTS+=" -Otarget"
src_compile() {
# Enable c++ locale features for not just "C" locale.
cd ${S}
rm -r libstdc++-v3/config/locale/generic
cp -r libstdc++-v3/config/locale/gnu libstdc++-v3/config/locale/generic
patch -p 3 < Cygwin-libstdc++-locale.patch
cd ${B}
# use built-in SSP with Cygwin 2.10
# FIXME: --disable-libssp should suffice in GCC 8
# export gcc_cv_libc_provides_ssp=yes
# configure tries to test SUSv4-compliant behaviour of
# realpath(..., NULL) via _XOPEN_VERSION
export glibcxx_cv_realpath=yes
___CFLAGS=`echo ${CFLAGS} | sed s/-Werror=format-security/-Wformat-security/g`
___CFLAGS=`echo ${___CFLAGS} | sed s/\(-Wp,\)\?-D_FORTIFY_SOURCE=[12]//g`
___CFLAGS=`echo ${___CFLAGS} | sed 's/[[:blank:]]\+/ /g'`
___CXXFLAGS=`echo ${CXXFLAGS} | sed s/-Werror=format-security/-Wformat-security/g`
___CXXFLAGS=`echo ${___CXXFLAGS} | sed s/\(-Wp,\)\?-D_FORTIFY_SOURCE=[12]//g`
___CXXFLAGS=`echo ${___CXXFLAGS} | sed 's/[[:blank:]]\+/ /g'`
export CFLAGS=${___CFLAGS}
export CXXFLAGS=${___CXXFLAGS}
# MingW64 header clash
export CPPFLAGS+=" -DWIN32_LEAN_AND_MEAN"
# parallel make encounters problems frequently
defined CYGPORT_RECOMPILE && echo recompile only ||
cygconf # CYGCONF_ARGS defined above
# make hangs after finishing everything on x86_64?
#cygmake BOOT_CFLAGS="${CXXFLAGS}"
make ${MAKEOPTS} BOOT_CFLAGS="${CXXFLAGS}" || true
}
# override default src_test, as we need to ignore failures and
# add build subdirectories to path so DLLs can definitely be found.
src_test() {
local gccpath
gccpath="${B}/gcc/ada/rts:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libgcc/shlib:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libatomic/.libs:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libgfortran/.libs:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libgomp/.libs:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libobjc/.libs:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libquadmath/.libs:"
gccpath+="${B}/${TOOLCHAIN_TARGET}/libstdc++-v3/src/.libs:"
cd ${B}
# cygtest doesn't work since btest_gnudebuglink has no creation rule
[ "no" != "${CYGPORT_RUN_UNSTABLE_TESTS-no}" ] &&
PATH="${gccpath}${PATH}" make ${MAKEOPTS} -k check ||
echo "Unstable test, set CYGPORT_RUN_UNSTABLE_TESTS to run."
}
src_install() {
cd ${B}
# Appears to be a problem with parallel install; finclude/ dir
# ends up empty somehow.
cyginstall -j1
# Workaround GCC install bug
if defined ARCH_x86_64
then
mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/lib/libgcc_s.dll.a ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/
#mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/lib32/libgcc_s.dll.a ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/32/
fi
# Move GDB auto-load to correct name and location
dodir /usr/share/gdb/auto-load/usr/bin
sed -i -e "/^libdir/ s|/lib/gcc/.*|/bin'|" \
${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++.dll.a-gdb.py
mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++.dll.a-gdb.py \
${D}/usr/share/gdb/auto-load/usr/bin/cygstdc++-6.dll-gdb.py
python_optimize /usr/share/gcc-${PVmaj}/python
# Move ADA DLLs
mv -v ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adalib/cyggna*.dll ${D}/usr/bin/
# rename libgna cyggna ${D}/usr/bin/libgna*.dll
# Now move docs to correct location
mkdir -p ${D}/usr/share/doc/${PN}
tar -cj -C ${S} INSTALL | tar -xj -C ${D}/usr/share/doc/${PN}/
# create standard aliases
dosym gcc.exe /usr/bin/cc
dosym ../bin/cpp.exe /usr/lib/cpp
dosym gfortran.exe /usr/bin/f95
cat > ${D}/usr/bin/c89 <<_EOF
#!/bin/sh
fl="-std=c89"
for opt; do
case "\$opt" in
-ansi|-std=c89|-std=iso9899:1990) fl="";;
-std=*) echo "`basename \$0` called with non ANSI/ISO C option \$opt" >&2
exit 1;;
esac
done
exec /usr/bin/gcc \$fl \${1+"\$@"}
_EOF
cat > ${D}/usr/bin/c99 <<_EOF
#!/bin/sh
fl="-std=c99"
for opt; do
case "\$opt" in
-std=c99|-std=iso9899:1999) fl="";;
-std=*) echo "`basename \$0` called with non ISO C99 option \$opt" >&2
exit 1;;
esac
done
exec /usr/bin/gcc \$fl \${1+"\$@"}
_EOF
chmod 755 ${D}/usr/bin/c?9
# clean-up include-fixed
mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include-fixed/*limits.h \
${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/
rm -fr ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include-fixed/
}
KEEP_LA_FILES="none"
PKG_NAMES="${PN}-ada ${PN}-core ${PN}-g++ ${PN}-gdc ${PN}-fortran ${PN}-objc ${PN}-objc++"
PKG_NAMES+=" libatomic1 libgcc1 libgfortran5 libgomp1 libgnat11 libobjc4 libstdc++6 libquadmath0"
defined LIBGCCJIT &&
PKG_NAMES+=" libgccjit0"
gcc_REQUIRES="${PN}${PVmaj} ${PN}-g++"
gcc_ada_SUMMARY="${SUMMARY} (Ada)"
gcc_ada_REQUIRES="${PN}${PVmaj}"
gcc_ada_CONTENTS="
usr/bin/gnat*.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/ada_target_properties
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adainclude
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adalib
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/gnat1.exe
usr/share/info/gnat-style.info*
usr/share/info/gnat_rm.info*
usr/share/info/gnat_ugn.info*
"
gcc_core_SUMMARY="${SUMMARY} (C, OpenMP)"
gcc_core_REQUIRES="binutils cygwin-devel w32api-headers w32api-runtime windows-default-manifest"
gcc_core_OBSOLETES="${PN}-ada ${PN}-cilkplus"
gcc_core_PROVIDES="${PN}${PVmaj}"
gcc_core_CONTENTS="
--exclude=jni*.h
usr/bin/cc
usr/bin/c89
usr/bin/c99
usr/bin/cpp.exe
usr/bin/gcc.exe
usr/bin/gcc-ar.exe
usr/bin/gcc-nm.exe
usr/bin/gcc-ranlib.exe
usr/bin/gcov.exe
usr/bin/gcov-tool.exe
usr/bin/gcov-dump.exe
usr/bin/lto-dump.exe
usr/bin/${TOOLCHAIN_TARGET}-gcc-${PVmaj}.exe
usr/bin/${TOOLCHAIN_TARGET}-gcc.exe
usr/bin/${TOOLCHAIN_TARGET}-gcc-ar.exe
usr/bin/${TOOLCHAIN_TARGET}-gcc-nm.exe
usr/bin/${TOOLCHAIN_TARGET}-gcc-ranlib.exe
usr/lib/cpp
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/*.h
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/install-tools
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/collect2.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/crt*.o
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cyglto_plugin.dll
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libatomic.*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgcc*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgcov.*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgomp.*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libquadmath.*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/lto*.exe
usr/share/doc/${PN}/
usr/share/info/cpp.info*
usr/share/info/cppinternals.info*
usr/share/info/gcc.info*
usr/share/info/gccinstall.info*
usr/share/info/gccint.info*
usr/share/info/libgomp.info*
usr/share/info/libquadmath.info*
usr/share/locale/*
usr/share/man/man1/cpp.1*
usr/share/man/man1/gcc.1*
usr/share/man/man1/gcov.1*
usr/share/man/man1/gcov-dump.1.*
usr/share/man/man1/gcov-tool.1.*
usr/share/man/man1/lto-dump.1.*
usr/share/man/man7/fsf-funding.7*
usr/share/man/man7/gfdl.7*
usr/share/man/man7/gpl.7*
"
gcc_g___SUMMARY="${SUMMARY} (C++)"
gcc_g___REQUIRES="${PN}${PVmaj}"
gcc_g___CONTENTS="
--exclude=gnu
usr/bin/c++.exe
usr/bin/g++.exe
usr/bin/${TOOLCHAIN_TARGET}-c++.exe
usr/bin/${TOOLCHAIN_TARGET}-g++.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1plus.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/g++-mapper-server.exe*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/c++
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++*
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libsupc++*
usr/share/man/man1/g++.1*
"
gcc_gdc_SUMMARY="${SUMMARY} (D)"
gcc_gdc_REQUIRES="${PN}${PVmaj}"
gcc_gdc_CONTENTS="
--exclude=gnu
usr/bin/gdc.exe
usr/bin/${TOOLCHAIN_TARGET}-gdc.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/d21.exe
usr/share/info/gdc.info*
usr/share/man/man1/gdc.1*
"
gcc_fortran_SUMMARY="${SUMMARY} (Fortran)"
gcc_fortran_REQUIRES="${PN}${PVmaj}"
gcc_fortran_PROVIDES="gfm${GFMABI}" # GNU Fortran Module version
gcc_fortran_CONTENTS="
usr/bin/f95
usr/bin/gfortran.exe
usr/bin/${TOOLCHAIN_TARGET}-gfortran.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/finclude/
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/f951.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libcaf_single.a
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgfortran*
usr/share/info/gfortran.info*
usr/share/man/man1/gfortran.1*
"
gcc_objc_SUMMARY="${SUMMARY} (Objective-C)"
gcc_objc_REQUIRES="${PN}${PVmaj}"
gcc_objc_CONTENTS="
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/objc/
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1obj.exe
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libobjc.*
"
gcc_objc___SUMMARY="${SUMMARY} (Objective-C++)"
gcc_objc___REQUIRES="${PN}${PVmaj} ${PN}-g++ ${PN}-objc"
gcc_objc___CONTENTS="
usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1objplus.exe
"
libatomic1_CATEGORY="Libs"
libatomic1_SUMMARY="GCC C11/C++11 locked atomics runtime library"
libatomic1_CONTENTS="usr/bin/cygatomic-1.dll"
libgcc1_CATEGORY="Libs"
libgcc1_SUMMARY="GCC C runtime library"
libgcc1_CONTENTS="usr/bin/cyggcc_s${ARCH_x86_64+-seh}-1.dll"
libgfortran5_CATEGORY="Libs"
libgfortran5_SUMMARY="GCC Fortran runtime library"
libgfortran5_CONTENTS="usr/bin/cyggfortran-5.dll"
libgnat11_CATEGORY="Libs"
libgnat11_SUMMARY="GCC Ada runtime library"
libgnat11_CONTENTS="usr/bin/cyggnarl-11.dll usr/bin/cyggnat-11.dll"
libgomp1_CATEGORY="Libs"
libgomp1_SUMMARY="GCC OpenMP runtime library"
libgomp1_CONTENTS="usr/bin/cyggomp-1.dll"
libobjc4_CATEGORY="Libs"
libobjc4_SUMMARY="GCC Objective-C runtime library"
libobjc4_CONTENTS="usr/bin/cygobjc-4.dll"
libstdc__6_CATEGORY="Libs"
libstdc__6_SUMMARY="GCC C++ runtime library"
libstdc__6_CONTENTS="usr/bin/cygstdc++-6.dll"
libstdc__devel_CATEGORY="_obsolete"
libstdc__devel_SUMMARY="Obsolete package"
libquadmath0_CATEGORY="Libs"
libquadmath0_SUMMARY="GCC Quad-Precision Math runtime library"
libquadmath0_CONTENTS="usr/bin/cygquadmath-0.dll"
libvtv0_CATEGORY="Libs"
libvtv0_SUMMARY="GCC vtable verification library"
libvtv0_CONTENTS="usr/bin/cygvtv-0.dll usr/bin/cygvtv_stubs-0.dll"
gcc_debuginfo_CONTENTS+=" usr/share/gcc-${PVmaj}/python/libstdcxx/"
if defined LIBGCCJIT
then
inform "Package libgccjit0 will be provided."
libgccjit0_CATEGORY="Libs"
libgccjit0_SUMMARY="GCC JIT runtime library, header files and documentation"
libgccjit0_CONTENTS="
usr/bin/cyggccjit-0.dll
usr/include/libgccjit*
usr/lib/libgccjit.dll.a
usr/share/info/libgccjit.info.gz
"
libgccjit0_REQUIRES="gcc-core"
fi
DIFF_EXCLUDES="
c_locale.cc
c_locale.h
c++locale_internal.h
codecvt_members.cc
collate_members.cc
ctype_members.cc
messages_members.cc
messages_members.h
monetary_members.cc
numeric_members.cc
time_members.cc
time_members.h
"