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