blob: ceb4f5ad3b0a240b31970d5837a677cbca3c5358 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001DESCRIPTION = "klibc is intended to be a minimalistic libc subset for \
2use with initramfs. It is deliberately written for small size, \
3minimal entaglement, and portability, not speed."
4SECTION = "libs"
Andrew Geissler9aee5002022-03-30 16:27:02 +00005LICENSE = "BSD-3-Clause & GPL-2.0-only & MIT & Zlib"
Patrick Williamsb48b7b42016-08-17 15:04:38 -05006LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8b"
7DEPENDS = "linux-libc-headers perl-native"
Patrick Williamsb48b7b42016-08-17 15:04:38 -05008
Brad Bishop93c3acf2019-10-29 09:48:15 -04009SRC_URI = "${KERNELORG_MIRROR}/linux/libs/klibc/2.0/klibc-${PV}.tar.xz \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010 ${ARMPATCHES} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050011 file://klcc-consider-sysroot.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012 file://klcc-cross-accept-clang-options.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 file://0001-dash-Specify-format-string-in-fmtstr.patch \
14 file://0001-Define-in_-structs-for-non-glibc-system-libs.patch \
15 file://0001-include-linux-sysinfo.h-directly.patch \
16 file://0001-mkfifo-Implement-mkfifo.patch \
17 file://0001-always-use-bfd-linker.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 file://0001-arm-Do-not-set-a-fallback-march-and-mtune.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019 file://0001-klibc_2.0.4-add-kexec_file_load-syscall.patch \
20 file://0001-klibc-add-getrandom-syscall.patch \
21 file://0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch \
Andrew Geisslerac970dd2021-02-12 15:32:45 -060022 file://cross-clang.patch \
23 file://0001-workaround-for-overlapping-sections-in-binary.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 "
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025
26ARMPATCHES ?= ""
27
Patrick Williams213cb262021-08-07 19:21:33 -050028ARMPATCHES:arm = " \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 file://armv4-fix-v4bx.patch \
30 "
Andrew Geisslerac970dd2021-02-12 15:32:45 -060031SRC_URI[sha256sum] = "4e48f1398cfe3ce0b6df55ce6e70acf54fc8488e3aea3fb3610ee1622d9cb436"
Brad Bishop93c3acf2019-10-29 09:48:15 -040032
33S = "${WORKDIR}/klibc-${PV}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050034
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050035OPTFLAGS = "${TUNE_CCARGS} -Os -fcommon"
Patrick Williams213cb262021-08-07 19:21:33 -050036OPTFLAGS:append:toolchain-clang = " -fno-builtin-bcmp"
37OPTFLAGS:append:toolchain-clang:mipsarch = " -no-integrated-as"
Brad Bishop26bdd442019-08-16 17:08:17 -040038
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039PARALLEL_MAKE = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050040EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \
41 'CROSS_COMPILE=${TARGET_PREFIX}' \
42 'KLIBCKERNELSRC=${STAGING_DIR_TARGET}${exec_prefix}' \
43 'KLIBCLIBGCC=${STAGING_DIR_TARGET}${libdir}/${TARGET_SYS}/*/libgcc.a' \
44 'prefix=${exec_prefix}' \
45 'INSTALLROOT=${D}' \
Patrick Williamsddad1a12017-02-23 20:36:32 -060046 'INSTALLDIR=${libdir}/klibc' \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050047 'SHLIBDIR=${libdir}' \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 '${KLIBCTHUMB}' \
Brad Bishop26bdd442019-08-16 17:08:17 -040049 'KLIBCOPTFLAGS=${OPTFLAGS}' \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050050 V=1 \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050051 "
52
53export FIX_ARMV4_EABI_BX = "${FIX_V4BX}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054KLIBCTHUMB = "${@['CONFIG_KLIBC_THUMB=n', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050055
56do_configure () {
57 ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
58}
59
Patrick Williams213cb262021-08-07 19:21:33 -050060do_compile:prepend:toolchain-clang() {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061 sed -i -e 's#$(KLIBCROSS)gcc#$(KLIBCROSS)clang#g' ${S}/Makefile
62}
63
Patrick Williamsb48b7b42016-08-17 15:04:38 -050064INHIBIT_PACKAGE_STRIP = "1"
65INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
Patrick Williams213cb262021-08-07 19:21:33 -050066INSANE_SKIP:${PN} = "already-stripped"
67INSANE_SKIP:libklibc-dev = "dev-elf"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050068KLIBC_ARCH = "${TARGET_ARCH}"
Patrick Williams213cb262021-08-07 19:21:33 -050069KLIBC_ARCH:aarch64 = "arm64"
70KLIBC_ARCH:armeb = "arm"
71KLIBC_ARCH:mipsel = "mips"
72KLIBC_ARCH:mips64el = "mips64"
73KLIBC_ARCH:x86 = "i386"
74KLIBC_ARCH:x86-64 = "x86_64"
75KLIBC_ARCH:powerpc = "ppc"
76KLIBC_ARCH:powerpc64 = "ppc64"
77KLIBC_ARCH:powerpc64le = "ppc64"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050078THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})"