1GCCMULTILIB = "--enable-multilib" 2require gcc-configure-common.inc 3 4EXTRA_OECONF_PATHS = "\ 5 --with-build-sysroot=${STAGING_DIR_TARGET} \ 6" 7 8EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu" 9 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 16ARMFPARCHEXT ?= "" 17 18EXTRA_OECONF_append_armv6 = " --with-arch=armv6${ARMFPARCHEXT}" 19EXTRA_OECONF_append_armv7a = " --with-arch=armv7-a${ARMFPARCHEXT}" 20EXTRA_OECONF_append_armv7ve = " --with-arch=armv7ve${ARMFPARCHEXT}" 21EXTRA_OECONF_append_arc = " --with-cpu=${TUNE_PKGARCH}" 22EXTRA_OECONF_append_x86-64 = " --with-arch=native" 23 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. 27export gcc_cv_objdump = "${TARGET_PREFIX}objdump" 28 29EXTRA_OECONF_GCC_FLOAT = "${@get_gcc_float_setting(bb, d)}" 30 31PACKAGES = "\ 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 43FILES_${PN} = "\ 44 ${bindir}/${TARGET_PREFIX}gcc* \ 45 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \ 46 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ 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" 56INSANE_SKIP_${PN} += "dev-so" 57RRECOMMENDS_${PN} += "\ 58 libssp \ 59 libssp-dev \ 60" 61RDEPENDS_${PN} += "cpp" 62 63FILES_${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" 70FILES_${PN}-symlinks = "\ 71 ${bindir}/cc \ 72 ${bindir}/gcc \ 73 ${bindir}/gccbug \ 74" 75 76FILES_${PN}-plugins = "\ 77 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \ 78" 79ALLOW_EMPTY_${PN}-plugins = "1" 80 81FILES_g77 = "\ 82 ${bindir}/${TARGET_PREFIX}g77 \ 83 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \ 84" 85FILES_g77-symlinks = "\ 86 ${bindir}/g77 \ 87 ${bindir}/f77 \ 88" 89RRECOMMENDS_g77 = "\ 90 libg2c \ 91 libg2c-dev \ 92" 93 94FILES_gfortran = "\ 95 ${bindir}/${TARGET_PREFIX}gfortran \ 96 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \ 97" 98RRECOMMENDS_gfortran = "\ 99 libquadmath \ 100 libquadmath-dev \ 101" 102FILES_gfortran-symlinks = "\ 103 ${bindir}/gfortran \ 104 ${bindir}/f95" 105 106FILES_cpp = "\ 107 ${bindir}/${TARGET_PREFIX}cpp* \ 108 ${base_libdir}/cpp \ 109 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1" 110FILES_cpp-symlinks = "${bindir}/cpp" 111 112FILES_gcov = "${bindir}/${TARGET_PREFIX}gcov* \ 113 ${bindir}/${TARGET_PREFIX}gcov-tool* \ 114" 115FILES_gcov-symlinks = "${bindir}/gcov \ 116 ${bindir}/gcov-tool \ 117" 118 119FILES_g++ = "\ 120 ${bindir}/${TARGET_PREFIX}g++* \ 121 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ 122" 123FILES_g++-symlinks = "\ 124 ${bindir}/c++ \ 125 ${bindir}/g++ \ 126" 127RRECOMMENDS_g++ = "\ 128 libstdc++ \ 129 libstdc++-dev \ 130 libatomic \ 131 libatomic-dev \ 132" 133 134FILES_${PN}-doc = "\ 135 ${infodir} \ 136 ${mandir} \ 137 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ 138" 139 140do_compile () { 141 # Prevent full target sysroot path from being used in configargs.h header, 142 # as it will be rewritten when used by other sysroots preventing support 143 # for gcc plugins. Additionally the path is embeddeded into the output 144 # binary, this prevents building a reproducible binary. 145 oe_runmake configure-gcc 146 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h 147 sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h 148 149 # Prevent sysroot/workdir paths from being used in checksum-options. 150 # checksum-options is used to generate a checksum which is embedded into 151 # the output binary. 152 oe_runmake TARGET-gcc=checksum-options all-gcc 153 sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options 154 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options 155 156 oe_runmake all-host 157} 158 159do_install () { 160 oe_runmake 'DESTDIR=${D}' install-host 161 162 # Add unwind.h, it comes from libgcc which we don't want to build again 163 install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ 164 165 # Info dir listing isn't interesting at this point so remove it if it exists. 166 if [ -e "${D}${infodir}/dir" ]; then 167 rm -f ${D}${infodir}/dir 168 fi 169 170 # Cleanup some of the ${libdir}{,exec}/gcc stuff ... 171 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools 172 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools 173 rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la 174 rmdir ${D}${includedir} 175 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude 176 177 # Hack around specs file assumptions 178 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 179 180 # Cleanup manpages.. 181 rm -rf ${D}${mandir}/man7 182 183 # Don't package details about the build host 184 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h 185 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h 186 187 cd ${D}${bindir} 188 189 # We care about g++ not c++ 190 rm -f *c++* 191 192 # We don't care about the gcc-<version> ones for this 193 rm -f *gcc-?.?* 194 195 # Not sure why we end up with these but we don't want them... 196 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}* 197 198 # Symlinks so we can use these trivially on the target 199 if [ -e ${TARGET_PREFIX}g77 ]; then 200 ln -sf ${TARGET_PREFIX}g77 g77 || true 201 ln -sf g77 f77 || true 202 fi 203 if [ -e ${TARGET_PREFIX}gfortran ]; then 204 ln -sf ${TARGET_PREFIX}gfortran gfortran || true 205 ln -sf gfortran f95 || true 206 fi 207 ln -sf ${TARGET_PREFIX}g++ g++ 208 ln -sf ${TARGET_PREFIX}gcc gcc 209 ln -sf ${TARGET_PREFIX}cpp cpp 210 ln -sf ${TARGET_PREFIX}gcov gcov 211 ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool 212 install -d ${D}${base_libdir} 213 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp 214 ln -sf g++ c++ 215 ln -sf gcc cc 216 217 chown -R root:root ${D} 218} 219 220do_install_append () { 221 # 222 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header 223 # files and places the modified files into 224 # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the 225 # build not deterministic. The following code prunes all those headers 226 # except those under include-fixed/linux, *limits.h and README, yielding 227 # the same include-fixed folders no matter what sysroot 228 229 include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed" 230 for f in $(find ${include_fixed} -type f); do 231 case $f in 232 */include-fixed/linux/*) 233 continue 234 ;; 235 */include-fixed/*limits.h) 236 continue 237 ;; 238 */include-fixed/README) 239 continue 240 ;; 241 *) 242 # remove file and directory if empty 243 bbdebug 2 "Pruning $f" 244 rm $f 245 find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \; 246 ;; 247 esac 248 done 249} 250 251# Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross 252# and one from here. These can confuse gcc cross where includes use #include_next 253# and builds track file dependencies (e.g. perl and its makedepends code). 254# For determinism we don't install this ever and rely on the copy from gcc-cross. 255# [YOCTO #7287] 256SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc" 257