blob: d48dc8b8230bfebbb228483b39f31265eea7eb5c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001BPN = "libgcc"
2
Patrick Williamsc0f7c042017-02-23 20:41:17 -06003require gcc-configure-common.inc
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004
5INHIBIT_DEFAULT_DEPS = "1"
6
7do_configure () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008 install -d ${D}${base_libdir} ${D}${libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009 mkdir -p ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010 mkdir -p ${B}/${TARGET_SYS}/${BPN}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011 cd ${B}/${BPN}
12 chmod a+x ${S}/${BPN}/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013 relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")}
14 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016EXTRACONFFUNCS += "extract_stashed_builddir"
17do_configure[depends] += "${COMPILERDEP}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19do_compile () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022}
23
24do_install () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
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 Williams213cb262021-08-07 19:21:33 -050047do_install:append:libc-baremetal () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 rmdir ${D}${base_libdir}
49}
Patrick Williams213cb262021-08-07 19:21:33 -050050do_install:append:libc-newlib () {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080051 rmdir ${D}${base_libdir}
52}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080054# No rpm package is actually created but -dev depends on it, avoid dnf error
Patrick Williams213cb262021-08-07 19:21:33 -050055RDEPENDS:${PN}-dev:libc-baremetal = ""
56RDEPENDS:${PN}-dev:libc-newlib = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057
58BBCLASSEXTEND = "nativesdk"
59
60addtask 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
67fakeroot python do_multilib_install() {
68 import re
69
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070 multilibs = d.getVar('MULTILIB_VARIANTS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 if not multilibs or bb.data.inherits_class('nativesdk', d):
72 return
73
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 binv = d.getVar('BINV')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075
Brad Bishop6e60e8b2018-02-01 10:27:11 -050076 mlprefix = d.getVar('MLPREFIX')
77 if ('%slibgcc' % mlprefix) != d.getVar('PN'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 return
79
80 if mlprefix:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081 orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082 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 Bishop6e60e8b2018-02-01 10:27:11 -050089 d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090
Brad Bishop6e60e8b2018-02-01 10:27:11 -050091 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
92 d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093
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 Williams213cb262021-08-07 19:21:33 -0500101 tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102 if not tune:
Patrick Williams213cb262021-08-07 19:21:33 -0500103 bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 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 Williamsc0f7c042017-02-23 20:41:17 -0600117 tune_abiextension = tune_parameters['abiextension']
118 if tune_abiextension:
119 libcextension = '-gnu' + tune_abiextension
120 else:
121 libcextension = ''
122
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123 src = '../../../' + tune_baselib + '/' + \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \
125 '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
128 d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129
130 if os.path.lexists(dest):
131 os.unlink(dest)
132 os.symlink(src, dest)
133}
134
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600135def get_original_os(d):
136 vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 if suffix and vendoros.endswith(suffix):
139 vendoros = vendoros[:-len(suffix)]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600140 # 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 Williamsc124f4f2015-09-15 14:41:29 -0500143 return vendoros
144
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600145ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
146BASETARGET_SYS = "${@get_original_os(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147
148addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
149fakeroot python do_extra_symlinks() {
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500150 if bb.data.inherits_class('nativesdk', d):
151 return
152
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500153 targetsys = d.getVar('BASETARGET_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500155 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 Williamsc124f4f2015-09-15 14:41:29 -0500159 os.symlink(src, dest)
160}