blob: 54cd3c24bc2985537263923f2df3c5ac4fbd2cf4 [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"
5LICENSE = "BSD-3-Clause & GPL-2.0 & MIT & Zlib"
6LIC_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-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch \
19 file://0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch \
20 file://0001-arm-Do-not-set-a-fallback-march-and-mtune.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021 file://0001-klibc_2.0.4-add-kexec_file_load-syscall.patch \
22 file://0001-klibc-add-getrandom-syscall.patch \
23 file://0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch \
Andrew Geissler1548c072019-02-22 16:03:50 -060024 file://0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 "
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026
27ARMPATCHES ?= ""
28
Brad Bishop93c3acf2019-10-29 09:48:15 -040029ARMPATCHES_arm = " \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 file://armv4-fix-v4bx.patch \
31 "
32
Brad Bishop93c3acf2019-10-29 09:48:15 -040033SRC_URI[md5sum] = "712f8bc1a069e03d92584b7f5380c521"
34SRC_URI[sha256sum] = "abef2637ca823485d9c90ce9512e2b08a65047ec4da204635eeaef95a41a9122"
35
36S = "${WORKDIR}/klibc-${PV}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050037
Brad Bishop26bdd442019-08-16 17:08:17 -040038OPTFLAGS = "${TUNE_CCARGS} -Os"
Brad Bishop90ca7472019-08-20 09:15:15 -040039OPTFLAGS_append_toolchain-clang = " -fno-builtin-bcmp"
Brad Bishope42b3e32020-01-15 22:08:42 -050040OPTFLAGS_append_toolchain-clang_mipsarch = " -no-integrated-as"
Brad Bishop26bdd442019-08-16 17:08:17 -040041
Brad Bishop6e60e8b2018-02-01 10:27:11 -050042PARALLEL_MAKE = ""
Patrick Williamsb48b7b42016-08-17 15:04:38 -050043EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \
44 'CROSS_COMPILE=${TARGET_PREFIX}' \
45 'KLIBCKERNELSRC=${STAGING_DIR_TARGET}${exec_prefix}' \
46 'KLIBCLIBGCC=${STAGING_DIR_TARGET}${libdir}/${TARGET_SYS}/*/libgcc.a' \
47 'prefix=${exec_prefix}' \
48 'INSTALLROOT=${D}' \
Patrick Williamsddad1a12017-02-23 20:36:32 -060049 'INSTALLDIR=${libdir}/klibc' \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050050 'SHLIBDIR=${libdir}' \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 '${KLIBCTHUMB}' \
Brad Bishop26bdd442019-08-16 17:08:17 -040052 'KLIBCOPTFLAGS=${OPTFLAGS}' \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050053 V=1 \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050054 "
55
56export FIX_ARMV4_EABI_BX = "${FIX_V4BX}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057KLIBCTHUMB = "${@['CONFIG_KLIBC_THUMB=n', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050058
59do_configure () {
60 ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
61}
62
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063do_compile_prepend_toolchain-clang() {
64 sed -i -e 's#$(KLIBCROSS)gcc#$(KLIBCROSS)clang#g' ${S}/Makefile
65}
66
Patrick Williamsb48b7b42016-08-17 15:04:38 -050067INHIBIT_PACKAGE_STRIP = "1"
68INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
69INSANE_SKIP_${PN} = "already-stripped"
70INSANE_SKIP_libklibc-dev = "dev-elf"
71KLIBC_ARCH = "${TARGET_ARCH}"
72KLIBC_ARCH_aarch64 = "arm64"
73KLIBC_ARCH_armeb = "arm"
74KLIBC_ARCH_mipsel = "mips"
Andrew Geissler1548c072019-02-22 16:03:50 -060075KLIBC_ARCH_mips64el = "mips64"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076KLIBC_ARCH_x86 = "i386"
77KLIBC_ARCH_x86-64 = "x86_64"
78KLIBC_ARCH_powerpc = "ppc"
79KLIBC_ARCH_powerpc64 = "ppc64"
Andrew Geissler82c905d2020-04-13 13:39:40 -050080KLIBC_ARCH_powerpc64le = "ppc64"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050081THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})"