Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit cross |
| 2 | |
| 3 | INHIBIT_DEFAULT_DEPS = "1" |
| 4 | EXTRADEPENDS = "" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | DEPENDS = "virtual/${TARGET_PREFIX}binutils ${EXTRADEPENDS} ${NATIVEDEPS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | PROVIDES = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++" |
| 7 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | if d.getVar("TARGET_OS").startswith("linux"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | d.setVar("EXTRADEPENDS", "linux-libc-headers") |
| 10 | } |
| 11 | |
| 12 | PN = "gcc-cross-${TARGET_ARCH}" |
| 13 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | # Ignore how TARGET_ARCH is computed. |
| 15 | TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}" |
| 16 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | require gcc-configure-common.inc |
| 18 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | # While we want the 'gnu' hash style, we explicitly set it to sysv here to |
| 20 | # ensure that any recipe which doesn't obey our LDFLAGS (which also set it to |
| 21 | # gnu) will hit a QA failure. |
| 22 | LINKER_HASH_STYLE ?= "sysv" |
| 23 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | EXTRA_OECONF += "--enable-poison-system-directories" |
| 25 | EXTRA_OECONF_append_sh4 = " \ |
| 26 | --with-multilib-list= \ |
| 27 | --enable-incomplete-targets \ |
| 28 | " |
| 29 | |
| 30 | EXTRA_OECONF += "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | --with-system-zlib \ |
| 32 | " |
| 33 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | EXTRA_OECONF_append_libc-baremetal = " --without-headers" |
| 35 | EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | EXTRA_OECONF_remove_libc-newlib = "--enable-threads=posix" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | |
| 38 | EXTRA_OECONF_PATHS = "\ |
| 39 | --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \ |
| 40 | --with-sysroot=/not/exist \ |
| 41 | --with-build-sysroot=${STAGING_DIR_TARGET} \ |
| 42 | " |
| 43 | |
| 44 | ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}" |
| 45 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | |
| 47 | do_configure_prepend () { |
| 48 | install -d ${RECIPE_SYSROOT}${target_includedir} |
| 49 | touch ${RECIPE_SYSROOT}${target_includedir}/limits.h |
| 50 | } |
| 51 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | do_compile () { |
| 53 | export CC="${BUILD_CC}" |
| 54 | export AR_FOR_TARGET="${TARGET_SYS}-ar" |
| 55 | export RANLIB_FOR_TARGET="${TARGET_SYS}-ranlib" |
| 56 | export LD_FOR_TARGET="${TARGET_SYS}-ld" |
| 57 | export NM_FOR_TARGET="${TARGET_SYS}-nm" |
| 58 | export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc" |
| 59 | export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}" |
| 60 | export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}" |
| 61 | export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}" |
| 62 | export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}" |
| 63 | |
| 64 | oe_runmake all-host configure-target-libgcc |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 65 | (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] | 66 | # now generate script to drive testing |
| 67 | echo "#!/usr/bin/env sh" >${B}/${TARGET_PREFIX}testgcc |
| 68 | set >> ${B}/${TARGET_PREFIX}testgcc |
| 69 | # prune out the unneeded vars |
| 70 | sed -i -e "/^BASH/d" ${B}/${TARGET_PREFIX}testgcc |
| 71 | sed -i -e "/^USER/d" ${B}/${TARGET_PREFIX}testgcc |
| 72 | sed -i -e "/^OPT/d" ${B}/${TARGET_PREFIX}testgcc |
| 73 | sed -i -e "/^DIRSTACK/d" ${B}/${TARGET_PREFIX}testgcc |
| 74 | sed -i -e "/^EUID/d" ${B}/${TARGET_PREFIX}testgcc |
| 75 | sed -i -e "/^FUNCNAME/d" ${B}/${TARGET_PREFIX}testgcc |
| 76 | sed -i -e "/^GROUPS/d" ${B}/${TARGET_PREFIX}testgcc |
| 77 | sed -i -e "/^HOST/d" ${B}/${TARGET_PREFIX}testgcc |
| 78 | sed -i -e "/^HOME/d" ${B}/${TARGET_PREFIX}testgcc |
| 79 | sed -i -e "/^IFS/d" ${B}/${TARGET_PREFIX}testgcc |
| 80 | sed -i -e "/^LC_ALL/d" ${B}/${TARGET_PREFIX}testgcc |
| 81 | sed -i -e "/^LOGNAME/d" ${B}/${TARGET_PREFIX}testgcc |
| 82 | sed -i -e "/^MACHTYPE/d" ${B}/${TARGET_PREFIX}testgcc |
| 83 | sed -i -e "/^OSTYPE/d" ${B}/${TARGET_PREFIX}testgcc |
| 84 | sed -i -e "/^PIPE/d" ${B}/${TARGET_PREFIX}testgcc |
| 85 | sed -i -e "/^SHELL/d" ${B}/${TARGET_PREFIX}testgcc |
| 86 | sed -i -e "/^'/d" ${B}/${TARGET_PREFIX}testgcc |
| 87 | sed -i -e "/^UID/d" ${B}/${TARGET_PREFIX}testgcc |
| 88 | sed -i -e "/^TERM/d" ${B}/${TARGET_PREFIX}testgcc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc |
| 90 | sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc |
| 91 | sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc |
| 92 | sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc |
| 93 | sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc |
| 94 | sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc |
| 95 | sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc |
| 96 | sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc |
| 97 | sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc |
| 98 | |
| 99 | # append execution part of the script |
| 100 | cat >> ${B}/${TARGET_PREFIX}testgcc << STOP |
| 101 | target="\$1" |
| 102 | usage () { |
| 103 | echo "Usage:" |
| 104 | echo "\$0 user@target 'extra options to dejagnu'" |
| 105 | echo "\$0 target 'extra options to dejagnu'" |
| 106 | echo "\$0 target" |
| 107 | echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'" |
| 108 | echo "will only run visibility-d.c test case" |
| 109 | echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'" |
| 110 | echo "will only run visibility-d.c test case in thumb mode" |
| 111 | echo "You need to have dejagnu autogen expect installed" |
| 112 | echo "on the build host" |
| 113 | } |
| 114 | if [ "x\$target" = "x" ] |
| 115 | then |
| 116 | echo "Please specify the target machine and remote user in form of user@target\n" |
| 117 | usage |
| 118 | exit 1; |
| 119 | fi |
| 120 | |
| 121 | shift |
| 122 | |
| 123 | echo "\$target" | grep "@" 2>&1 > /dev/null |
| 124 | if [ "x\$?" = "x0" ] |
| 125 | then |
| 126 | user=\$(echo \$target | cut -d '@' -f 1) |
| 127 | target=\$(echo \$target | cut -d '@' -f 2) |
| 128 | else |
| 129 | user=\$USER |
| 130 | fi |
| 131 | ssh \$user@\$target date 2>&1 > /dev/null |
| 132 | if [ "x\$?" != "x0" ] |
| 133 | then |
| 134 | echo "Failed connecting to \$user@\$target it could be because" |
| 135 | echo "you don't have passwordless ssh setup to access \$target" |
| 136 | echo "or sometimes host key has been changed" |
| 137 | echo "in such case do something like below on build host" |
| 138 | echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target" |
| 139 | echo "and then try ssh \$user@\$target" |
| 140 | |
| 141 | usage |
| 142 | exit 1 |
| 143 | fi |
| 144 | echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp |
| 145 | echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp |
| 146 | echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp |
| 147 | echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp |
| 148 | echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp |
| 149 | echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp |
| 150 | DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@" |
| 151 | |
| 152 | STOP |
| 153 | |
| 154 | chmod +x ${B}/${TARGET_PREFIX}testgcc |
| 155 | |
| 156 | } |
| 157 | |
| 158 | INHIBIT_PACKAGE_STRIP = "1" |
| 159 | |
| 160 | # Compute how to get from libexecdir to bindir in python (easier than shell) |
| 161 | BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}" |
| 162 | |
| 163 | do_install () { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 164 | ( 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] | 165 | oe_runmake 'DESTDIR=${D}' install-host |
| 166 | |
| 167 | install -d ${D}${target_base_libdir} |
| 168 | install -d ${D}${target_libdir} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 169 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 170 | # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77 |
| 171 | # gfortran is fully backwards compatible. This is a safe and practical solution. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 172 | if [ -n "${@d.getVar('FORTRAN')}" ]; then |
| 173 | ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true |
| 174 | fortsymlinks="g77 gfortran" |
| 175 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are |
| 178 | # found. These need to be relative paths so they work in different locations. |
| 179 | dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/ |
| 180 | install -d $dest |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 181 | for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip gcc cpp $fortsymlinks; do |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t |
| 183 | ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t |
| 184 | done |
| 185 | |
| 186 | # Remove things we don't need but keep share/java |
| 187 | for d in info man share/doc share/locale share/man share/info; do |
| 188 | rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d |
| 189 | done |
| 190 | |
| 191 | # libquadmath headers need to be available in the gcc libexec dir |
| 192 | install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 193 | cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 194 | cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 195 | |
| 196 | # We use libiberty from binutils |
| 197 | find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f |
| 198 | find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 199 | |
| 200 | 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 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 201 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | |
| 203 | do_package[noexec] = "1" |
| 204 | do_packagedata[noexec] = "1" |
| 205 | do_package_write_ipk[noexec] = "1" |
| 206 | do_package_write_rpm[noexec] = "1" |
| 207 | do_package_write_deb[noexec] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 208 | |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 209 | inherit chrpath |
| 210 | |
| 211 | python gcc_stash_builddir_fixrpaths() { |
| 212 | # rewrite rpaths, breaking hardlinks as required |
| 213 | process_dir("/", d.getVar("BUILDDIRSTASH"), d, break_hardlinks = True) |
| 214 | } |
| 215 | |
| 216 | BUILDDIRSTASH = "${WORKDIR}/stashed-builddir/build" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 217 | do_gcc_stash_builddir[dirs] = "${B}" |
| 218 | do_gcc_stash_builddir[cleandirs] = "${BUILDDIRSTASH}" |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 219 | do_gcc_stash_builddir[postfuncs] += "gcc_stash_builddir_fixrpaths" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 220 | do_gcc_stash_builddir () { |
| 221 | dest=${BUILDDIRSTASH} |
| 222 | hardlinkdir . $dest |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 223 | # Makefile does move-if-change which can end up with 'timestamp' as file contents so break links to those files |
| 224 | rm $dest/gcc/include/*.h |
| 225 | cp gcc/include/*.h $dest/gcc/include/ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 226 | } |
| 227 | addtask do_gcc_stash_builddir after do_compile before do_install |
| 228 | SSTATETASKS += "do_gcc_stash_builddir" |
| 229 | do_gcc_stash_builddir[sstate-inputdirs] = "${BUILDDIRSTASH}" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 230 | do_gcc_stash_builddir[sstate-outputdirs] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}" |
| 231 | do_gcc_stash_builddir[sstate-fixmedir] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 232 | |
| 233 | python do_gcc_stash_builddir_setscene () { |
| 234 | sstate_setscene(d) |
| 235 | } |
| 236 | addtask do_gcc_stash_builddir_setscene |