1require gcc-configure-common.inc 2 3SUMMARY = "Runtime libraries from GCC" 4 5# Over-ride the LICENSE set by gcc-${PV}.inc to remove "& GPLv3" 6# All gcc-runtime packages are now covered by the runtime exception. 7LICENSE = "GPL-3.0-with-GCC-exception" 8 9CXXFLAGS:remove = "-fvisibility-inlines-hidden" 10 11EXTRA_OECONF_PATHS = "\ 12 --with-gxx-include-dir=${includedir}/c++/${BINV} \ 13 --with-sysroot=/not/exist \ 14 --with-build-sysroot=${STAGING_DIR_TARGET} \ 15" 16 17EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu" 18EXTRA_OECONF:append = " --cache-file=${B}/config.cache" 19EXTRA_OECONF:append:libc-newlib = " --with-newlib --with-target-subdir" 20EXTRA_OECONF:append:libc-picolibc = " --with-newlib --with-target-subdir" 21EXTRA_OECONF:append:libc-baremetal = " --with-target-subdir" 22 23# Disable ifuncs for libatomic on arm conflicts -march/-mcpu 24EXTRA_OECONF:append:arm = " libat_cv_have_ifunc=no " 25EXTRA_OECONF:append:armeb = " libat_cv_have_ifunc=no " 26 27DISABLE_STATIC:class-nativesdk ?= "" 28 29# Newlib does not support symbol versioning on libsdtcc++ 30SYMVERS_CONF:libc-newlib = "" 31SYMVERS_CONF:libc-picolibc = "" 32 33# Building with thumb enabled on armv6t fails 34ARM_INSTRUCTION_SET:armv6 = "arm" 35 36RUNTIMELIBITM = "libitm" 37RUNTIMELIBITM:arc = "" 38RUNTIMELIBITM:mipsarch = "" 39RUNTIMELIBITM:nios2 = "" 40RUNTIMELIBITM:microblaze = "" 41RUNTIMELIBITM:riscv32 = "" 42RUNTIMELIBITM:riscv64 = "" 43RUNTIMELIBITM:loongarch64 = "" 44RUNTIMELIBSSP ?= "" 45RUNTIMELIBSSP:mingw32 ?= "libssp" 46 47RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic ${RUNTIMELIBITM} \ 48 ${@bb.utils.contains('FORTRAN', ',fortran', 'libquadmath', '', d)} \ 49" 50# Only build libstdc++ for newlib 51RUNTIMETARGET:libc-newlib = "libstdc++-v3" 52RUNTIMETARGET:libc-picolibc = "libstdc++-v3" 53 54# libiberty 55# libgfortran needs separate recipe due to libquadmath dependency 56 57do_configure () { 58 export CXX="${CXX} -nostdinc++ -L${WORKDIR}/dummylib" 59 # libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure 60 # tests. Create a dummy empty lib for the purposes of configure. 61 mkdir -p ${WORKDIR}/dummylib 62 ${CC} -x c /dev/null -c -o ${WORKDIR}/dummylib/dummylib.o 63 ${AR} rcs ${WORKDIR}/dummylib/libstdc++.a ${WORKDIR}/dummylib/dummylib.o 64 for d in libgcc ${RUNTIMETARGET}; do 65 echo "Configuring $d" 66 rm -rf ${B}/${TARGET_SYS}/$d/ 67 mkdir -p ${B}/${TARGET_SYS}/$d/ 68 cd ${B}/${TARGET_SYS}/$d/ 69 chmod a+x ${S}/$d/configure 70 ${S}/$d/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} 71 if [ "$d" = "libgcc" ]; then 72 (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h) 73 fi 74 done 75} 76EXTRACONFFUNCS += "extract_stashed_builddir" 77do_configure[depends] += "${COMPILERDEP}" 78 79do_compile () { 80 for d in libgcc ${RUNTIMETARGET}; do 81 cd ${B}/${TARGET_SYS}/$d/ 82 oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/ 83 done 84} 85 86do_install () { 87 for d in ${RUNTIMETARGET}; do 88 cd ${B}/${TARGET_SYS}/$d/ 89 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/ install 90 done 91 install -d ${D}${datadir}/gdb/auto-load/${libdir} 92 mv ${D}${libdir}/libstdc++*-gdb.py ${D}${datadir}/gdb/auto-load/${libdir} 93 if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include ]; then 94 install -d ${D}${libdir}/${TARGET_SYS}/${BINV}/include 95 mv ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/* ${D}${libdir}/${TARGET_SYS}/${BINV}/include 96 rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include 97 fi 98 rm -rf ${D}${infodir}/libgomp.info* ${D}${infodir}/dir 99 rm -rf ${D}${infodir}/libitm.info ${D}${infodir}/dir 100 rm -rf ${D}${infodir}/libquadmath.info ${D}${infodir}/dir 101 if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude ]; then 102 rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude 103 fi 104 if [ -d ${D}${infodir} ]; then 105 rmdir --ignore-fail-on-non-empty -p ${D}${infodir} 106 fi 107 if [ -d ${D}${libdir} ]; then 108 rmdir --ignore-fail-on-non-empty -p ${D}${libdir} 109 fi 110} 111 112do_install:append:class-target () { 113 if [ "${TARGET_OS}" = "linux-gnuspe" ]; then 114 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 115 fi 116 117 if [ "${TARGET_OS}" = "linux-gnun32" ]; then 118 if [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then 119 mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux 120 ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux/32 121 elif [ "${MULTILIB_VARIANTS}" != "" ]; then 122 mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 123 ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux/32 124 else 125 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 126 fi 127 elif [ "${TARGET_OS}" = "linux-gnux32" ]; then 128 if [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then 129 mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux 130 ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-linux/x32 131 elif [ "${MULTILIB_VARIANTS}" != "" ]; then 132 mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 133 ln -s ../${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux/32 134 else 135 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 136 fi 137 elif [ "${TARGET_VENDOR_MULTILIB_ORIGINAL}" != "" -a "${TARGET_VENDOR}" != "${TARGET_VENDOR_MULTILIB_ORIGINAL}" ]; then 138 mkdir ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS} 139 ln -s ../${TARGET_SYS}/bits ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/bits 140 ln -s ../${TARGET_SYS}/ext ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/ext 141 fi 142 143 if [ "${TARGET_ARCH}" = "x86_64" -a "${MULTILIB_VARIANTS}" != "" ];then 144 ln -sf ../${X86ARCH32}${TARGET_VENDOR}-${TARGET_OS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}/32 145 fi 146 147 if [ "${TCLIBC}" != "glibc" ]; then 148 case "${TARGET_OS}" in 149 "linux-musl" | "linux-*spe") extra_target_os="linux";; 150 "linux-musleabi") extra_target_os="linux-gnueabi";; 151 *) extra_target_os="linux";; 152 esac 153 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-$extra_target_os 154 fi 155 chown -R root:root ${D} 156} 157 158INHIBIT_DEFAULT_DEPS = "1" 159DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++ libgcc virtual/${MLPREFIX}libc" 160PROVIDES = "virtual/${TARGET_PREFIX}compilerlibs" 161 162BBCLASSEXTEND = "nativesdk" 163 164PACKAGES = "\ 165 ${PN}-dbg \ 166 libstdc++ \ 167 libstdc++-precompile-dev \ 168 libstdc++-dev \ 169 libstdc++-staticdev \ 170 libssp \ 171 libssp-dev \ 172 libssp-staticdev \ 173 libquadmath \ 174 libquadmath-dev \ 175 libquadmath-staticdev \ 176 libgomp \ 177 libgomp-dev \ 178 libgomp-staticdev \ 179 libatomic \ 180 libatomic-dev \ 181 libatomic-staticdev \ 182 libitm \ 183 libitm-dev \ 184 libitm-staticdev \ 185" 186# The base package doesn't exist, so we clear the recommends. 187RRECOMMENDS:${PN}-dbg = "" 188 189# include python debugging scripts 190FILES:${PN}-dbg += "\ 191 ${datadir}/gcc-${BINV}/python/libstdcxx \ 192 ${datadir}/gdb/auto-load \ 193" 194# Needed by libstdcxx pretty printer, however it is disabled intentionally 195# as it adds build time dependency on bash and some cases e.g. no GPL3 cases 196# bash is not availbale and builds fails 197# So it needs to be added manually to images sadly. 198# RDEPENDS:${PN}-dbg += "python3-datetime" 199 200FILES:libstdc++ = "${libdir}/libstdc++.so.*" 201SUMMARY:libstdc++ = "GNU standard C++ library" 202FILES:libstdc++-dev = "\ 203 ${includedir}/c++/ \ 204 ${libdir}/libstdc++.so \ 205 ${libdir}/libstdc++*.la \ 206 ${libdir}/libsupc++.la \ 207" 208SUMMARY:libstdc++-dev = "GNU standard C++ library - development files" 209FILES:libstdc++-staticdev = "\ 210 ${libdir}/libstdc++*.a \ 211 ${libdir}/libsupc++.a \ 212" 213SUMMARY:libstdc++-staticdev = "GNU standard C++ library - static development files" 214 215FILES:libstdc++-precompile-dev = "${includedir}/c++/${TARGET_SYS}/bits/*.gch" 216SUMMARY:libstdc++-precompile-dev = "GNU standard C++ library - precompiled header files" 217 218FILES:libssp = "${libdir}/libssp.so.*" 219SUMMARY:libssp = "GNU stack smashing protection library" 220FILES:libssp-dev = "\ 221 ${libdir}/libssp*.so \ 222 ${libdir}/libssp*_nonshared.a \ 223 ${libdir}/libssp*.la \ 224 ${libdir}/${TARGET_SYS}/${BINV}/include/ssp \ 225" 226SUMMARY:libssp-dev = "GNU stack smashing protection library - development files" 227FILES:libssp-staticdev = "${libdir}/libssp*.a" 228SUMMARY:libssp-staticdev = "GNU stack smashing protection library - static development files" 229 230FILES:libquadmath = "${libdir}/libquadmath*.so.*" 231SUMMARY:libquadmath = "GNU quad-precision math library" 232FILES:libquadmath-dev = "\ 233 ${libdir}/${TARGET_SYS}/${BINV}/include/quadmath* \ 234 ${libdir}/libquadmath*.so \ 235 ${libdir}/libquadmath.la \ 236" 237SUMMARY:libquadmath-dev = "GNU quad-precision math library - development files" 238FILES:libquadmath-staticdev = "${libdir}/libquadmath.a" 239SUMMARY:libquadmath-staticdev = "GNU quad-precision math library - static development files" 240 241FILES:libgomp = "${libdir}/libgomp*${SOLIBS}" 242SUMMARY:libgomp = "GNU OpenMP parallel programming library" 243FILES:libgomp-dev = "\ 244 ${libdir}/libgomp*${SOLIBSDEV} \ 245 ${libdir}/libgomp*.la \ 246 ${libdir}/libgomp.spec \ 247 ${libdir}/${TARGET_SYS}/${BINV}/include/acc_prof.h \ 248 ${libdir}/${TARGET_SYS}/${BINV}/include/omp.h \ 249 ${libdir}/${TARGET_SYS}/${BINV}/include/openacc.h \ 250" 251SUMMARY:libgomp-dev = "GNU OpenMP parallel programming library - development files" 252FILES:libgomp-staticdev = "${libdir}/libgomp*.a" 253SUMMARY:libgomp-staticdev = "GNU OpenMP parallel programming library - static development files" 254 255FILES:libatomic = "${libdir}/libatomic.so.*" 256SUMMARY:libatomic = "GNU C++11 atomics support library" 257FILES:libatomic-dev = "\ 258 ${libdir}/libatomic.so \ 259 ${libdir}/libatomic.la \ 260" 261SUMMARY:libatomic-dev = "GNU C++11 atomics support library - development files" 262FILES:libatomic-staticdev = "${libdir}/libatomic.a" 263SUMMARY:libatomic-staticdev = "GNU C++11 atomics support library - static development files" 264 265FILES:libitm = "${libdir}/libitm.so.*" 266SUMMARY:libitm = "GNU transactional memory support library" 267FILES:libitm-dev = "\ 268 ${libdir}/libitm.so \ 269 ${libdir}/libitm.la \ 270 ${libdir}/libitm.spec \ 271" 272SUMMARY:libitm-dev = "GNU transactional memory support library - development files" 273FILES:libitm-staticdev = "${libdir}/libitm.a" 274SUMMARY:libitm-staticdev = "GNU transactional memory support library - static development files" 275 276require gcc-testsuite.inc 277 278EXTRA_OEMAKE:prepend:task-check = "${PARALLEL_MAKE} " 279 280MAKE_CHECK_TARGETS ??= "check-gcc ${@" ".join("check-target-" + i for i in d.getVar("RUNTIMETARGET").split())}" 281# prettyprinters and xmethods require gdb tooling 282MAKE_CHECK_IGNORE ??= "prettyprinters.exp xmethods.exp" 283MAKE_CHECK_RUNTESTFLAGS ??= "${MAKE_CHECK_BOARDARGS} --ignore '${MAKE_CHECK_IGNORE}'" 284 285# specific host and target dependencies required for test suite running 286do_check[depends] += "dejagnu-native:do_populate_sysroot expect-native:do_populate_sysroot" 287do_check[depends] += "virtual/libc:do_populate_sysroot" 288# only depend on qemu if targeting linux user execution 289do_check[depends] += "${@'qemu-native:do_populate_sysroot' if "user" in d.getVar('TOOLCHAIN_TEST_TARGET') else ''}" 290# extend the recipe sysroot to include the built libraries (for qemu usermode) 291do_check[prefuncs] += "extend_recipe_sysroot" 292do_check[prefuncs] += "check_prepare" 293do_check[dirs] = "${WORKDIR}/dejagnu ${B}" 294do_check[nostamp] = "1" 295do_check[network] = "1" 296do_check() { 297 export DEJAGNU="${WORKDIR}/dejagnu/site.exp" 298 299 # HACK: this works around the configure setting CXX with -nostd* args 300 sed -i 's#-nostdinc++ -L${WORKDIR}/dummylib##g' $(find ${B} -name testsuite_flags | head -1) 301 302 if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then 303 # qemu user has issues allocating large amounts of memory 304 export G_SLICE=always-malloc 305 # no test should need more that 10G of memory, this prevents tests like pthread7-rope from leaking memory 306 ulimit -m 4194304 307 ulimit -v 10485760 308 fi 309 310 oe_runmake -i ${MAKE_CHECK_TARGETS} RUNTESTFLAGS="${MAKE_CHECK_RUNTESTFLAGS}" 311} 312addtask check after do_compile do_populate_sysroot 313 314