gcc-target.inc 8.4 KB

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