Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit cross-canadian |
| 2 | |
| 3 | SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)" |
| 4 | PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}" |
| 5 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 6 | DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | |
| 8 | GCCMULTILIB = "--enable-multilib" |
| 9 | |
| 10 | require gcc-configure-common.inc |
| 11 | |
| 12 | EXTRA_OECONF_PATHS = "\ |
| 13 | --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \ |
| 14 | --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \ |
| 15 | --with-sysroot=/not/exist \ |
| 16 | --with-build-sysroot=${STAGING_DIR_TARGET} \ |
| 17 | " |
| 18 | # We have to point gcc at a sysroot but we don't need to rebuild if this changes |
| 19 | # e.g. we switch between different machines with different tunes. |
| 20 | EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH" |
| 21 | TARGET_ARCH[vardepsexclude] = "TUNE_ARCH" |
| 22 | get_gcc_float_setting[vardepvalue] = "" |
| 23 | |
| 24 | # |
| 25 | # gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky |
| 26 | # for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse. |
| 27 | # |
| 28 | export AR_FOR_TARGET = "${TARGET_PREFIX}ar" |
| 29 | export AS_FOR_TARGET = "${TARGET_PREFIX}as" |
| 30 | export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool" |
| 31 | export CC_FOR_TARGET = "${TARGET_PREFIX}gcc" |
| 32 | export CXX_FOR_TARGET = "${TARGET_PREFIX}g++" |
| 33 | export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc" |
| 34 | export LD_FOR_TARGET = "${TARGET_PREFIX}ld" |
| 35 | export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo" |
| 36 | export NM_FOR_TARGET = "${TARGET_PREFIX}nm" |
| 37 | export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump" |
| 38 | export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib" |
| 39 | export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip" |
| 40 | export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres" |
| 41 | |
| 42 | # |
| 43 | # We need to override this and make sure the compiler can find staging |
| 44 | # |
| 45 | export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}" |
| 46 | |
| 47 | do_configure () { |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 48 | if [ ! -d ${RECIPE_SYSROOT}/${target_includedir} ]; then |
| 49 | mkdir -p ${RECIPE_SYSROOT}/${target_includedir} |
| 50 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | export CC_FOR_BUILD="${BUILD_CC}" |
| 52 | export CXX_FOR_BUILD="${BUILD_CXX}" |
| 53 | export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}" |
| 54 | export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}" |
| 55 | export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}" |
| 56 | export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}" |
| 57 | export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}" |
| 58 | export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}" |
| 59 | export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}" |
| 60 | export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}" |
| 61 | oe_runconf |
| 62 | } |
| 63 | |
| 64 | do_compile () { |
| 65 | oe_runmake all-host configure-target-libgcc |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 66 | (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | PACKAGES = "${PN}-dbg ${PN} ${PN}-doc" |
| 70 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 71 | FILES:${PN} = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | ${exec_prefix}/bin/* \ |
| 73 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \ |
| 74 | ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \ |
| 75 | ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \ |
| 76 | ${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \ |
| 77 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include \ |
| 78 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \ |
| 79 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \ |
| 80 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \ |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 81 | ${libdir}/bfd-plugins/*.so \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 82 | ${includedir}/c++/${BINV} \ |
| 83 | ${prefix}/${TARGET_SYS}/bin/* \ |
| 84 | ${prefix}/${TARGET_SYS}/lib/* \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 85 | ${prefix}/${TARGET_SYS}${target_includedir}/* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 87 | INSANE_SKIP:${PN} += "dev-so" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 89 | FILES:${PN}-doc = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | ${infodir} \ |
| 91 | ${mandir} \ |
| 92 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ |
| 93 | " |
| 94 | |
| 95 | EXEEXT = "" |
| 96 | |
| 97 | # Compute how to get from libexecdir to bindir in python (easier than shell) |
| 98 | BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}" |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 99 | # linker plugin path |
| 100 | LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | |
| 102 | do_install () { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 103 | ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h ) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | oe_runmake 'DESTDIR=${D}' install-host |
| 105 | |
| 106 | # Cleanup some of the ${libdir}{,exec}/gcc stuff ... |
| 107 | rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 108 | rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 109 | rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude |
| 110 | |
| 111 | # We care about g++ not c++ |
| 112 | rm -f ${D}${bindir}/*c++ |
| 113 | |
| 114 | # We don't care about the gcc-<version> copies |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 115 | rm -f ${D}${bindir}/*gcc-${BINV}* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | # Cleanup empty directories which are not shipped |
| 118 | # we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted |
| 119 | # ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686 |
| 120 | local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}" |
| 121 | for i in $empty_dirs; do |
| 122 | [ -d $i ] && rmdir --ignore-fail-on-non-empty $i |
| 123 | done |
| 124 | |
| 125 | # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are |
| 126 | # found. |
| 127 | dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/ |
| 128 | install -d $dest |
| 129 | suffix=${EXEEXT} |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 130 | for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then |
| 132 | continue |
| 133 | fi |
| 134 | |
| 135 | ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix |
| 136 | done |
| 137 | t=real-ld |
| 138 | ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix |
| 139 | |
| 140 | # libquadmath headers need to be available in the gcc libexec dir |
| 141 | install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 142 | cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 143 | cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 144 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 145 | # install LTO linker plugins where binutils tools can find it |
| 146 | install -d ${D}${libdir}/bfd-plugins |
| 147 | ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so |
| 148 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | chown -R root:root ${D} |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 150 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 151 | cross_canadian_bindirlinks |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 152 | |
| 153 | for i in linux ${CANADIANEXTRAOS} |
| 154 | do |
| 155 | for v in ${CANADIANEXTRAVENDOR} |
| 156 | do |
| 157 | d=${D}${bindir}/../${TARGET_ARCH}$v-$i |
| 158 | install -d $d |
| 159 | for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT} |
| 160 | do |
| 161 | p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,` |
| 162 | case $i in |
| 163 | *musl*) |
| 164 | rm -rf $d/$p |
| 165 | echo "#!/usr/bin/env sh" > $d/$p |
| 166 | echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p |
| 167 | chmod 0755 $d/$p |
| 168 | ;; |
| 169 | *) |
| 170 | ;; |
| 171 | esac |
| 172 | done |
| 173 | done |
| 174 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | ELFUTILS = "nativesdk-elfutils" |
| 178 | DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 179 | RDEPENDS:${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 181 | SYSTEMHEADERS = "${target_includedir}/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | SYSTEMLIBS = "${target_base_libdir}/" |
| 183 | SYSTEMLIBS1 = "${target_libdir}/" |
| 184 | |
| 185 | EXTRA_OECONF += "--enable-poison-system-directories" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 186 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | # gcc 4.7 needs -isystem |
| 188 | export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}" |