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