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