gcc-cross-canadian.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. inherit cross-canadian
  2. SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
  3. PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
  4. DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc"
  5. GCCMULTILIB = "--enable-multilib"
  6. require gcc-configure-common.inc
  7. EXTRA_OECONF += "--with-plugin-ld=ld"
  8. EXTRA_OECONF_PATHS = "\
  9. --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
  10. --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
  11. --with-sysroot=/not/exist \
  12. --with-build-sysroot=${STAGING_DIR_TARGET} \
  13. "
  14. # We have to point gcc at a sysroot but we don't need to rebuild if this changes
  15. # e.g. we switch between different machines with different tunes.
  16. EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
  17. TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
  18. get_gcc_float_setting[vardepvalue] = ""
  19. #
  20. # gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky
  21. # for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse.
  22. #
  23. export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
  24. export AS_FOR_TARGET = "${TARGET_PREFIX}as"
  25. export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool"
  26. export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
  27. export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
  28. export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc"
  29. export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
  30. export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo"
  31. export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
  32. export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump"
  33. export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
  34. export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
  35. export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
  36. #
  37. # We need to override this and make sure the compiler can find staging
  38. #
  39. export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
  40. do_configure () {
  41. if [ ! -d ${RECIPE_SYSROOT}/${target_includedir} ]; then
  42. mkdir -p ${RECIPE_SYSROOT}/${target_includedir}
  43. fi
  44. export CC_FOR_BUILD="${BUILD_CC}"
  45. export CXX_FOR_BUILD="${BUILD_CXX}"
  46. export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
  47. export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
  48. export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
  49. export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
  50. export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
  51. export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
  52. export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
  53. export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
  54. oe_runconf
  55. }
  56. do_compile () {
  57. oe_runmake all-host configure-target-libgcc
  58. (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
  59. }
  60. PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
  61. FILES:${PN} = "\
  62. ${exec_prefix}/bin/* \
  63. ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
  64. ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
  65. ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
  66. ${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \
  67. ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
  68. ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
  69. ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
  70. ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
  71. ${libdir}/bfd-plugins/*.so \
  72. ${includedir}/c++/${BINV} \
  73. ${prefix}/${TARGET_SYS}/bin/* \
  74. ${prefix}/${TARGET_SYS}/lib/* \
  75. ${prefix}/${TARGET_SYS}${target_includedir}/* \
  76. "
  77. INSANE_SKIP:${PN} += "dev-so"
  78. FILES:${PN}-doc = "\
  79. ${infodir} \
  80. ${mandir} \
  81. ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
  82. "
  83. EXEEXT = ""
  84. # Compute how to get from libexecdir to bindir in python (easier than shell)
  85. BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
  86. # linker plugin path
  87. LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}"
  88. do_install () {
  89. ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
  90. oe_runmake 'DESTDIR=${D}' install-host
  91. # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
  92. rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
  93. rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
  94. rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
  95. # We care about g++ not c++
  96. rm -f ${D}${bindir}/*c++
  97. # We don't care about the gcc-<version> copies
  98. rm -f ${D}${bindir}/*gcc-${BINV}*
  99. # Cleanup empty directories which are not shipped
  100. # we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
  101. # ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686
  102. local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}"
  103. for i in $empty_dirs; do
  104. [ -d $i ] && rmdir --ignore-fail-on-non-empty $i
  105. done
  106. # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
  107. # found.
  108. dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
  109. install -d $dest
  110. suffix=${EXEEXT}
  111. for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
  112. if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
  113. continue
  114. fi
  115. ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
  116. done
  117. # libquadmath headers need to be available in the gcc libexec dir
  118. install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  119. cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  120. cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
  121. # install LTO linker plugins where binutils tools can find it
  122. install -d ${D}${libdir}/bfd-plugins
  123. ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
  124. chown -R root:root ${D}
  125. cross_canadian_bindirlinks
  126. for i in linux ${CANADIANEXTRAOS}
  127. do
  128. for v in ${CANADIANEXTRAVENDOR}
  129. do
  130. d=${D}${bindir}/../${TARGET_ARCH}$v-$i
  131. install -d $d
  132. for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
  133. do
  134. p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
  135. case $i in
  136. *musl*)
  137. rm -rf $d/$p
  138. echo "#!/usr/bin/env sh" > $d/$p
  139. echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
  140. chmod 0755 $d/$p
  141. ;;
  142. *)
  143. ;;
  144. esac
  145. done
  146. done
  147. done
  148. }
  149. ELFUTILS = "nativesdk-elfutils"
  150. DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib nativesdk-zstd"
  151. RDEPENDS:${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
  152. SYSTEMHEADERS = "${target_includedir}/"
  153. SYSTEMLIBS = "${target_base_libdir}/"
  154. SYSTEMLIBS1 = "${target_libdir}/"
  155. EXTRA_OECONF += "--enable-poison-system-directories"
  156. # gcc 4.7 needs -isystem
  157. export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"