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