libgcc-common.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. BPN = "libgcc"
  2. require gcc-configure-common.inc
  3. INHIBIT_DEFAULT_DEPS = "1"
  4. do_configure () {
  5. install -d ${D}${base_libdir} ${D}${libdir}
  6. mkdir -p ${B}/${BPN}
  7. mkdir -p ${B}/${TARGET_SYS}/${BPN}/
  8. cd ${B}/${BPN}
  9. chmod a+x ${S}/${BPN}/configure
  10. ${S}/${BPN}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
  11. }
  12. EXTRACONFFUNCS += "extract_stashed_builddir"
  13. do_configure[depends] += "${COMPILERDEP}"
  14. do_compile () {
  15. cd ${B}/${BPN}
  16. oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/
  17. }
  18. do_install () {
  19. cd ${B}/${BPN}
  20. oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install
  21. # Move libgcc_s into /lib
  22. mkdir -p ${D}${base_libdir}
  23. if [ -f ${D}${libdir}/nof/libgcc_s.so ]; then
  24. mv ${D}${libdir}/nof/libgcc* ${D}${base_libdir}
  25. else
  26. mv ${D}${libdir}/libgcc* ${D}${base_libdir} || true
  27. fi
  28. # install the runtime in /usr/lib/ not in /usr/lib/gcc on target
  29. # so that cross-gcc can find it in the sysroot
  30. mv ${D}${libdir}/gcc/* ${D}${libdir}
  31. rm -rf ${D}${libdir}/gcc/
  32. # unwind.h is installed here which is shipped in gcc-cross
  33. # as well as target gcc and they are identical so we dont
  34. # ship one with libgcc here
  35. rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include
  36. }
  37. do_install:append:libc-baremetal () {
  38. if [ "${base_libdir}" != "${libdir}" ]; then
  39. rmdir ${D}${base_libdir}
  40. fi
  41. }
  42. do_install:append:libc-newlib () {
  43. if [ "${base_libdir}" != "${libdir}" ]; then
  44. rmdir ${D}${base_libdir}
  45. fi
  46. }
  47. do_install:append:libc-picolibc () {
  48. if [ "${base_libdir}" != "${libdir}" ]; then
  49. rmdir ${D}${base_libdir}
  50. fi
  51. }
  52. # No rpm package is actually created but -dev depends on it, avoid dnf error
  53. DEV_PKG_DEPENDENCY:libc-baremetal = ""
  54. DEV_PKG_DEPENDENCY:libc-newlib = ""
  55. BBCLASSEXTEND = "nativesdk"
  56. addtask multilib_install after do_install before do_package do_populate_sysroot
  57. # this makes multilib gcc files findable for target gcc
  58. # e.g.
  59. # /usr/lib/i586-pokymllib32-linux/4.7/
  60. # by creating this symlink to it
  61. # /usr/lib64/x86_64-poky-linux/4.7/32
  62. fakeroot python do_multilib_install() {
  63. import re
  64. multilibs = d.getVar('MULTILIB_VARIANTS')
  65. if not multilibs or bb.data.inherits_class('nativesdk', d):
  66. return
  67. binv = d.getVar('BINV')
  68. mlprefix = d.getVar('MLPREFIX')
  69. if ('%slibgcc' % mlprefix) != d.getVar('PN'):
  70. return
  71. if mlprefix:
  72. orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL')
  73. orig_tune_params = get_tune_parameters(orig_tune, d)
  74. orig_tune_baselib = orig_tune_params['baselib']
  75. orig_tune_bitness = orig_tune_baselib.replace('lib', '')
  76. if not orig_tune_bitness:
  77. orig_tune_bitness = '32'
  78. src = '../../../' + orig_tune_baselib + '/' + \
  79. d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/'
  80. dest = d.getVar('D') + d.getVar('libdir') + '/' + \
  81. d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness
  82. if os.path.lexists(dest):
  83. os.unlink(dest)
  84. os.symlink(src, dest)
  85. return
  86. for ml in multilibs.split():
  87. tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml)
  88. if not tune:
  89. bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml)
  90. continue
  91. tune_parameters = get_tune_parameters(tune, d)
  92. tune_baselib = tune_parameters['baselib']
  93. if not tune_baselib:
  94. bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune)
  95. continue
  96. tune_arch = tune_parameters['arch']
  97. tune_bitness = tune_baselib.replace('lib', '')
  98. if not tune_bitness:
  99. tune_bitness = '32' # /lib => 32bit lib
  100. tune_abiextension = tune_parameters['abiextension']
  101. if tune_abiextension:
  102. libcextension = '-gnu' + tune_abiextension
  103. else:
  104. libcextension = ''
  105. src = '../../../' + tune_baselib + '/' + \
  106. tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \
  107. '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/'
  108. dest = d.getVar('D') + d.getVar('libdir') + '/' + \
  109. d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness
  110. if os.path.lexists(dest):
  111. os.unlink(dest)
  112. os.symlink(src, dest)
  113. }
  114. def get_original_os(d):
  115. vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
  116. for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]:
  117. if suffix and vendoros.endswith(suffix):
  118. vendoros = vendoros[:-len(suffix)]
  119. # Arm must use linux-gnueabi not linux as only the former is accepted by gcc
  120. if vendoros.startswith("arm-") and not vendoros.endswith("-gnueabi"):
  121. vendoros = vendoros + "-gnueabi"
  122. return vendoros
  123. ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
  124. BASETARGET_SYS = "${@get_original_os(d)}"
  125. addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
  126. fakeroot python do_extra_symlinks() {
  127. if bb.data.inherits_class('nativesdk', d):
  128. return
  129. targetsys = d.getVar('BASETARGET_SYS')
  130. if targetsys != d.getVar('TARGET_SYS'):
  131. dest = d.getVar('D') + d.getVar('libdir') + '/' + targetsys
  132. src = d.getVar('TARGET_SYS')
  133. if not os.path.lexists(dest) and os.path.lexists(d.getVar('D') + d.getVar('libdir')):
  134. os.symlink(src, dest)
  135. }