libgcc-common.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. # No rpm package is actually created but -dev depends on it, avoid dnf error
  48. DEV_PKG_DEPENDENCY:libc-baremetal = ""
  49. DEV_PKG_DEPENDENCY:libc-newlib = ""
  50. BBCLASSEXTEND = "nativesdk"
  51. addtask multilib_install after do_install before do_package do_populate_sysroot
  52. # this makes multilib gcc files findable for target gcc
  53. # e.g.
  54. # /usr/lib/i586-pokymllib32-linux/4.7/
  55. # by creating this symlink to it
  56. # /usr/lib64/x86_64-poky-linux/4.7/32
  57. fakeroot python do_multilib_install() {
  58. import re
  59. multilibs = d.getVar('MULTILIB_VARIANTS')
  60. if not multilibs or bb.data.inherits_class('nativesdk', d):
  61. return
  62. binv = d.getVar('BINV')
  63. mlprefix = d.getVar('MLPREFIX')
  64. if ('%slibgcc' % mlprefix) != d.getVar('PN'):
  65. return
  66. if mlprefix:
  67. orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL')
  68. orig_tune_params = get_tune_parameters(orig_tune, d)
  69. orig_tune_baselib = orig_tune_params['baselib']
  70. orig_tune_bitness = orig_tune_baselib.replace('lib', '')
  71. if not orig_tune_bitness:
  72. orig_tune_bitness = '32'
  73. src = '../../../' + orig_tune_baselib + '/' + \
  74. d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/'
  75. dest = d.getVar('D') + d.getVar('libdir') + '/' + \
  76. d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness
  77. if os.path.lexists(dest):
  78. os.unlink(dest)
  79. os.symlink(src, dest)
  80. return
  81. for ml in multilibs.split():
  82. tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml)
  83. if not tune:
  84. bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml)
  85. continue
  86. tune_parameters = get_tune_parameters(tune, d)
  87. tune_baselib = tune_parameters['baselib']
  88. if not tune_baselib:
  89. bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune)
  90. continue
  91. tune_arch = tune_parameters['arch']
  92. tune_bitness = tune_baselib.replace('lib', '')
  93. if not tune_bitness:
  94. tune_bitness = '32' # /lib => 32bit lib
  95. tune_abiextension = tune_parameters['abiextension']
  96. if tune_abiextension:
  97. libcextension = '-gnu' + tune_abiextension
  98. else:
  99. libcextension = ''
  100. src = '../../../' + tune_baselib + '/' + \
  101. tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \
  102. '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/'
  103. dest = d.getVar('D') + d.getVar('libdir') + '/' + \
  104. d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness
  105. if os.path.lexists(dest):
  106. os.unlink(dest)
  107. os.symlink(src, dest)
  108. }
  109. def get_original_os(d):
  110. vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
  111. for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]:
  112. if suffix and vendoros.endswith(suffix):
  113. vendoros = vendoros[:-len(suffix)]
  114. # Arm must use linux-gnueabi not linux as only the former is accepted by gcc
  115. if vendoros.startswith("arm-") and not vendoros.endswith("-gnueabi"):
  116. vendoros = vendoros + "-gnueabi"
  117. return vendoros
  118. ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
  119. BASETARGET_SYS = "${@get_original_os(d)}"
  120. addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
  121. fakeroot python do_extra_symlinks() {
  122. if bb.data.inherits_class('nativesdk', d):
  123. return
  124. targetsys = d.getVar('BASETARGET_SYS')
  125. if targetsys != d.getVar('TARGET_SYS'):
  126. dest = d.getVar('D') + d.getVar('libdir') + '/' + targetsys
  127. src = d.getVar('TARGET_SYS')
  128. if not os.path.lexists(dest) and os.path.lexists(d.getVar('D') + d.getVar('libdir')):
  129. os.symlink(src, dest)
  130. }