xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/gcc/libgcc-initial.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# Notes on the way the OE cross toolchain now works
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# We need a libgcc to build glibc. Tranditionally we therefore built
5*4882a593Smuzhiyun# a non-threaded and non-shared compiler (gcc-cross-initial), then use
6*4882a593Smuzhiyun# that to build libgcc-initial which is used to build glibc which we can
7*4882a593Smuzhiyun# then build gcc-cross and libgcc against.
8*4882a593Smuzhiyun#
9*4882a593Smuzhiyun# We were able to drop the glibc dependency from gcc-cross, with two tweaks:
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun# a) specify the minimum glibc version to support in a configure option
12*4882a593Smuzhiyun# b) create a dummy limits.h file so that later when glibc creates one,
13*4882a593Smuzhiyun#    the headers structure has support for it. We can do this with a simple
14*4882a593Smuzhiyun#    empty file
15*4882a593Smuzhiyun#
16*4882a593Smuzhiyun# Once gcc-cross is libc independent, we can use it to build both
17*4882a593Smuzhiyun# libgcc-initial and then later libgcc.
18*4882a593Smuzhiyun#
19*4882a593Smuzhiyun# libgcc-initial is tricky as we need to imitate the non-threaded and
20*4882a593Smuzhiyun# non-shared case. We can do that by hacking the threading mode back to
21*4882a593Smuzhiyun# "single" even if gcc reports "posix" and disable libc presence for the
22*4882a593Smuzhiyun# libgcc-intial build. We have to create the dummy limits.h to avoid
23*4882a593Smuzhiyun# compiler errors from a missing header.
24*4882a593Smuzhiyun#
25*4882a593Smuzhiyun# glibc will fail to link with libgcc-initial due to a missing "exception
26*4882a593Smuzhiyun# handler" capable libgcc (libgcc_eh.a). Since we know glibc doesn't need
27*4882a593Smuzhiyun# any exception handler, we can safely symlink to libgcc.a.
28*4882a593Smuzhiyun#
29*4882a593Smuzhiyun
30*4882a593Smuzhiyunrequire libgcc-common.inc
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunDEPENDS = "virtual/${TARGET_PREFIX}gcc"
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunLICENSE = "GPL-3.0-with-GCC-exception"
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunPACKAGES = ""
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunEXTRA_OECONF += "--disable-shared"
39*4882a593Smuzhiyun
40*4882a593Smuzhiyuninherit nopackages
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun# We really only want this built by things that need it, not any recrdeptask
43*4882a593Smuzhiyundeltask do_build
44*4882a593Smuzhiyun
45*4882a593Smuzhiyundo_configure:prepend () {
46*4882a593Smuzhiyun	install -d ${STAGING_INCDIR}
47*4882a593Smuzhiyun	touch ${STAGING_INCDIR}/limits.h
48*4882a593Smuzhiyun	sed -i -e 's#INHIBIT_LIBC_CFLAGS =.*#INHIBIT_LIBC_CFLAGS = -Dinhibit_libc#' ${B}/gcc/libgcc.mvars
49*4882a593Smuzhiyun	sed -i -e 's#inhibit_libc = false#inhibit_libc = true#' ${B}/gcc/Makefile
50*4882a593Smuzhiyun}
51*4882a593Smuzhiyun
52*4882a593Smuzhiyundo_configure:append () {
53*4882a593Smuzhiyun	sed -i -e 's#thread_header = .*#thread_header = gthr-single.h#' ${B}/${BPN}/Makefile
54*4882a593Smuzhiyun}
55*4882a593Smuzhiyun
56*4882a593Smuzhiyundo_install:append () {
57*4882a593Smuzhiyun	ln -s libgcc.a ${D}${libdir}/${TARGET_SYS}/${BINV}/libgcc_eh.a
58*4882a593Smuzhiyun}
59