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 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 8 | EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 18 | EXTRA_OECONF:append:armv6:class-target = " --with-arch=armv6${ARMFPARCHEXT}" |
| 19 | EXTRA_OECONF:append:armv7a:class-target = " --with-arch=armv7-a${ARMFPARCHEXT}" |
| 20 | EXTRA_OECONF:append:armv7ve:class-target = " --with-arch=armv7ve${ARMFPARCHEXT}" |
| 21 | EXTRA_OECONF:append:arc:class-target = " --with-cpu=${TUNE_PKGARCH}" |
| 22 | EXTRA_OECONF:append:x86-64:class-target = " --with-arch=native" |
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 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 43 | FILES:${PN} = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | ${bindir}/${TARGET_PREFIX}gcc* \ |
Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 45 | ${bindir}/${TARGET_PREFIX}lto* \ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 46 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \ |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 47 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/g++-mapper-server \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \ |
| 49 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ |
| 50 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \ |
| 51 | ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \ |
| 52 | ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \ |
| 53 | ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ |
| 54 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include \ |
| 55 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \ |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 56 | ${libdir}/bfd-plugins/*.so \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 58 | INSANE_SKIP:${PN} += "dev-so" |
| 59 | RRECOMMENDS:${PN} += "\ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 60 | libssp \ |
| 61 | libssp-dev \ |
| 62 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 63 | RDEPENDS:${PN} += "cpp" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 65 | FILES:${PN}-dev = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ |
| 67 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ |
| 68 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \ |
| 69 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \ |
| 70 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \ |
| 71 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 72 | FILES:${PN}-symlinks = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | ${bindir}/cc \ |
| 74 | ${bindir}/gcc \ |
| 75 | ${bindir}/gccbug \ |
| 76 | " |
| 77 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 78 | FILES:${PN}-plugins = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \ |
| 80 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 81 | ALLOW_EMPTY:${PN}-plugins = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 82 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 83 | FILES:g77 = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | ${bindir}/${TARGET_PREFIX}g77 \ |
| 85 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \ |
| 86 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 87 | FILES:g77-symlinks = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | ${bindir}/g77 \ |
| 89 | ${bindir}/f77 \ |
| 90 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 91 | RRECOMMENDS:g77 = "\ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 92 | libg2c \ |
| 93 | libg2c-dev \ |
| 94 | " |
| 95 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 96 | FILES:gfortran = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | ${bindir}/${TARGET_PREFIX}gfortran \ |
| 98 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \ |
| 99 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 100 | RRECOMMENDS:gfortran = "\ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 101 | libquadmath \ |
| 102 | libquadmath-dev \ |
| 103 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 104 | FILES:gfortran-symlinks = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 105 | ${bindir}/gfortran \ |
| 106 | ${bindir}/f95" |
| 107 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 108 | FILES:cpp = "\ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 109 | ${bindir}/${TARGET_PREFIX}cpp* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | ${base_libdir}/cpp \ |
| 111 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 112 | FILES:cpp-symlinks = "${bindir}/cpp" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 114 | FILES:gcov = "${bindir}/${TARGET_PREFIX}gcov* \ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 115 | ${bindir}/${TARGET_PREFIX}gcov-tool* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 117 | FILES:gcov-symlinks = "${bindir}/gcov \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | ${bindir}/gcov-tool \ |
| 119 | " |
| 120 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 121 | FILES:g++ = "\ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 122 | ${bindir}/${TARGET_PREFIX}g++* \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ |
| 124 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 125 | FILES:g++-symlinks = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | ${bindir}/c++ \ |
| 127 | ${bindir}/g++ \ |
| 128 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 129 | RRECOMMENDS:g++ = "\ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 130 | libstdc++ \ |
| 131 | libstdc++-dev \ |
| 132 | libatomic \ |
| 133 | libatomic-dev \ |
| 134 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 136 | FILES:${PN}-doc = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | ${infodir} \ |
| 138 | ${mandir} \ |
| 139 | ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ |
| 140 | " |
| 141 | |
| 142 | do_compile () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 143 | # Prevent full target sysroot path from being used in configargs.h header, |
| 144 | # as it will be rewritten when used by other sysroots preventing support |
| 145 | # for gcc plugins. Additionally the path is embeddeded into the output |
| 146 | # binary, this prevents building a reproducible binary. |
| 147 | oe_runmake configure-gcc |
| 148 | sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h |
| 149 | sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h |
| 150 | |
| 151 | # Prevent sysroot/workdir paths from being used in checksum-options. |
| 152 | # checksum-options is used to generate a checksum which is embedded into |
| 153 | # the output binary. |
| 154 | oe_runmake TARGET-gcc=checksum-options all-gcc |
| 155 | sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options |
| 156 | sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options |
| 157 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 158 | oe_runmake all-host |
| 159 | } |
| 160 | |
| 161 | do_install () { |
| 162 | oe_runmake 'DESTDIR=${D}' install-host |
| 163 | |
| 164 | # Add unwind.h, it comes from libgcc which we don't want to build again |
| 165 | install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ |
| 166 | |
| 167 | # Info dir listing isn't interesting at this point so remove it if it exists. |
| 168 | if [ -e "${D}${infodir}/dir" ]; then |
| 169 | rm -f ${D}${infodir}/dir |
| 170 | fi |
| 171 | |
| 172 | # Cleanup some of the ${libdir}{,exec}/gcc stuff ... |
| 173 | rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 174 | rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools |
| 175 | rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la |
| 176 | rmdir ${D}${includedir} |
| 177 | rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude |
| 178 | |
| 179 | # Hack around specs file assumptions |
| 180 | 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 |
| 181 | |
| 182 | # Cleanup manpages.. |
| 183 | rm -rf ${D}${mandir}/man7 |
| 184 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 185 | # Don't package details about the build host |
| 186 | rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h |
| 187 | rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h |
| 188 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 189 | cd ${D}${bindir} |
| 190 | |
| 191 | # We care about g++ not c++ |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 192 | rm -f *c++* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 193 | |
| 194 | # We don't care about the gcc-<version> ones for this |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 195 | rm -f *gcc-?*.?* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 196 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | # Not sure why we end up with these but we don't want them... |
| 198 | rm -f ${TARGET_PREFIX}${TARGET_PREFIX}* |
| 199 | |
| 200 | # Symlinks so we can use these trivially on the target |
| 201 | if [ -e ${TARGET_PREFIX}g77 ]; then |
| 202 | ln -sf ${TARGET_PREFIX}g77 g77 || true |
| 203 | ln -sf g77 f77 || true |
| 204 | fi |
| 205 | if [ -e ${TARGET_PREFIX}gfortran ]; then |
| 206 | ln -sf ${TARGET_PREFIX}gfortran gfortran || true |
| 207 | ln -sf gfortran f95 || true |
| 208 | fi |
| 209 | ln -sf ${TARGET_PREFIX}g++ g++ |
| 210 | ln -sf ${TARGET_PREFIX}gcc gcc |
| 211 | ln -sf ${TARGET_PREFIX}cpp cpp |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 212 | ln -sf ${TARGET_PREFIX}gcov gcov |
| 213 | ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 214 | install -d ${D}${base_libdir} |
| 215 | ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp |
| 216 | ln -sf g++ c++ |
| 217 | ln -sf gcc cc |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 218 | install -d ${D}${libdir}/bfd-plugins |
| 219 | ln -sf ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | chown -R root:root ${D} |
| 221 | } |
| 222 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 223 | do_install:append () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 224 | # |
| 225 | # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header |
| 226 | # files and places the modified files into |
| 227 | # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the |
| 228 | # build not deterministic. The following code prunes all those headers |
| 229 | # except those under include-fixed/linux, *limits.h and README, yielding |
| 230 | # the same include-fixed folders no matter what sysroot |
| 231 | |
| 232 | include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed" |
| 233 | for f in $(find ${include_fixed} -type f); do |
| 234 | case $f in |
| 235 | */include-fixed/linux/*) |
| 236 | continue |
| 237 | ;; |
| 238 | */include-fixed/*limits.h) |
| 239 | continue |
| 240 | ;; |
| 241 | */include-fixed/README) |
| 242 | continue |
| 243 | ;; |
| 244 | *) |
| 245 | # remove file and directory if empty |
| 246 | bbdebug 2 "Pruning $f" |
| 247 | rm $f |
| 248 | find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \; |
| 249 | ;; |
| 250 | esac |
| 251 | done |
| 252 | } |
| 253 | |
| 254 | # Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross |
| 255 | # and one from here. These can confuse gcc cross where includes use #include_next |
| 256 | # and builds track file dependencies (e.g. perl and its makedepends code). |
| 257 | # For determinism we don't install this ever and rely on the copy from gcc-cross. |
| 258 | # [YOCTO #7287] |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 259 | SYSROOT_DIRS_IGNORE += "${libdir}/gcc" |