gcc-cross-canadian.inc 7.1 KB

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