gcc-target.inc 8.2 KB

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