libgcc-common.inc 5.1 KB

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