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