blob: 17fa2d52a5bc759c187194be24c41e4e6466d607 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001require glibc-common.inc
2require glibc-ld.inc
3require glibc-testing.inc
4
5STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}"
6STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${TARGET_ARCH}"
7PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
8
9TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TCBOOTSTRAP}"
10
11# glibc can't be built without optimization, if someone tries to compile an
12# entire image as -O0, we override it with -O2 here and give a note about it.
13def get_optimization(d):
14 selected_optimization = d.getVar("SELECTED_OPTIMIZATION", True)
15 if bb.utils.contains("SELECTED_OPTIMIZATION", "-O2", "x", "", d) == "x":
16 return selected_optimization
17 elif bb.utils.contains("SELECTED_OPTIMIZATION", "-O", "x", "", d) == "x":
18 bb.note("glibc can't be built with -O, -O -Wno-error will be used instead.")
19 return selected_optimization.replace("-O", "-O -Wno-error")
20 elif bb.utils.contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x":
21 bb.note("glibc can't be built with -O0, -O2 will be used instead.")
22 return selected_optimization.replace("-O0", "-O2")
23 elif bb.utils.contains("SELECTED_OPTIMIZATION", "-Os", "x", "", d) == "x":
24 bb.note("glibc can't be built with -Os, -Os -Wno-error will be used instead.")
25 return selected_optimization.replace("-Os", "-Os -Wno-error")
26 elif bb.utils.contains("SELECTED_OPTIMIZATION", "-O1", "x", "", d) == "x":
27 bb.note("glibc can't be built with -O1, -O1 -Wno-error will be used instead.")
28 return selected_optimization.replace("-O1", "-O1 -Wno-error")
29 return selected_optimization
30
31SELECTED_OPTIMIZATION := "${@get_optimization(d)}"
32
33# siteconfig.bbclass runs configure which needs a working compiler
34# For the compiler to work we need a working libc yet libc isn't
35# in the sysroots directory at this point. This means the libc.so
36# linker script won't work as the --sysroot setting isn't correct.
37# Here we create a hacked up libc linker script and pass in the right
38# flags to let configure work. Ugly.
39EXTRASITECONFIG = "CFLAGS='${CFLAGS} -Wl,-L${WORKDIR}/site_config_libc -L${WORKDIR}/site_config_libc -L${SYSROOT_DESTDIR}${libdir} -L${SYSROOT_DESTDIR}${base_libdir} -Wl,-L${SYSROOT_DESTDIR}${libdir} -Wl,-L${SYSROOT_DESTDIR}${base_libdir}'"
40siteconfig_do_siteconfig_gencache_prepend = " \
41 mkdir -p ${WORKDIR}/site_config_libc; \
42 cp ${SYSROOT_DESTDIR}${libdir}/libc.so ${WORKDIR}/site_config_libc; \
43 sed -i -e 's# ${base_libdir}# ${SYSROOT_DESTDIR}${base_libdir}#g' -e 's# ${libdir}# ${SYSROOT_DESTDIR}${libdir}#g' ${WORKDIR}/site_config_libc/libc.so; \
44"
45
46# nptl needs unwind support in gcc, which can't be built without glibc.
47DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial libgcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial"
48# nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this
49#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}"
50PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
51PROVIDES += "virtual/libintl virtual/libiconv"
52inherit autotools texinfo distro_features_check systemd
53require glibc-options.inc
54
55# The main purpose of setting this variable is to prevent users from accidently
56# overriding DISTRO_FEATRUES, causing obscure build failures because of lack
57# of libc functions.
58REQUIRED_DISTRO_FEATURES = "${DISTRO_FEATURES_LIBC}"
59
60LEAD_SONAME = "libc.so"
61
62CACHED_CONFIGUREVARS += " \
63 ac_cv_path_BASH_SHELL=${base_bindir}/bash \
64 libc_cv_slibdir=${base_libdir} \
65 libc_cv_rootsbindir=${base_sbindir} \
66 libc_cv_localedir=${localedir} \
67 libc_cv_ssp=no \
68"
69
70GLIBC_EXTRA_OECONF ?= ""
71GLIBC_EXTRA_OECONF_class-nativesdk = ""
72INHIBIT_DEFAULT_DEPS = "1"
73
74# This needs to match with glibc-collateral.inc, otherwise glibc-scripts and glibc-locale
75# will fail to find main glibc, for details see
76# http://lists.openembedded.org/pipermail/openembedded-core/2015-January/100679.html
77ARM_INSTRUCTION_SET = "arm"
78
79# glibc uses PARALLELMFLAGS variable to pass parallel build info so transfer
80# PARALLEL_MAKE into PARALLELMFLAGS and empty out PARALLEL_MAKE
81EGLIBCPARALLELISM := "PARALLELMFLAGS="${PARALLEL_MAKE}""
82EXTRA_OEMAKE[vardepsexclude] += "EGLIBCPARALLELISM"
83EXTRA_OEMAKE += "${EGLIBCPARALLELISM}"
84PARALLEL_MAKE = ""
85
86# glibc make-syscalls.sh has a number of issues with /bin/dash and
87# it's output which make calls via the SHELL also has issues, so
88# ensure make uses /bin/bash
89EXTRA_OEMAKE += "SHELL=/bin/bash"
90
91OE_FEATURES = "${@features_to_glibc_settings(d)}"
92do_configure_prepend() {
93 sed -e "s#@BASH@#/bin/sh#" -i ${S}/elf/ldd.bash.in
94 echo '${OE_FEATURES}' > ${B}/option-groups.config
95}
96
97do_configure_append() {
98 yes '' | oe_runmake config
99
100 # Remove quotation marks from OPTION_EGLIBC_NSSWITCH_FIXED_*. This will
101 # avoid install error.
102 sed -i 's/^OPTION_EGLIBC_NSSWITCH_FIXED_\(.*\)="\(.*\)"$/OPTION_EGLIBC_NSSWITCH_FIXED_\1=\2/' option-groups.config
103}
104
105GLIBC_ADDONS ?= "nptl,libidn"