blob: d9084af51ad72107bdd899911f30e3bb6c2c8d31 [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 Williams92b42cb2022-09-03 06:53:57 -050013 ${S}/${BPN}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015EXTRACONFFUNCS += "extract_stashed_builddir"
16do_configure[depends] += "${COMPILERDEP}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017
18do_compile () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020 oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021}
22
23do_install () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026
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 Williams213cb262021-08-07 19:21:33 -050046do_install:append:libc-baremetal () {
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050047 if [ "${base_libdir}" != "${libdir}" ]; then
48 rmdir ${D}${base_libdir}
49 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050}
Patrick Williams213cb262021-08-07 19:21:33 -050051do_install:append:libc-newlib () {
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050052 if [ "${base_libdir}" != "${libdir}" ]; then
53 rmdir ${D}${base_libdir}
54 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057# No rpm package is actually created but -dev depends on it, avoid dnf error
Andrew Geissler615f2f12022-07-15 14:00:58 -050058DEV_PKG_DEPENDENCY:libc-baremetal = ""
59DEV_PKG_DEPENDENCY:libc-newlib = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060
61BBCLASSEXTEND = "nativesdk"
62
63addtask 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
70fakeroot python do_multilib_install() {
71 import re
72
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073 multilibs = d.getVar('MULTILIB_VARIANTS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 if not multilibs or bb.data.inherits_class('nativesdk', d):
75 return
76
Brad Bishop6e60e8b2018-02-01 10:27:11 -050077 binv = d.getVar('BINV')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078
Brad Bishop6e60e8b2018-02-01 10:27:11 -050079 mlprefix = d.getVar('MLPREFIX')
80 if ('%slibgcc' % mlprefix) != d.getVar('PN'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081 return
82
83 if mlprefix:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084 orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 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 Bishop6e60e8b2018-02-01 10:27:11 -050092 d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
95 d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096
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 Williams213cb262021-08-07 19:21:33 -0500104 tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 if not tune:
Patrick Williams213cb262021-08-07 19:21:33 -0500106 bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 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 Williamsc0f7c042017-02-23 20:41:17 -0600120 tune_abiextension = tune_parameters['abiextension']
121 if tune_abiextension:
122 libcextension = '-gnu' + tune_abiextension
123 else:
124 libcextension = ''
125
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 src = '../../../' + tune_baselib + '/' + \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \
128 '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500130 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
131 d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132
133 if os.path.lexists(dest):
134 os.unlink(dest)
135 os.symlink(src, dest)
136}
137
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600138def get_original_os(d):
139 vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500140 for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141 if suffix and vendoros.endswith(suffix):
142 vendoros = vendoros[:-len(suffix)]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600143 # 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 Williamsc124f4f2015-09-15 14:41:29 -0500146 return vendoros
147
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600148ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
149BASETARGET_SYS = "${@get_original_os(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150
151addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
152fakeroot python do_extra_symlinks() {
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500153 if bb.data.inherits_class('nativesdk', d):
154 return
155
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156 targetsys = d.getVar('BASETARGET_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 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 Williamsc124f4f2015-09-15 14:41:29 -0500162 os.symlink(src, dest)
163}