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