Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | GCCMULTILIB = "--enable-multilib" |
| 2 | require gcc-configure-common.inc |
| 3 | |
| 4 | EXTRA_OECONF_PATHS = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | --with-build-sysroot=${STAGING_DIR_TARGET} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | " |
| 7 | |
| 8 | EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu" |
| 9 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | # Configure gcc running on the target to default to an architecture which will |
| 11 | # be compatible with that of gcc-runtime (which is cross compiled to be target |
| 12 | # specific). For example, for ARM, ARMv6+ adds atomic instructions that may |
| 13 | # affect the ABI in the gcc-runtime libs. Since we can't rely on gcc on the |
| 14 | # target to always be passed -march etc, its built-in default needs to be safe. |
| 15 | |
| 16 | ARMFPARCHEXT ?= "" |
| 17 | |
| 18 | EXTRA_OECONF_append_armv6 = " --with-arch=armv6${ARMFPARCHEXT}" |
| 19 | EXTRA_OECONF_append_armv7a = " --with-arch=armv7-a${ARMFPARCHEXT}" |
| 20 | EXTRA_OECONF_append_armv7ve = " --with-arch=armv7ve${ARMFPARCHEXT}" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | EXTRA_OECONF_append_arc = " --with-cpu=${TUNE_PKGARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | # libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is |
| 24 | # set in subdir gcc, so subdir libcc1 can't use it, export it here to |
| 25 | # fix the problem. |
| 26 | export gcc_cv_objdump = "${TARGET_PREFIX}objdump" |
| 27 | |
| 28 | EXTRA_OECONF_GCC_FLOAT = "${@get_gcc_float_setting(bb, d)}" |
| 29 | |
| 30 | PACKAGES = "\ |
| 31 | ${PN} ${PN}-plugins ${PN}-symlinks \ |
| 32 | g++ g++-symlinks \ |
| 33 | cpp cpp-symlinks \ |
| 34 | g77 g77-symlinks \ |
| 35 | gfortran gfortran-symlinks \ |
| 36 | gcov gcov-symlinks \ |
| 37 | ${PN}-doc \ |
| 38 | ${PN}-dev \ |
| 39 | ${PN}-dbg \ |
| 40 | " |
| 41 | |
| 42 | FILES_${PN} = "\ |
| 43 | ${bindir}/${TARGET_PREFIX}gcc* \ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 44 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 45 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \ |
| 47 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ |
| 48 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \ |
| 49 | ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \ |
| 50 | ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \ |
| 51 | ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ |
| 52 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include \ |
| 53 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \ |
| 54 | " |
| 55 | INSANE_SKIP_${PN} += "dev-so" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 56 | RRECOMMENDS_${PN} += "\ |
| 57 | libssp \ |
| 58 | libssp-dev \ |
| 59 | " |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 60 | RDEPENDS_${PN} += "cpp" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | FILES_${PN}-dev = "\ |
| 63 | ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ |
| 64 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ |
| 65 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \ |
| 66 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \ |
| 67 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \ |
| 68 | " |
| 69 | FILES_${PN}-symlinks = "\ |
| 70 | ${bindir}/cc \ |
| 71 | ${bindir}/gcc \ |
| 72 | ${bindir}/gccbug \ |
| 73 | " |
| 74 | |
| 75 | FILES_${PN}-plugins = "\ |
| 76 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \ |
| 77 | " |
| 78 | ALLOW_EMPTY_${PN}-plugins = "1" |
| 79 | |
| 80 | FILES_g77 = "\ |
| 81 | ${bindir}/${TARGET_PREFIX}g77 \ |
| 82 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \ |
| 83 | " |
| 84 | FILES_g77-symlinks = "\ |
| 85 | ${bindir}/g77 \ |
| 86 | ${bindir}/f77 \ |
| 87 | " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 88 | RRECOMMENDS_g77 = "\ |
| 89 | libg2c \ |
| 90 | libg2c-dev \ |
| 91 | " |
| 92 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | FILES_gfortran = "\ |
| 94 | ${bindir}/${TARGET_PREFIX}gfortran \ |
| 95 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \ |
| 96 | " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 97 | RRECOMMENDS_gfortran = "\ |
| 98 | libquadmath \ |
| 99 | libquadmath-dev \ |
| 100 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | FILES_gfortran-symlinks = "\ |
| 102 | ${bindir}/gfortran \ |
| 103 | ${bindir}/f95" |
| 104 | |
| 105 | FILES_cpp = "\ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 106 | ${bindir}/${TARGET_PREFIX}cpp* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | ${base_libdir}/cpp \ |
| 108 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1" |
| 109 | FILES_cpp-symlinks = "${bindir}/cpp" |
| 110 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 111 | FILES_gcov = "${bindir}/${TARGET_PREFIX}gcov* \ |
| 112 | ${bindir}/${TARGET_PREFIX}gcov-tool* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | " |
| 114 | FILES_gcov-symlinks = "${bindir}/gcov \ |
| 115 | ${bindir}/gcov-tool \ |
| 116 | " |
| 117 | |
| 118 | FILES_g++ = "\ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 119 | ${bindir}/${TARGET_PREFIX}g++* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ |
| 121 | " |
| 122 | FILES_g++-symlinks = "\ |
| 123 | ${bindir}/c++ \ |
| 124 | ${bindir}/g++ \ |
| 125 | " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 126 | RRECOMMENDS_g++ = "\ |
| 127 | libstdc++ \ |
| 128 | libstdc++-dev \ |
| 129 | libatomic \ |
| 130 | libatomic-dev \ |
| 131 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 132 | |
| 133 | FILES_${PN}-doc = "\ |
| 134 | ${infodir} \ |
| 135 | ${mandir} \ |
| 136 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ |
| 137 | " |
| 138 | |
| 139 | do_compile () { |
| 140 | oe_runmake all-host |
| 141 | } |
| 142 | |
| 143 | do_install () { |
| 144 | oe_runmake 'DESTDIR=${D}' install-host |
| 145 | |
| 146 | # Add unwind.h, it comes from libgcc which we don't want to build again |
| 147 | install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 148 | |
| 149 | # Info dir listing isn't interesting at this point so remove it if it exists. |
| 150 | if [ -e "${D}${infodir}/dir" ]; then |
| 151 | rm -f ${D}${infodir}/dir |
| 152 | fi |
| 153 | |
| 154 | # Cleanup some of the ${libdir}{,exec}/gcc stuff ... |
| 155 | rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 156 | rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 157 | rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la |
| 158 | rmdir ${D}${includedir} |
| 159 | rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude |
| 160 | |
| 161 | # Hack around specs file assumptions |
| 162 | test -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs && sed -i -e '/^*cross_compile:$/ { n; s/1/0/; }' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs |
| 163 | |
| 164 | # Cleanup manpages.. |
| 165 | rm -rf ${D}${mandir}/man7 |
| 166 | |
| 167 | cd ${D}${bindir} |
| 168 | |
| 169 | # We care about g++ not c++ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 170 | rm -f *c++* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | |
| 172 | # We don't care about the gcc-<version> ones for this |
| 173 | rm -f *gcc-?.?* |
| 174 | |
| 175 | # We use libiberty from binutils |
| 176 | find ${D}${libdir} -name libiberty.a | xargs rm -f |
| 177 | find ${D}${libdir} -name libiberty.h | xargs rm -f |
| 178 | |
| 179 | # Not sure why we end up with these but we don't want them... |
| 180 | rm -f ${TARGET_PREFIX}${TARGET_PREFIX}* |
| 181 | |
| 182 | # Symlinks so we can use these trivially on the target |
| 183 | if [ -e ${TARGET_PREFIX}g77 ]; then |
| 184 | ln -sf ${TARGET_PREFIX}g77 g77 || true |
| 185 | ln -sf g77 f77 || true |
| 186 | fi |
| 187 | if [ -e ${TARGET_PREFIX}gfortran ]; then |
| 188 | ln -sf ${TARGET_PREFIX}gfortran gfortran || true |
| 189 | ln -sf gfortran f95 || true |
| 190 | fi |
| 191 | ln -sf ${TARGET_PREFIX}g++ g++ |
| 192 | ln -sf ${TARGET_PREFIX}gcc gcc |
| 193 | ln -sf ${TARGET_PREFIX}cpp cpp |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 194 | ln -sf ${TARGET_PREFIX}gcov gcov |
| 195 | ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 196 | install -d ${D}${base_libdir} |
| 197 | ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp |
| 198 | ln -sf g++ c++ |
| 199 | ln -sf gcc cc |
| 200 | |
| 201 | chown -R root:root ${D} |
| 202 | } |
| 203 | |
| 204 | do_install_append () { |
| 205 | # |
| 206 | # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header |
| 207 | # files and places the modified files into |
| 208 | # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the |
| 209 | # build not deterministic. The following code prunes all those headers |
| 210 | # except those under include-fixed/linux, *limits.h and README, yielding |
| 211 | # the same include-fixed folders no matter what sysroot |
| 212 | |
| 213 | include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed" |
| 214 | for f in $(find ${include_fixed} -type f); do |
| 215 | case $f in |
| 216 | */include-fixed/linux/*) |
| 217 | continue |
| 218 | ;; |
| 219 | */include-fixed/*limits.h) |
| 220 | continue |
| 221 | ;; |
| 222 | */include-fixed/README) |
| 223 | continue |
| 224 | ;; |
| 225 | *) |
| 226 | # remove file and directory if empty |
| 227 | bbdebug 2 "Pruning $f" |
| 228 | rm $f |
| 229 | find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \; |
| 230 | ;; |
| 231 | esac |
| 232 | done |
| 233 | } |
| 234 | |
| 235 | # Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross |
| 236 | # and one from here. These can confuse gcc cross where includes use #include_next |
| 237 | # and builds track file dependencies (e.g. perl and its makedepends code). |
| 238 | # For determinism we don't install this ever and rely on the copy from gcc-cross. |
| 239 | # [YOCTO #7287] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 240 | SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc" |