gcc-target.inc 8.4 KB

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