Skip to content
Snippets Groups Projects
Commit cb31856f authored by Bernhard Rosenkränzer's avatar Bernhard Rosenkränzer Committed by Stefan Schmidt
Browse files

gcc: Add a gcc 12 snapshot


This commit is identical to what I have submitted upstream and what
has since been picked up by upstream devs.

It is not yet committed upstream because upstream would rather wait
for an official gcc 12-rc, but upstream's gcc 12 will have the same
patches when it arrives.

Signed-off-by: default avatarBernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
parent b58a945b
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !87. Comments created here will be created in the context of that merge request.
Showing
with 1834 additions and 14 deletions
require gcc-common.inc
# Third digit in PV should be incremented after a minor release
PV = "12.0.1"
# BINV should be incremented to a revision after a minor gcc release
BINV = "12.0.1"
MAJOR = "12"
SNAPSHOT = "20220313"
FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:"
DEPENDS =+ "mpfr gmp libmpc zlib flex-native"
NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native"
LICENSE = "GPL-3.0-with-GCC-exception & GPL-3.0-only"
LIC_FILES_CHKSUM = "\
file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \
file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \
file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \
file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \
"
#RELEASE ?= "5b2ac9b40c325e9209c0bd55955db84aad4a0cc5"
#BASEURI ?= "https://github.com/gcc-mirror/gcc/archive/${RELEASE}.zip;downloadfilename=gcc-${PV}-${RELEASE}.zip"
BASEURI ?= "https://mirror.koddos.net/gcc/snapshots/${MAJOR}-${SNAPSHOT}/gcc-${MAJOR}-${SNAPSHOT}.tar.xz \
"
SRC_URI = "\
${BASEURI} \
file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \
file://0002-gcc-poison-system-directories.patch \
file://0004-64-bit-multilib-hack.patch \
file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
file://0009-cpp-honor-sysroot.patch \
file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
file://0014-libtool.patch \
file://0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \
file://0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch \
file://0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \
file://0019-Ensure-target-gcc-headers-can-be-included.patch \
file://0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch \
file://0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
file://0024-handle-sysroot-support-for-nativesdk-gcc.patch \
file://0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
file://0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
file://0033-Re-introduce-spe-commandline-options.patch \
file://0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \
file://0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
file://0036-mingw32-Enable-operation_not_supported.patch \
file://0037-libatomic-Do-not-enforce-march-on-aarch64.patch \
file://0006-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch \
file://0001-Fix-install-path-of-linux64.h.patch \
"
SRC_URI[sha256sum] = "979d8cbe9b2ed2ab4434f52097754e004a207cf6541aea3e167c5d0f74957633"
S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${MAJOR}-${SNAPSHOT}"
# For dev release snapshotting
#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}"
#B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
# Language Overrides
FORTRAN = ""
JAVA = ""
SSP ?= "--disable-libssp"
SSP:mingw32 = "--enable-libssp"
EXTRA_OECONF_BASE = "\
${SSP} \
--enable-libitm \
--enable-lto \
--disable-bootstrap \
--with-system-zlib \
${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \
--enable-linker-build-id \
--with-ppl=no \
--with-cloog=no \
--enable-checking=release \
--enable-cheaders=c_global \
--without-isl \
"
EXTRA_OECONF_INITIAL = "\
--disable-libgomp \
--disable-libitm \
--disable-libquadmath \
--with-system-zlib \
--disable-lto \
--disable-plugin \
--enable-linker-build-id \
--enable-decimal-float=no \
--without-isl \
--disable-libssp \
"
EXTRA_OECONF_PATHS = "\
--with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
# Is a binutils 2.26 issue, not gcc
CVE_CHECK_IGNORE += "CVE-2021-37322"
SUMMARY = "GNU cc and gcc C compilers"
HOMEPAGE = "http://www.gnu.org/software/gcc/"
DESCRIPTION = "The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages (libstdc++,...). GCC was originally written as the compiler for the GNU operating system."
SECTION = "devel"
LICENSE = "GPL"
NATIVEDEPS = ""
CVE_PRODUCT = "gcc"
inherit autotools gettext texinfo
BPN = "gcc"
COMPILERDEP = "virtual/${MLPREFIX}${TARGET_PREFIX}gcc:do_gcc_stash_builddir"
COMPILERDEP:class-nativesdk = "virtual/${TARGET_PREFIX}gcc-crosssdk:do_gcc_stash_builddir"
python extract_stashed_builddir () {
src = d.expand("${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}")
dest = d.getVar("B")
oe.path.copyhardlinktree(src, dest)
staging_processfixme([src + "/fixmepath"], dest, d.getVar("RECIPE_SYSROOT"), d.getVar("RECIPE_SYSROOT_NATIVE"), d)
}
def get_gcc_float_setting(bb, d):
if d.getVar('ARMPKGSFX_EABI') == "hf" and d.getVar('TRANSLATED_TARGET_ARCH') == "arm":
return "--with-float=hard"
if d.getVar('TARGET_FPU') in [ 'soft' ]:
return "--with-float=soft"
if d.getVar('TARGET_FPU') in [ 'ppc-efd' ]:
return "--enable-e500_double"
return ""
get_gcc_float_setting[vardepvalue] = "${@get_gcc_float_setting(bb, d)}"
def get_gcc_mips_plt_setting(bb, d):
if d.getVar('TRANSLATED_TARGET_ARCH') in [ 'mips', 'mipsel' ] and bb.utils.contains('DISTRO_FEATURES', 'mplt', True, False, d):
return "--with-mips-plt"
return ""
def get_gcc_ppc_plt_settings(bb, d):
if d.getVar('TRANSLATED_TARGET_ARCH') in [ 'powerpc', 'powerpc64' ] and not bb.utils.contains('DISTRO_FEATURES', 'bssplt', True, False, d):
return "--enable-secureplt"
return ""
def get_gcc_multiarch_setting(bb, d):
target_arch = d.getVar('TRANSLATED_TARGET_ARCH')
multiarch_options = {
"i586": "--enable-targets=all",
"i686": "--enable-targets=all",
"powerpc": "--enable-targets=powerpc64",
"powerpc64le": "--enable-targets=powerpcle",
"mips": "--enable-targets=all",
"sparc": "--enable-targets=all",
}
if bb.utils.contains('DISTRO_FEATURES', 'multiarch', True, False, d):
if target_arch in multiarch_options :
return multiarch_options[target_arch]
return ""
# this is used by the multilib setup of gcc
def get_tune_parameters(tune, d):
availtunes = d.getVar('AVAILTUNES')
if tune not in availtunes.split():
bb.error('The tune: %s is not one of the available tunes: %s' % (tune or None, availtunes))
localdata = bb.data.createCopy(d)
override = ':tune-' + tune
localdata.setVar('OVERRIDES', localdata.getVar('OVERRIDES', False) + override)
retdict = {}
retdict['tune'] = tune
retdict['ccargs'] = localdata.getVar('TUNE_CCARGS')
retdict['features'] = localdata.getVar('TUNE_FEATURES')
# BASELIB is used by the multilib code to change library paths
retdict['baselib'] = localdata.getVar('BASE_LIB') or localdata.getVar('BASELIB')
retdict['arch'] = localdata.getVar('TUNE_ARCH')
retdict['abiextension'] = localdata.getVar('ABIEXTENSION')
retdict['target_fpu'] = localdata.getVar('TARGET_FPU')
retdict['pkgarch'] = localdata.getVar('TUNE_PKGARCH')
retdict['package_extra_archs'] = localdata.getVar('PACKAGE_EXTRA_ARCHS')
return retdict
get_tune_parameters[vardepsexclude] = "AVAILTUNES TUNE_CCARGS OVERRIDES TUNE_FEATURES BASE_LIB BASELIB TUNE_ARCH ABIEXTENSION TARGET_FPU TUNE_PKGARCH PACKAGE_EXTRA_ARCHS"
DEBIANNAME:${MLPREFIX}libgcc = "libgcc1"
MIRRORS =+ "\
${GNU_MIRROR}/gcc https://gcc.gnu.org/pub/gcc/releases/ \
"
#
# Set some default values
#
gcclibdir = "${libdir}/gcc"
BINV = "${PV}"
#S = "${WORKDIR}/gcc-${PV}"
S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
target_includedir ?= "${includedir}"
target_libdir ?= "${libdir}"
target_base_libdir ?= "${base_libdir}"
target_prefix ?= "${prefix}"
# We need to ensure that for the shared work directory, the do_patch signatures match
# The real WORKDIR location isn't a dependency for the shared workdir.
src_patches[vardepsexclude] = "WORKDIR"
should_apply[vardepsexclude] += "PN"
require gcc-multilib-config.inc
require gcc-shared-source.inc
#
# Build the list of lanaguages to build.
#
# These can be overridden by the version specific .inc file.
# gcc 3.x expects 'f77', 4.0 expects 'f95', 4.1 and 4.2 expect 'fortran'
FORTRAN ?= ",f77"
LANGUAGES ?= "c,c++${FORTRAN}"
EXTRA_OECONF_BASE ?= ""
EXTRA_OECONF_PATHS ?= ""
GCCMULTILIB ?= "--disable-multilib"
GCCTHREADS ?= "posix"
GCCPIE ??= ""
SYMVERS_CONF ?= "--enable-symvers=gnu"
EXTRA_OECONF = "\
${@['--enable-clocale=generic', ''][d.getVar('USE_NLS') != 'no']} \
--with-gnu-ld \
--enable-shared \
--enable-languages=${LANGUAGES} \
--enable-threads=${GCCTHREADS} \
${GCCMULTILIB} \
${GCCPIE} \
--enable-c99 \
--enable-long-long \
${SYMVERS_CONF} \
--enable-libstdcxx-pch \
--program-prefix=${TARGET_PREFIX} \
--without-local-prefix \
--disable-install-libiberty \
${EXTRA_OECONF_BASE} \
${EXTRA_OECONF_GCC_FLOAT} \
${EXTRA_OECONF_PATHS} \
${@get_gcc_mips_plt_setting(bb, d)} \
${@get_gcc_ppc_plt_settings(bb, d)} \
${@get_gcc_multiarch_setting(bb, d)} \
--enable-standard-branch-protection \
"
# glibc version is a minimum controlling whether features are enabled.
# Doesn't need to track glibc exactly
EXTRA_OECONF:append:libc-glibc = " --with-glibc-version=2.28 "
# Set this here since GCC configure won't auto-detect and enable
# initfini-arry when cross compiling.
EXTRA_OECONF:append = " --enable-initfini-array"
export gcc_cv_collect2_libs = 'none required'
# We need to set gcc_cv_collect2_libs else there is cross-compilation badness
# in the config.log files (which might not get generated until do_compile
# hence being missed by the insane do_configure check).
EXTRA_OECONF:append:linux = " --enable-__cxa_atexit"
EXTRA_OECONF:append:mips64 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
EXTRA_OECONF:append:mips64el = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
EXTRA_OECONF:append:mips64n32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
EXTRA_OECONF:append:mips64eln32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
EXTRA_OECONF:append:mipsisa32r6el = " --with-abi=32 --with-arch=mips32r6"
EXTRA_OECONF:append:mipsisa32r6 = " --with-abi=32 --with-arch=mips32r6"
EXTRA_OECONF:append:mipsisa64r6el = " --with-abi=64 --with-arch-64=mips64r6"
EXTRA_OECONF:append:mipsisa64r6 = " --with-abi=64 --with-arch-64=mips64r6"
EXTRA_OECONF_GCC_FLOAT ??= ""
CPPFLAGS = ""
SYSTEMHEADERS = "${target_includedir}"
SYSTEMLIBS = "${target_base_libdir}/"
SYSTEMLIBS1 = "${target_libdir}/"
do_configure:prepend () {
# teach gcc to find correct target includedir when checking libc ssp support
mkdir -p ${B}/gcc
echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${B}/gcc/t-oe
cat ${S}/gcc/defaults.h | grep -v "\#endif.*GCC_DEFAULTS_H" > ${B}/gcc/defaults.h.new
cat >>${B}/gcc/defaults.h.new <<_EOF
#define NATIVE_SYSTEM_HEADER_DIR "${SYSTEMHEADERS}"
#define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}"
#define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}"
#define SYSTEMLIBS_DIR "${SYSTEMLIBS}"
#endif /* ! GCC_DEFAULTS_H */
_EOF
mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h
}
do_configure () {
# Setup these vars for cross building only
# ... because foo_FOR_TARGET apparently gets misinterpreted inside the
# gcc build stuff when the build is producing a cross compiler - i.e.
# when the 'current' target is the 'host' system, and the host is not
# the target (because the build is actually making a cross compiler!)
if [ "${BUILD_SYS}" != "${HOST_SYS}" ]; then
export CC_FOR_TARGET="${CC}"
export GCC_FOR_TARGET="${CC}"
export CXX_FOR_TARGET="${CXX}"
export AS_FOR_TARGET="${HOST_PREFIX}as"
export LD_FOR_TARGET="${HOST_PREFIX}ld"
export NM_FOR_TARGET="${HOST_PREFIX}nm"
export AR_FOR_TARGET="${HOST_PREFIX}ar"
export GFORTRAN_FOR_TARGET="gfortran"
export RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib"
fi
export CC_FOR_BUILD="${BUILD_CC}"
export CXX_FOR_BUILD="${BUILD_CXX}"
export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
oe_runconf
}
inherit cross-canadian
SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc"
GCCMULTILIB = "--enable-multilib"
require gcc-configure-common.inc
EXTRA_OECONF_PATHS = "\
--with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
--with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
# We have to point gcc at a sysroot but we don't need to rebuild if this changes
# e.g. we switch between different machines with different tunes.
EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
get_gcc_float_setting[vardepvalue] = ""
#
# gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky
# for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse.
#
export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
export AS_FOR_TARGET = "${TARGET_PREFIX}as"
export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool"
export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc"
export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo"
export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump"
export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
#
# We need to override this and make sure the compiler can find staging
#
export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
do_configure () {
if [ ! -d ${RECIPE_SYSROOT}/${target_includedir} ]; then
mkdir -p ${RECIPE_SYSROOT}/${target_includedir}
fi
export CC_FOR_BUILD="${BUILD_CC}"
export CXX_FOR_BUILD="${BUILD_CXX}"
export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
oe_runconf
}
do_compile () {
oe_runmake all-host configure-target-libgcc
(cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
}
PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
FILES:${PN} = "\
${exec_prefix}/bin/* \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \
${gcclibdir}/${TARGET_SYS}/${BINV}/include \
${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
${libdir}/bfd-plugins/*.so \
${includedir}/c++/${BINV} \
${prefix}/${TARGET_SYS}/bin/* \
${prefix}/${TARGET_SYS}/lib/* \
${prefix}/${TARGET_SYS}${target_includedir}/* \
"
INSANE_SKIP:${PN} += "dev-so"
FILES:${PN}-doc = "\
${infodir} \
${mandir} \
${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
"
EXEEXT = ""
# Compute how to get from libexecdir to bindir in python (easier than shell)
BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
# linker plugin path
LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}"
do_install () {
( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
oe_runmake 'DESTDIR=${D}' install-host
# Cleanup some of the ${libdir}{,exec}/gcc stuff ...
rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
# We care about g++ not c++
rm -f ${D}${bindir}/*c++
# We don't care about the gcc-<version> copies
rm -f ${D}${bindir}/*gcc-${BINV}*
# Cleanup empty directories which are not shipped
# we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
# ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686
local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}"
for i in $empty_dirs; do
[ -d $i ] && rmdir --ignore-fail-on-non-empty $i
done
# Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
# found.
dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
install -d $dest
suffix=${EXEEXT}
for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
continue
fi
ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
done
t=real-ld
ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix
# libquadmath headers need to be available in the gcc libexec dir
install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
# install LTO linker plugins where binutils tools can find it
install -d ${D}${libdir}/bfd-plugins
ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
chown -R root:root ${D}
cross_canadian_bindirlinks
for i in linux ${CANADIANEXTRAOS}
do
for v in ${CANADIANEXTRAVENDOR}
do
d=${D}${bindir}/../${TARGET_ARCH}$v-$i
install -d $d
for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
do
p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
case $i in
*musl*)
rm -rf $d/$p
echo "#!/usr/bin/env sh" > $d/$p
echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
chmod 0755 $d/$p
;;
*)
;;
esac
done
done
done
}
ELFUTILS = "nativesdk-elfutils"
DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib"
RDEPENDS:${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
SYSTEMHEADERS = "${target_includedir}/"
SYSTEMLIBS = "${target_base_libdir}/"
SYSTEMLIBS1 = "${target_libdir}/"
EXTRA_OECONF += "--enable-poison-system-directories"
# gcc 4.7 needs -isystem
export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"
require recipes-devtools/gcc/gcc-${PV}.inc
require gcc-cross-canadian.inc
inherit cross
INHIBIT_DEFAULT_DEPS = "1"
EXTRADEPENDS = ""
DEPENDS = "virtual/${TARGET_PREFIX}binutils ${EXTRADEPENDS} ${NATIVEDEPS}"
PROVIDES = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++"
python () {
if d.getVar("TARGET_OS").startswith("linux"):
d.setVar("EXTRADEPENDS", "linux-libc-headers")
}
PN = "gcc-cross-${TARGET_ARCH}"
# Ignore how TARGET_ARCH is computed.
TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
require gcc-configure-common.inc
# While we want the 'gnu' hash style, we explicitly set it to sysv here to
# ensure that any recipe which doesn't obey our LDFLAGS (which also set it to
# gnu) will hit a QA failure.
LINKER_HASH_STYLE ?= "sysv"
EXTRA_OECONF += "--enable-poison-system-directories=error"
EXTRA_OECONF:append:sh4 = " \
--with-multilib-list= \
--enable-incomplete-targets \
"
EXTRA_OECONF += "\
--with-system-zlib \
"
EXTRA_OECONF:append:libc-baremetal = " --without-headers"
EXTRA_OECONF:remove:libc-baremetal = "--enable-threads=posix"
EXTRA_OECONF:remove:libc-newlib = "--enable-threads=posix"
EXTRA_OECONF_PATHS = "\
--with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
do_configure:prepend () {
install -d ${RECIPE_SYSROOT}${target_includedir}
touch ${RECIPE_SYSROOT}${target_includedir}/limits.h
}
do_compile () {
export CC="${BUILD_CC}"
export AR_FOR_TARGET="${TARGET_SYS}-ar"
export RANLIB_FOR_TARGET="${TARGET_SYS}-ranlib"
export LD_FOR_TARGET="${TARGET_SYS}-ld"
export NM_FOR_TARGET="${TARGET_SYS}-nm"
export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
# Prevent native/host sysroot path from being used in configargs.h header,
# as it will be rewritten when used by other sysroots preventing support
# for gcc plugins
oe_runmake configure-gcc
sed -i 's@${STAGING_DIR_TARGET}@/host@g' ${B}/gcc/configargs.h
sed -i 's@${STAGING_DIR_HOST}@/host@g' ${B}/gcc/configargs.h
# Prevent sysroot/workdir paths from being used in checksum-options.
# checksum-options is used to generate a checksum which is embedded into
# the output binary.
oe_runmake TARGET-gcc=checksum-options all-gcc
sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options
sed -i 's@${STAGING_DIR_HOST}@/host@g' ${B}/gcc/checksum-options
oe_runmake all-host configure-target-libgcc
(cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
}
INHIBIT_PACKAGE_STRIP = "1"
# Compute how to get from libexecdir to bindir in python (easier than shell)
BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
# linker plugin path
LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/bfd-plugins"))}"
do_install () {
( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
oe_runmake 'DESTDIR=${D}' install-host
install -d ${D}${target_base_libdir}
install -d ${D}${target_libdir}
# Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
# gfortran is fully backwards compatible. This is a safe and practical solution.
if [ -n "${@d.getVar('FORTRAN')}" ]; then
ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
fortsymlinks="g77 gfortran"
fi
# Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
# found. These need to be relative paths so they work in different locations.
dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
install -d $dest
for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip gcc cpp $fortsymlinks; do
ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
done
# Remove things we don't need but keep share/java
for d in info man share/doc share/locale share/man share/info; do
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
done
# libquadmath headers need to be available in the gcc libexec dir
install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
find ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed -type f -not -name "README" -not -name limits.h -not -name syslimits.h | xargs rm -f
# install LTO linker plugins where binutils tools can find it
install -d ${D}${libdir}/bfd-plugins
ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
}
do_package[noexec] = "1"
do_packagedata[noexec] = "1"
do_package_write_ipk[noexec] = "1"
do_package_write_rpm[noexec] = "1"
do_package_write_deb[noexec] = "1"
inherit chrpath
python gcc_stash_builddir_fixrpaths() {
# rewrite rpaths, breaking hardlinks as required
process_dir("/", d.getVar("BUILDDIRSTASH"), d, break_hardlinks = True)
}
BUILDDIRSTASH = "${WORKDIR}/stashed-builddir/build"
do_gcc_stash_builddir[dirs] = "${B}"
do_gcc_stash_builddir[cleandirs] = "${BUILDDIRSTASH}"
do_gcc_stash_builddir[postfuncs] += "gcc_stash_builddir_fixrpaths"
do_gcc_stash_builddir () {
dest=${BUILDDIRSTASH}
hardlinkdir . $dest
# Makefile does move-if-change which can end up with 'timestamp' as file contents so break links to those files
rm $dest/gcc/include/*.h
cp gcc/include/*.h $dest/gcc/include/
}
addtask do_gcc_stash_builddir after do_compile before do_install
SSTATETASKS += "do_gcc_stash_builddir"
do_gcc_stash_builddir[sstate-inputdirs] = "${BUILDDIRSTASH}"
do_gcc_stash_builddir[sstate-outputdirs] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}"
do_gcc_stash_builddir[sstate-fixmedir] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}"
python do_gcc_stash_builddir_setscene () {
sstate_setscene(d)
}
addtask do_gcc_stash_builddir_setscene
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: Apache-2.0
do_configure:prepend () {
if ! echo ${@d.getVar("TARGET_OS")} | grep -qi linux; then
# Building Zephyr with DWARF-5 is problematic because
# its kernel tests use pyelftools, which has incomplete
# DWARF-5 support (even after applying preliminary
# support patches). Use DWARF-4 on Zephyr and FreeRTOS
# for the time being.
sed -i -e 's,Var(dwarf_version) Init(5),Var(dwarf_version) Init(4),' ${S}/gcc/common.opt
fi
}
require recipes-devtools/gcc/gcc-${PV}.inc
require gcc-cross.inc
inherit crosssdk
PN = "gcc-crosssdk-${SDK_SYS}"
SYSTEMHEADERS = "${SDKPATHNATIVE}${prefix_nativesdk}/include"
SYSTEMLIBS = "${SDKPATHNATIVE}${base_libdir_nativesdk}/"
SYSTEMLIBS1 = "${SDKPATHNATIVE}${libdir_nativesdk}/"
GCCMULTILIB = "--disable-multilib"
DEPENDS = "virtual/${TARGET_PREFIX}binutils-crosssdk gettext-native ${NATIVEDEPS}"
PROVIDES = "virtual/${TARGET_PREFIX}gcc-crosssdk virtual/${TARGET_PREFIX}g++-crosssdk"
require recipes-devtools/gcc/gcc-cross_${PV}.bb
require gcc-crosssdk.inc
# following code modifies these definitions in the gcc config
# MULTILIB_OPTIONS
# MULTILIB_DIRNAMES
# MULTILIB_OSDIRNAMES
# GLIBC_DYNAMIC_LINKER32
# GLIBC_DYNAMIC_LINKER64
# GLIBC_DYNAMIC_LINKERX32
# GLIBC_DYNAMIC_LINKERN32
# For more information on use of these variables look at these files in the gcc source code
# gcc/config/i386/t-linux64
# gcc/config/mips/t-linux64
# gcc/config/rs6000/t-linux64
# gcc/config/i386/linux64.h
# gcc/config/mips/linux64.h
# gcc/config/rs6000/linux64.h
MULTILIB_OPTION_WHITELIST ??= "-m32 -m64 -mx32 -mabi=n32 -mabi=32 -mabi=64"
python gcc_multilib_setup() {
import re
import shutil
import glob
srcdir = d.getVar('S')
builddir = d.getVar('B')
src_conf_dir = '%s/gcc/config' % srcdir
build_conf_dir = '%s/gcc/config' % builddir
bb.utils.remove(build_conf_dir, True)
ml_globs = ('%s/*/t-linux64' % src_conf_dir,
'%s/*/linux64.h' % src_conf_dir,
'%s/aarch64/t-aarch64' % src_conf_dir,
'%s/aarch64/aarch64.h' % src_conf_dir,
'%s/aarch64/aarch64-linux.h' % src_conf_dir,
'%s/aarch64/aarch64-cores.def' % src_conf_dir,
'%s/arm/linux-eabi.h' % src_conf_dir,
'%s/*/linux.h' % src_conf_dir,
'%s/linux.h' % src_conf_dir)
# copy the target multilib config files to ${B}
for ml_glob in ml_globs:
for fn in glob.glob(ml_glob):
rel_path = os.path.relpath(fn, src_conf_dir)
parent_dir = os.path.dirname(rel_path)
bb.utils.mkdirhier('%s/%s' % (build_conf_dir, parent_dir))
bb.utils.copyfile(fn, '%s/%s' % (build_conf_dir, rel_path))
pn = d.getVar('PN')
multilibs = (d.getVar('MULTILIB_VARIANTS') or '').split()
if not multilibs and pn != "nativesdk-gcc":
return
mlprefix = d.getVar('MLPREFIX')
if ('%sgcc' % mlprefix) != pn and (not pn.startswith('gcc-cross-canadian')) and pn != "nativesdk-gcc":
return
def write_config(root, files, options, dirnames, osdirnames):
for ml_conf_file in files:
with open(root + '/' + ml_conf_file, 'r') as f:
filelines = f.readlines()
# recreate multilib configuration variables
substs = [
(r'^(\s*(MULTILIB_OPTIONS\s*=).*)$', r'\2 %s' % '/'.join(options)),
(r'^(\s*MULTILIB_OPTIONS\s*\+=.*)$', ''),
(r'^(\s*(MULTILIB_DIRNAMES\s*=).*)$', r'\2 %s' % ' '.join(dirnames)),
(r'^(\s*MULTILIB_DIRNAMES\s*\+=.*)$', ''),
(r'^(\s*(MULTILIB_OSDIRNAMES\s*=).*)$', r'\2 %s' % ' '.join(osdirnames)),
(r'^(\s*MULTILIB_OSDIRNAMES\s*\+=.*)$', ''),
]
for (i, line) in enumerate(filelines):
for subst in substs:
line = re.sub(subst[0], subst[1], line)
filelines[i] = line
with open(root + '/' + ml_conf_file, 'w') as f:
f.write(''.join(filelines))
def write_headers(root, files, libdir32, libdir64, libdirx32, libdirn32):
def wrap_libdir(libdir):
if libdir.find('SYSTEMLIBS_DIR') != -1:
return '"%r"'
else:
return '"/%s/"' % libdir
for ml_conf_file in files:
fn = root + '/' + ml_conf_file
if not os.path.exists(fn):
continue
with open(fn, 'r') as f:
filelines = f.readlines()
# replace lines like
# #define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
# by
# #define GLIBC_DYNAMIC_LINKER32 "/lib/" "ld-linux.so.2"
# this is needed to put the correct dynamic loader path in the generated binaries
substs = [
(r'^(#define\s*GLIBC_DYNAMIC_LINKER32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
(r'^(#define\s*GLIBC_DYNAMIC_LINKER64\s*)(\S+)(\s*\"\S+\")$',
r'\1' + wrap_libdir(libdir64) + r'\3'),
(r'^(#define\s*GLIBC_DYNAMIC_LINKER64\s*\"\S+\"\s*)(\S+)(\s*\"\S+\"\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir64) + r'\3' + wrap_libdir(libdir64) + r'\5'),
(r'^(#define\s*GLIBC_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
(r'^(#define\s*GLIBC_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdirx32) + r'\3'),
(r'^(#define\s*GLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdirn32) + r'\3'),
(r'^(#define\s*UCLIBC_DYNAMIC_LINKER32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
(r'^(#define\s*UCLIBC_DYNAMIC_LINKER64\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir64) + r'\3'),
(r'^(#define\s*UCLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdirn32) + r'\3'),
(r'^(#define\s*UCLIBC_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdirx32) + r'\3'),
(r'^(#define\s*UCLIBC_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
(r'^(#define\s*MUSL_DYNAMIC_LINKER32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
(r'^(#define\s*MUSL_DYNAMIC_LINKER64\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir64) + r'\3'),
(r'^(#define\s*MUSL_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdirx32) + r'\3'),
(r'^(#define\s*MUSL_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
r'\1' + wrap_libdir(libdir32) + r'\3'),
]
for (i, line) in enumerate(filelines):
for subst in substs:
line = re.sub(subst[0], subst[1], line)
filelines[i] = line
with open(root + '/' + ml_conf_file, 'w') as f:
f.write(''.join(filelines))
gcc_target_config_files = {
'x86_64' : ['gcc/config/i386/t-linux64'],
'i586' : ['gcc/config/i386/t-linux64'],
'i686' : ['gcc/config/i386/t-linux64'],
'mips' : ['gcc/config/mips/t-linux64'],
'mips64' : ['gcc/config/mips/t-linux64'],
'powerpc' : ['gcc/config/rs6000/t-linux64'],
'powerpc64' : ['gcc/config/rs6000/t-linux64'],
'aarch64' : ['gcc/config/aarch64/t-aarch64'],
'arm' : ['gcc/config/aarch64/t-aarch64'],
}
gcc_header_config_files = {
'x86_64' : ['gcc/config/linux.h', 'gcc/config/i386/linux.h', 'gcc/config/i386/linux64.h'],
'i586' : ['gcc/config/linux.h', 'gcc/config/i386/linux.h', 'gcc/config/i386/linux64.h'],
'i686' : ['gcc/config/linux.h', 'gcc/config/i386/linux64.h'],
'mips' : ['gcc/config/linux.h', 'gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'],
'mips64' : ['gcc/config/linux.h', 'gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'],
'powerpc' : ['gcc/config/linux.h', 'gcc/config/rs6000/linux64.h'],
'powerpc64' : ['gcc/config/linux.h', 'gcc/config/rs6000/linux64.h'],
'aarch64' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'],
'arm' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'],
}
libdir32 = 'SYSTEMLIBS_DIR'
libdir64 = 'SYSTEMLIBS_DIR'
libdirx32 = 'SYSTEMLIBS_DIR'
libdirn32 = 'SYSTEMLIBS_DIR'
target_arch = (d.getVar('TARGET_ARCH_MULTILIB_ORIGINAL') if mlprefix
else d.getVar('TARGET_ARCH'))
if pn == "nativesdk-gcc":
header_config_files = gcc_header_config_files[d.getVar("SDK_ARCH")]
write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32)
return
if target_arch not in gcc_target_config_files:
bb.warn('gcc multilib setup is not supported for TARGET_ARCH=' + target_arch)
return
target_config_files = gcc_target_config_files[target_arch]
header_config_files = gcc_header_config_files[target_arch]
ml_list = ['DEFAULTTUNE_MULTILIB_ORIGINAL' if mlprefix else 'DEFAULTTUNE']
mltunes = [('DEFAULTTUNE:virtclass-multilib-%s' % ml) for ml in multilibs]
if mlprefix:
mlindex = 0
for ml in multilibs:
if mlprefix == ml + '-':
break
mlindex += 1
ml_list.extend(mltunes[:mlindex] + ['DEFAULTTUNE'] + mltunes[(mlindex + 1):])
else:
ml_list.extend(mltunes)
options = []
dirnames = []
osdirnames = []
optsets = []
for ml in ml_list:
tune = d.getVar(ml)
if not tune:
bb.warn("%s doesn't have a corresponding tune. Skipping..." % ml)
continue
tune_parameters = get_tune_parameters(tune, d)
tune_baselib = tune_parameters['baselib']
if not tune_baselib:
bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune)
continue
if tune_baselib == 'lib64':
libdir64 = tune_baselib
elif tune_baselib == 'libx32':
libdirx32 = tune_baselib
elif tune_baselib == 'lib32':
libdirn32 = tune_baselib
elif tune_baselib == 'lib':
libdir32 = tune_baselib
else:
bb.error('Unknown libdir (%s) of the tune : %s' % (tune_baselib, tune))
# take out '-' mcpu='s and march='s from parameters
opts = []
whitelist = (d.getVar("MULTILIB_OPTION_WHITELIST") or "").split()
for i in d.expand(tune_parameters['ccargs']).split():
if i in whitelist:
# Need to strip '-' from option
opts.append(i[1:])
options.append(" ".join(opts))
if tune_baselib == 'lib':
dirnames.append('32') # /lib => 32bit lib
else:
dirnames.append(tune_baselib.replace('lib', ''))
osdirnames.append('../' + tune_baselib)
write_config(builddir, target_config_files, options, dirnames, osdirnames)
write_headers(builddir, header_config_files, libdir32, libdir64, libdirx32, libdirn32)
}
gcc_multilib_setup[cleandirs] = "${B}/gcc/config"
gcc_multilib_setup[vardepsexclude] = "SDK_ARCH"
EXTRACONFFUNCS += "gcc_multilib_setup"
require gcc-configure-common.inc
SUMMARY = "Runtime libraries from GCC"
# Over-ride the LICENSE set by gcc-${PV}.inc to remove "& GPLv3"
# All gcc-runtime packages are now covered by the runtime exception.
LICENSE = "GPL-3.0-with-GCC-exception"
CXXFLAGS:remove = "-fvisibility-inlines-hidden"
EXTRA_OECONF_PATHS = "\
--with-gxx-include-dir=${includedir}/c++/${BINV} \
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu"
EXTRA_OECONF:append = " --cache-file=${B}/config.cache"
EXTRA_OECONF:append:libc-newlib = " --with-newlib"
# Disable ifuncs for libatomic on arm conflicts -march/-mcpu
EXTRA_OECONF:append:arm = " libat_cv_have_ifunc=no "
EXTRA_OECONF:append:armeb = " libat_cv_have_ifunc=no "
DISABLE_STATIC:class-nativesdk ?= ""
# Newlib does not support symbol versioning on libsdtcc++
SYMVERS_CONF:libc-newlib = ""
# Building with thumb enabled on armv6t fails
ARM_INSTRUCTION_SET:armv6 = "arm"
RUNTIMELIBITM = "libitm"
RUNTIMELIBITM:arc = ""
RUNTIMELIBITM:mipsarch = ""
RUNTIMELIBITM:nios2 = ""
RUNTIMELIBITM:microblaze = ""
RUNTIMELIBITM:riscv32 = ""
RUNTIMELIBITM:riscv64 = ""
RUNTIMELIBSSP ?= ""
RUNTIMELIBSSP:mingw32 ?= "libssp"
RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic ${RUNTIMELIBITM} \
${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'], 'libquadmath', '', d)} \
"
# Only build libstdc++ for newlib
RUNTIMETARGET:libc-newlib = "libstdc++-v3"
# libiberty
# libgfortran needs separate recipe due to libquadmath dependency
# Relative path to be repaced into debug info
REL_S = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
DEBUG_PREFIX_MAP:class-target = " \
-fdebug-prefix-map=${WORKDIR}/recipe-sysroot= \
-fdebug-prefix-map=${WORKDIR}/recipe-sysroot-native= \
-fdebug-prefix-map=${S}=${REL_S} \
-fdebug-prefix-map=${S}/include=${REL_S}/libstdc++-v3/../include \
-fdebug-prefix-map=${S}/libiberty=${REL_S}/libstdc++-v3/../libiberty \
-fdebug-prefix-map=${S}/libgcc=${REL_S}/libstdc++-v3/../libgcc \
-fdebug-prefix-map=${B}=${REL_S} \
-ffile-prefix-map=${B}/${HOST_SYS}/libstdc++-v3/include=${includedir}/c++/${BINV} \
"
do_configure () {
export CXX="${CXX} -nostdinc++ -L${WORKDIR}/dummylib"
# libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure
# tests. Create a dummy empty lib for the purposes of configure.
mkdir -p ${WORKDIR}/dummylib
touch ${WORKDIR}/dummylib/libstdc++.so
for d in libgcc ${RUNTIMETARGET}; do
echo "Configuring $d"
rm -rf ${B}/${TARGET_SYS}/$d/
mkdir -p ${B}/${TARGET_SYS}/$d/
cd ${B}/${TARGET_SYS}/$d/
chmod a+x ${S}/$d/configure
relpath=${@os.path.relpath("${S}/$d", "${B}/${TARGET_SYS}/$d")}
$relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
if [ "$d" = "libgcc" ]; then
(cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
fi
done
}
EXTRACONFFUNCS += "extract_stashed_builddir"
do_configure[depends] += "${COMPILERDEP}"
do_compile () {
for d in libgcc ${RUNTIMETARGET}; do
cd ${B}/${TARGET_SYS}/$d/
oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/
done
}
do_install () {
for d in ${RUNTIMETARGET}; do
cd ${B}/${TARGET_SYS}/$d/
oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/ install
done
if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include ]; then
install -d ${D}${libdir}/${TARGET_SYS}/${BINV}/include
mv ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/* ${D}${libdir}/${TARGET_SYS}/${BINV}/include
rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include
fi
rm -rf ${D}${infodir}/libgomp.info ${D}${infodir}/dir
rm -rf ${D}${infodir}/libitm.info ${D}${infodir}/dir
rm -rf ${D}${infodir}/libquadmath.info ${D}${infodir}/dir
if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude ]; then
rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
fi
if [ -d ${D}${infodir} ]; then
rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
fi
}
do_install:append:class-target () {
if [ "${TARGET_OS}" = "linux-gnuspe" ]; then
ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
fi
if [ "${TARGET_OS}" = "linux-gnun32" ]; then
if [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then
mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux
ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux/32
elif [ "${MULTILIB_VARIANTS}" != "" ]; then
mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux/32
else
ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
fi
elif [ "${TARGET_OS}" = "linux-gnux32" ]; then
if [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then
mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux
ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux/x32
elif [ "${MULTILIB_VARIANTS}" != "" ]; then
mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux/32
else
ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
fi
elif [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then
mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}
ln -s ../${TARGET_SYS}/bits ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/bits
ln -s ../${TARGET_SYS}/ext ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/ext
fi
if [ "${TARGET_ARCH}" == "x86_64" -a "${MULTILIB_VARIANTS}" != "" ];then
ln -sf ../${X86ARCH32}${TARGET_VENDOR}-${TARGET_OS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}/32
fi
if [ "${TCLIBC}" != "glibc" ]; then
case "${TARGET_OS}" in
"linux-musl" | "linux-*spe") extra_target_os="linux";;
"linux-musleabi") extra_target_os="linux-gnueabi";;
*) extra_target_os="linux";;
esac
ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-$extra_target_os
fi
chown -R root:root ${D}
}
INHIBIT_DEFAULT_DEPS = "1"
DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++ libgcc virtual/${MLPREFIX}libc"
PROVIDES = "virtual/${TARGET_PREFIX}compilerlibs"
BBCLASSEXTEND = "nativesdk"
PACKAGES = "\
${PN}-dbg \
libstdc++ \
libstdc++-precompile-dev \
libstdc++-dev \
libstdc++-staticdev \
libg2c \
libg2c-dev \
libssp \
libssp-dev \
libssp-staticdev \
libquadmath \
libquadmath-dev \
libquadmath-staticdev \
libgomp \
libgomp-dev \
libgomp-staticdev \
libatomic \
libatomic-dev \
libatomic-staticdev \
libitm \
libitm-dev \
libitm-staticdev \
"
# The base package doesn't exist, so we clear the recommends.
RRECOMMENDS:${PN}-dbg = ""
# include python debugging scripts
FILES:${PN}-dbg += "\
${libdir}/libstdc++.*-gdb.py \
${datadir}/gcc-${BINV}/python/libstdcxx \
"
FILES:libg2c = "${target_libdir}/libg2c.so.*"
SUMMARY:libg2c = "Companion runtime library for g77"
FILES:libg2c-dev = "\
${libdir}/libg2c.so \
${libdir}/libg2c.a \
${libdir}/libfrtbegin.a \
"
SUMMARY:libg2c-dev = "Companion runtime library for g77 - development files"
FILES:libstdc++ = "${libdir}/libstdc++.so.*"
SUMMARY:libstdc++ = "GNU standard C++ library"
FILES:libstdc++-dev = "\
${includedir}/c++/ \
${libdir}/libstdc++.so \
${libdir}/libstdc++*.la \
${libdir}/libsupc++.la \
"
SUMMARY:libstdc++-dev = "GNU standard C++ library - development files"
FILES:libstdc++-staticdev = "\
${libdir}/libstdc++*.a \
${libdir}/libsupc++.a \
"
SUMMARY:libstdc++-staticdev = "GNU standard C++ library - static development files"
FILES:libstdc++-precompile-dev = "${includedir}/c++/${TARGET_SYS}/bits/*.gch"
SUMMARY:libstdc++-precompile-dev = "GNU standard C++ library - precompiled header files"
FILES:libssp = "${libdir}/libssp.so.*"
SUMMARY:libssp = "GNU stack smashing protection library"
FILES:libssp-dev = "\
${libdir}/libssp*.so \
${libdir}/libssp*_nonshared.a \
${libdir}/libssp*.la \
${libdir}/${TARGET_SYS}/${BINV}/include/ssp \
"
SUMMARY:libssp-dev = "GNU stack smashing protection library - development files"
FILES:libssp-staticdev = "${libdir}/libssp*.a"
SUMMARY:libssp-staticdev = "GNU stack smashing protection library - static development files"
FILES:libquadmath = "${libdir}/libquadmath*.so.*"
SUMMARY:libquadmath = "GNU quad-precision math library"
FILES:libquadmath-dev = "\
${libdir}/${TARGET_SYS}/${BINV}/include/quadmath* \
${libdir}/libquadmath*.so \
${libdir}/libquadmath.la \
"
SUMMARY:libquadmath-dev = "GNU quad-precision math library - development files"
FILES:libquadmath-staticdev = "${libdir}/libquadmath.a"
SUMMARY:libquadmath-staticdev = "GNU quad-precision math library - static development files"
FILES:libgomp = "${libdir}/libgomp*${SOLIBS}"
SUMMARY:libgomp = "GNU OpenMP parallel programming library"
FILES:libgomp-dev = "\
${libdir}/libgomp*${SOLIBSDEV} \
${libdir}/libgomp*.la \
${libdir}/libgomp.spec \
${libdir}/${TARGET_SYS}/${BINV}/include/acc_prof.h \
${libdir}/${TARGET_SYS}/${BINV}/include/omp.h \
${libdir}/${TARGET_SYS}/${BINV}/include/openacc.h \
"
SUMMARY:libgomp-dev = "GNU OpenMP parallel programming library - development files"
FILES:libgomp-staticdev = "${libdir}/libgomp*.a"
SUMMARY:libgomp-staticdev = "GNU OpenMP parallel programming library - static development files"
FILES:libatomic = "${libdir}/libatomic.so.*"
SUMMARY:libatomic = "GNU C++11 atomics support library"
FILES:libatomic-dev = "\
${libdir}/libatomic.so \
${libdir}/libatomic.la \
"
SUMMARY:libatomic-dev = "GNU C++11 atomics support library - development files"
FILES:libatomic-staticdev = "${libdir}/libatomic.a"
SUMMARY:libatomic-staticdev = "GNU C++11 atomics support library - static development files"
FILES:libitm = "${libdir}/libitm.so.*"
SUMMARY:libitm = "GNU transactional memory support library"
FILES:libitm-dev = "\
${libdir}/libitm.so \
${libdir}/libitm.la \
${libdir}/libitm.spec \
"
SUMMARY:libitm-dev = "GNU transactional memory support library - development files"
FILES:libitm-staticdev = "${libdir}/libitm.a"
SUMMARY:libitm-staticdev = "GNU transactional memory support library - static development files"
require gcc-testsuite.inc
EXTRA_OEMAKE:prepend:task-check = "${PARALLEL_MAKE} "
MAKE_CHECK_TARGETS ??= "check-gcc ${@" ".join("check-target-" + i for i in d.getVar("RUNTIMETARGET").split())}"
# prettyprinters and xmethods require gdb tooling
MAKE_CHECK_IGNORE ??= "prettyprinters.exp xmethods.exp"
MAKE_CHECK_RUNTESTFLAGS ??= "${MAKE_CHECK_BOARDARGS} --ignore '${MAKE_CHECK_IGNORE}'"
# specific host and target dependencies required for test suite running
do_check[depends] += "dejagnu-native:do_populate_sysroot expect-native:do_populate_sysroot"
do_check[depends] += "virtual/libc:do_populate_sysroot"
# only depend on qemu if targeting linux user execution
do_check[depends] += "${@'qemu-native:do_populate_sysroot' if "user" in d.getVar('TOOLCHAIN_TEST_TARGET') else ''}"
# extend the recipe sysroot to include the built libraries (for qemu usermode)
do_check[prefuncs] += "extend_recipe_sysroot"
do_check[prefuncs] += "check_prepare"
do_check[dirs] = "${WORKDIR}/dejagnu ${B}"
do_check[nostamp] = "1"
do_check() {
export DEJAGNU="${WORKDIR}/dejagnu/site.exp"
# HACK: this works around the configure setting CXX with -nostd* args
sed -i 's#-nostdinc++ -L${WORKDIR}/dummylib##g' $(find ${B} -name testsuite_flags | head -1)
if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then
# qemu user has issues allocating large amounts of memory
export G_SLICE=always-malloc
# no test should need more that 10G of memory, this prevents tests like pthread7-rope from leaking memory
ulimit -m 4194304
ulimit -v 10485760
fi
oe_runmake -i ${MAKE_CHECK_TARGETS} RUNTESTFLAGS="${MAKE_CHECK_RUNTESTFLAGS}"
}
addtask check after do_compile do_populate_sysroot
require recipes-devtools/gcc/gcc-${PV}.inc
require gcc-runtime.inc
require gcc-configure-common.inc
LICENSE = "NCSA | MIT"
LIC_FILES_CHKSUM = "\
file://libsanitizer/LICENSE.TXT;md5=0249c37748936faf5b1efd5789587909 \
"
EXTRA_OECONF_PATHS = "\
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
do_configure () {
rm -rf ${B}/${TARGET_SYS}/libsanitizer/
mkdir -p ${B}/${TARGET_SYS}/libsanitizer/
cd ${B}/${TARGET_SYS}/libsanitizer/
chmod a+x ${S}/libsanitizer/configure
relpath=${@os.path.relpath("${S}/libsanitizer", "${B}/${TARGET_SYS}/libsanitizer")}
$relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
# Easiest way to stop bad RPATHs getting into the library since we have a
# broken libtool here
sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${B}/${TARGET_SYS}/libsanitizer/libtool
# Link to the sysroot's libstdc++ instead of one gcc thinks it just built
sed -i -e '/LIBSTDCXX_RAW_CXX_\(CXXFLAGS\|LDFLAGS\)\s*=/d' ${B}/${TARGET_SYS}/libsanitizer/*/Makefile
}
EXTRACONFFUNCS += "extract_stashed_builddir"
do_configure[depends] += "${COMPILERDEP}"
do_compile () {
cd ${B}/${TARGET_SYS}/libsanitizer/
oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/libsanitizer/
}
do_install () {
cd ${B}/${TARGET_SYS}/libsanitizer/
oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/libsanitizer/ install
if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include ]; then
install -d ${D}${libdir}/${TARGET_SYS}/${BINV}/include
mv ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/* ${D}${libdir}/${TARGET_SYS}/${BINV}/include
rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include
fi
if [ -d ${D}${infodir} ]; then
rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
fi
chown -R root:root ${D}
}
INHIBIT_DEFAULT_DEPS = "1"
ALLOW_EMPTY:${PN} = "1"
DEPENDS = "virtual/crypt gcc-runtime virtual/${TARGET_PREFIX}gcc"
# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
DEBUG_OPTIMIZATION:append = " -Wno-error"
BBCLASSEXTEND = "nativesdk"
PACKAGES = "${PN} ${PN}-dbg"
PACKAGES += "libasan libubsan liblsan libtsan"
PACKAGES += "libasan-dev libubsan-dev liblsan-dev libtsan-dev"
PACKAGES += "libasan-staticdev libubsan-staticdev liblsan-staticdev libtsan-staticdev"
RDEPENDS:libasan += "libstdc++"
RDEPENDS:libubsan += "libstdc++"
RDEPENDS:liblsan += "libstdc++"
RDEPENDS:libtsan += "libstdc++"
RDEPENDS:libasan-dev += "${PN}"
RDEPENDS:libubsan-dev += "${PN}"
RDEPENDS:liblsan-dev += "${PN}"
RDEPENDS:libtsan-dev += "${PN}"
RRECOMMENDS:${PN} += "libasan libubsan"
RRECOMMENDS:${PN}:append:x86 = " liblsan"
RRECOMMENDS:${PN}:append:x86-64 = " liblsan libtsan"
RRECOMMENDS:${PN}:append:powerpc64 = " liblsan libtsan"
RRECOMMENDS:${PN}:append:aarch64 = " liblsan libtsan"
do_package_write_ipk[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
do_package_write_deb[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
do_package_write_rpm[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
# Only x86, powerpc, sparc, s390, arm, and aarch64 are supported
COMPATIBLE_HOST = '(x86_64|i.86|powerpc|sparc|s390|arm|aarch64).*-linux'
# musl is currently broken entirely
COMPATIBLE_HOST:libc-musl = 'null'
FILES:libasan += "${libdir}/libasan.so.* ${libdir}/libhwasan.so.*"
FILES:libasan-dev += "\
${libdir}/libasan_preinit.o \
${libdir}/libasan.so \
${libdir}/libhwasan.so \
${libdir}/libasan.la \
"
FILES:libasan-staticdev += "${libdir}/libasan.a \
${libdir}/libhwasan.a \
"
FILES:libubsan += "${libdir}/libubsan.so.*"
FILES:libubsan-dev += "\
${libdir}/libubsan.so \
${libdir}/libubsan.la \
"
FILES:libubsan-staticdev += "${libdir}/libubsan.a"
FILES:liblsan += "${libdir}/liblsan.so.*"
FILES:liblsan-dev += "\
${libdir}/liblsan.so \
${libdir}/liblsan.la \
${libdir}/liblsan_preinit.o \
"
FILES:liblsan-staticdev += "${libdir}/liblsan.a"
FILES:libtsan += "${libdir}/libtsan.so.*"
FILES:libtsan-dev += "\
${libdir}/libtsan.so \
${libdir}/libtsan.la \
${libdir}/libtsan_*.o \
"
FILES:libtsan-staticdev += "${libdir}/libtsan.a"
FILES:${PN} = "${libdir}/*.spec ${libdir}/${TARGET_SYS}/${BINV}/include/sanitizer/*.h"
require recipes-devtools/gcc/gcc-${PV}.inc
require gcc-sanitizers.inc
# Building with thumb enabled on armv4t armv5t fails with
# sanitizer_linux.s:5749: Error: lo register required -- `ldr ip,[sp],#8'
ARM_INSTRUCTION_SET:armv4 = "arm"
ARM_INSTRUCTION_SET:armv5 = "arm"
do_fetch() {
:
}
do_fetch[noexec] = "1"
deltask do_unpack
deltask do_patch
SRC_URI = ""
do_configure[depends] += "gcc-source-${PV}:do_preconfigure"
do_populate_lic[depends] += "gcc-source-${PV}:do_unpack"
deltask do_configure
deltask do_compile
deltask do_install
deltask do_populate_sysroot
deltask do_populate_lic
RM_WORK_EXCLUDE += "${PN}"
inherit nopackages
PN = "gcc-source-${PV}"
WORKDIR = "${TMPDIR}/work-shared/gcc-${PV}-${PR}"
SSTATE_SWSPEC = "sstate:gcc::${PV}:${PR}::${SSTATE_VERSION}:"
STAMP = "${STAMPS_DIR}/work-shared/gcc-${PV}-${PR}"
STAMPCLEAN = "${STAMPS_DIR}/work-shared/gcc-${PV}-*"
INHIBIT_DEFAULT_DEPS = "1"
DEPENDS = ""
PACKAGES = ""
# This needs to be Python to avoid lots of shell variables becoming dependencies.
python do_preconfigure () {
import subprocess
cmd = d.expand('cd ${S} && PATH=${PATH} gnu-configize')
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
# See 0044-gengtypes.patch, we need to regenerate this file
bb.utils.remove(d.expand("${S}/gcc/gengtype-lex.c"))
cmd = d.expand("sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure")
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
# Easiest way to stop bad RPATHs getting into the library since we have a
# broken libtool here (breaks cross-canadian and target at least)
cmd = d.expand("sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${S}/libcc1/configure")
subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
}
addtask do_preconfigure after do_patch
do_preconfigure[depends] += "gnu-config-native:do_populate_sysroot autoconf-native:do_populate_sysroot"
require recipes-devtools/gcc/gcc-${PV}.inc
require recipes-devtools/gcc/gcc-source.inc
EXCLUDE_FROM_WORLD = "1"
GCCMULTILIB = "--enable-multilib"
require gcc-configure-common.inc
EXTRA_OECONF_PATHS = "\
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu"
# Configure gcc running on the target to default to an architecture which will
# be compatible with that of gcc-runtime (which is cross compiled to be target
# specific). For example, for ARM, ARMv6+ adds atomic instructions that may
# affect the ABI in the gcc-runtime libs. Since we can't rely on gcc on the
# target to always be passed -march etc, its built-in default needs to be safe.
ARMFPARCHEXT ?= ""
EXTRA_OECONF:append:armv6:class-target = " --with-arch=armv6${ARMFPARCHEXT}"
EXTRA_OECONF:append:armv7a:class-target = " --with-arch=armv7-a${ARMFPARCHEXT}"
EXTRA_OECONF:append:armv7ve:class-target = " --with-arch=armv7ve${ARMFPARCHEXT}"
EXTRA_OECONF:append:arc:class-target = " --with-cpu=${TUNE_PKGARCH}"
EXTRA_OECONF:append:x86-64:class-target = " --with-arch=native"
# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is
# set in subdir gcc, so subdir libcc1 can't use it, export it here to
# fix the problem.
export gcc_cv_objdump = "${TARGET_PREFIX}objdump"
EXTRA_OECONF_GCC_FLOAT = "${@get_gcc_float_setting(bb, d)}"
PACKAGES = "\
${PN} ${PN}-plugins ${PN}-symlinks \
g++ g++-symlinks \
cpp cpp-symlinks \
g77 g77-symlinks \
gfortran gfortran-symlinks \
gcov gcov-symlinks \
${PN}-doc \
${PN}-dev \
${PN}-dbg \
"
FILES:${PN} = "\
${bindir}/${TARGET_PREFIX}gcc* \
${bindir}/${TARGET_PREFIX}lto* \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/g++-mapper-server \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \
${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
${gcclibdir}/${TARGET_SYS}/${BINV}/include \
${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
${libdir}/bfd-plugins/*.so \
"
INSANE_SKIP:${PN} += "dev-so"
RRECOMMENDS:${PN} += "\
libssp \
libssp-dev \
"
RDEPENDS:${PN} += "cpp"
FILES:${PN}-dev = "\
${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \
${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \
"
FILES:${PN}-symlinks = "\
${bindir}/cc \
${bindir}/gcc \
${bindir}/gccbug \
"
FILES:${PN}-plugins = "\
${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \
"
ALLOW_EMPTY:${PN}-plugins = "1"
FILES:g77 = "\
${bindir}/${TARGET_PREFIX}g77 \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \
"
FILES:g77-symlinks = "\
${bindir}/g77 \
${bindir}/f77 \
"
RRECOMMENDS:g77 = "\
libg2c \
libg2c-dev \
"
FILES:gfortran = "\
${bindir}/${TARGET_PREFIX}gfortran \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \
"
RRECOMMENDS:gfortran = "\
libquadmath \
libquadmath-dev \
"
FILES:gfortran-symlinks = "\
${bindir}/gfortran \
${bindir}/f95"
FILES:cpp = "\
${bindir}/${TARGET_PREFIX}cpp* \
${base_libdir}/cpp \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1"
FILES:cpp-symlinks = "${bindir}/cpp"
FILES:gcov = "${bindir}/${TARGET_PREFIX}gcov* \
${bindir}/${TARGET_PREFIX}gcov-tool* \
"
FILES:gcov-symlinks = "${bindir}/gcov \
${bindir}/gcov-tool \
"
FILES:g++ = "\
${bindir}/${TARGET_PREFIX}g++* \
${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \
"
FILES:g++-symlinks = "\
${bindir}/c++ \
${bindir}/g++ \
"
RRECOMMENDS:g++ = "\
libstdc++ \
libstdc++-dev \
libatomic \
libatomic-dev \
"
FILES:${PN}-doc = "\
${infodir} \
${mandir} \
${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
"
do_compile () {
# Prevent full target sysroot path from being used in configargs.h header,
# as it will be rewritten when used by other sysroots preventing support
# for gcc plugins. Additionally the path is embeddeded into the output
# binary, this prevents building a reproducible binary.
oe_runmake configure-gcc
sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h
sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h
# Prevent sysroot/workdir paths from being used in checksum-options.
# checksum-options is used to generate a checksum which is embedded into
# the output binary.
oe_runmake TARGET-gcc=checksum-options all-gcc
sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options
sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options
oe_runmake all-host
}
do_install () {
oe_runmake 'DESTDIR=${D}' install-host
# Add unwind.h, it comes from libgcc which we don't want to build again
install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
# Info dir listing isn't interesting at this point so remove it if it exists.
if [ -e "${D}${infodir}/dir" ]; then
rm -f ${D}${infodir}/dir
fi
# Cleanup some of the ${libdir}{,exec}/gcc stuff ...
rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la
rmdir ${D}${includedir}
rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
# Hack around specs file assumptions
test -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs && sed -i -e '/^*cross_compile:$/ { n; s/1/0/; }' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs
# Cleanup manpages..
rm -rf ${D}${mandir}/man7
# Don't package details about the build host
rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h
rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h
cd ${D}${bindir}
# We care about g++ not c++
rm -f *c++*
# We don't care about the gcc-<version> ones for this
rm -f *gcc-?*.?*
# Not sure why we end up with these but we don't want them...
rm -f ${TARGET_PREFIX}${TARGET_PREFIX}*
# Symlinks so we can use these trivially on the target
if [ -e ${TARGET_PREFIX}g77 ]; then
ln -sf ${TARGET_PREFIX}g77 g77 || true
ln -sf g77 f77 || true
fi
if [ -e ${TARGET_PREFIX}gfortran ]; then
ln -sf ${TARGET_PREFIX}gfortran gfortran || true
ln -sf gfortran f95 || true
fi
ln -sf ${TARGET_PREFIX}g++ g++
ln -sf ${TARGET_PREFIX}gcc gcc
ln -sf ${TARGET_PREFIX}cpp cpp
ln -sf ${TARGET_PREFIX}gcov gcov
ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool
install -d ${D}${base_libdir}
ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp
ln -sf g++ c++
ln -sf gcc cc
install -d ${D}${libdir}/bfd-plugins
ln -sf ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
chown -R root:root ${D}
}
do_install:append () {
#
# Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header
# files and places the modified files into
# {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the
# build not deterministic. The following code prunes all those headers
# except those under include-fixed/linux, *limits.h and README, yielding
# the same include-fixed folders no matter what sysroot
include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed"
for f in $(find ${include_fixed} -type f); do
case $f in
*/include-fixed/linux/*)
continue
;;
*/include-fixed/*limits.h)
continue
;;
*/include-fixed/README)
continue
;;
*)
# remove file and directory if empty
bbdebug 2 "Pruning $f"
rm $f
find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \;
;;
esac
done
}
# Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross
# and one from here. These can confuse gcc cross where includes use #include_next
# and builds track file dependencies (e.g. perl and its makedepends code).
# For determinism we don't install this ever and rely on the copy from gcc-cross.
# [YOCTO #7287]
SYSROOT_DIRS_IGNORE += "${libdir}/gcc"
inherit qemu
TOOLCHAIN_TEST_TARGET ??= "user"
TOOLCHAIN_TEST_HOST ??= "localhost"
TOOLCHAIN_TEST_HOST_USER ??= "root"
TOOLCHAIN_TEST_HOST_PORT ??= "2222"
MAKE_CHECK_BOARDFLAGS ??= ""
MAKE_CHECK_BOARDARGS ??= "--target_board=${TOOLCHAIN_TEST_TARGET}${MAKE_CHECK_BOARDFLAGS}"
python () {
# Provide the targets compiler args via targets options. This allows dejagnu to
# correctly mark incompatible tests as UNSUPPORTED (e.g. needs soft-float
# but running on hard-float target).
#
# These options are called "multilib_flags" within the gcc test suite. Most
# architectures handle these options in a sensible way such that tests that
# are incompatible with the provided multilib are marked as UNSUPPORTED.
#
# Note: multilib flags are added to the compile command after the args
# provided by any test (through dg-options), CFLAGS_FOR_TARGET is always
# added to the compile command before any other args but is not interpted
# as options like multilib flags.
#
# i686, x86-64 and aarch64 are special, since most toolchains built for
# these targets don't do multilib the tests do not get correctly marked as
# UNSUPPORTED. More importantly the test suite itself does not handle
# overriding the multilib flags where it could (like other archs do). As
# such do not pass the target compiler args for these targets.
args = d.getVar("TUNE_CCARGS").split()
if d.getVar("TUNE_ARCH") in ["i686", "x86_64", "aarch64"]:
args = []
d.setVar("MAKE_CHECK_BOARDFLAGS", ("/" + "/".join(args)) if len(args) != 0 else "")
}
python check_prepare() {
def generate_qemu_linux_user_config(d):
content = []
content.append('load_generic_config "sim"')
content.append('load_base_board_description "basic-sim"')
content.append('process_multilib_options ""')
# qemu args
qemu_binary = qemu_target_binary(d)
if not qemu_binary:
bb.fatal("Missing target qemu linux-user binary")
args = []
# QEMU_OPTIONS is not always valid due to -cross recipe
args += ["-r", d.getVar("OLDEST_KERNEL")]
# enable all valid instructions, since the test suite itself does not
# limit itself to the target cpu options.
# - valid for x86*, powerpc, arm, arm64
if qemu_binary.lstrip("qemu-") in ["x86_64", "i386", "ppc", "arm", "aarch64"]:
args += ["-cpu", "max"]
sysroot = d.getVar("RECIPE_SYSROOT")
args += ["-L", sysroot]
# lib paths are static here instead of using $libdir since this is used by a -cross recipe
libpaths = [sysroot + "/usr/lib", sysroot + "/lib"]
args += ["-E", "LD_LIBRARY_PATH={0}".format(":".join(libpaths))]
content.append('set_board_info is_simulator 1')
content.append('set_board_info sim "{0}"'.format(qemu_binary))
content.append('set_board_info sim,options "{0}"'.format(" ".join(args)))
# target build/test config
content.append('set_board_info target_install {%s}' % d.getVar("TARGET_SYS"))
content.append('set_board_info ldscript ""')
#content.append('set_board_info needs_status_wrapper 1') # qemu-linux-user return codes work, and abort works fine
content.append('set_board_info gcc,stack_size 16834')
content.append('set_board_info gdb,nosignals 1')
content.append('set_board_info gcc,timeout 60')
return "\n".join(content)
def generate_remote_ssh_linux_config(d):
content = []
content.append('load_generic_config "unix"')
content.append('process_multilib_options ""')
content.append("set_board_info hostname {0}".format(d.getVar("TOOLCHAIN_TEST_HOST")))
content.append("set_board_info username {0}".format(d.getVar("TOOLCHAIN_TEST_HOST_USER")))
port = d.getVar("TOOLCHAIN_TEST_HOST_PORT")
content.append("set_board_info rsh_prog \"/usr/bin/ssh -p {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))
content.append("set_board_info rcp_prog \"/usr/bin/scp -P {0} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\"".format(port))
return "\n".join(content)
dejagnudir = d.expand("${WORKDIR}/dejagnu")
if not os.path.isdir(dejagnudir):
os.makedirs(dejagnudir)
# write out target qemu board config
with open(os.path.join(dejagnudir, "user.exp"), "w") as f:
f.write(generate_qemu_linux_user_config(d))
# write out target ssh board config
with open(os.path.join(dejagnudir, "ssh.exp"), "w") as f:
f.write(generate_remote_ssh_linux_config(d))
# generate site.exp to provide boards
with open(os.path.join(dejagnudir, "site.exp"), "w") as f:
f.write("lappend boards_dir {0}\n".format(dejagnudir))
f.write("set CFLAGS_FOR_TARGET \"{0}\"\n".format(d.getVar("TOOLCHAIN_OPTIONS")))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment