The morello musl libc appends the musl_git.bb recipe. The installation path and PROVIDES depend on the machine. The native libraries that go into clang resource folder are also covered. The build order is: musl-morello-native, musl-morello-libs-native, and musl-morello-target.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-core/musl/files/compiler_rt.cmake | 5 ++ recipes-core/musl/musl-morello-1.5.inc | 4 + recipes-core/musl/musl-morello-a64-so.inc | 7 ++ recipes-core/musl/musl-morello-a64.inc | 7 ++ recipes-core/musl/musl-morello-c64-so.inc | 7 ++ recipes-core/musl/musl-morello-c64.inc | 7 ++ recipes-core/musl/musl-morello-common.inc | 65 ++++++++++++++++ recipes-core/musl/musl-morello-libs-native.bb | 74 +++++++++++++++++++ recipes-core/musl/musl-morello-native.bb | 36 +++++++++ recipes-core/musl/musl-morello-target.inc | 52 +++++++++++++ recipes-core/musl/musl_%.bbappend | 17 +++++ recipes-core/musl/override-glibc.inc | 4 + recipes-core/musl/override-musl.inc | 2 + 13 files changed, 287 insertions(+) create mode 100644 recipes-core/musl/files/compiler_rt.cmake create mode 100644 recipes-core/musl/musl-morello-1.5.inc create mode 100644 recipes-core/musl/musl-morello-a64-so.inc create mode 100644 recipes-core/musl/musl-morello-a64.inc create mode 100644 recipes-core/musl/musl-morello-c64-so.inc create mode 100644 recipes-core/musl/musl-morello-c64.inc create mode 100644 recipes-core/musl/musl-morello-common.inc create mode 100644 recipes-core/musl/musl-morello-libs-native.bb create mode 100644 recipes-core/musl/musl-morello-native.bb create mode 100644 recipes-core/musl/musl-morello-target.inc create mode 100644 recipes-core/musl/musl_%.bbappend create mode 100644 recipes-core/musl/override-glibc.inc create mode 100644 recipes-core/musl/override-musl.inc
diff --git a/recipes-core/musl/files/compiler_rt.cmake b/recipes-core/musl/files/compiler_rt.cmake new file mode 100644 index 0000000..24ea9e7 --- /dev/null +++ b/recipes-core/musl/files/compiler_rt.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") +set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-1.5.inc b/recipes-core/musl/musl-morello-1.5.inc new file mode 100644 index 0000000..750120d --- /dev/null +++ b/recipes-core/musl/musl-morello-1.5.inc @@ -0,0 +1,4 @@ +LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=b03f1cc25363d094011f8f4fd8bcfb68" + +SRCBRANCH = "morello/master" +SRCTAG = "morello-release-1.5.0" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-a64-so.inc b/recipes-core/musl/musl-morello-a64-so.inc new file mode 100644 index 0000000..1a294dd --- /dev/null +++ b/recipes-core/musl/musl-morello-a64-so.inc @@ -0,0 +1,7 @@ +PROVIDES += "virtual/${OUTPUTS_NAME}-a64 virtual/crypt-a64" + +do_install:append() { + install -d ${D}${nonarch_base_libdir} + ln -rs ${TARGET_INSTALL_DIR}${libdir}/libc.so ${D}${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 + rm -f ${TARGET_INSTALL_DIR}${nonarch_base_libdir}/ld-musl-morello.so.1 +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-a64.inc b/recipes-core/musl/musl-morello-a64.inc new file mode 100644 index 0000000..7aa18a3 --- /dev/null +++ b/recipes-core/musl/musl-morello-a64.inc @@ -0,0 +1,7 @@ +require musl-morello-common.inc + +EXTRA_CONFIGUREOPTS = "--disable-morello" + +ARCH_TRIPLE = "${A64_ARCH_TRIPLE}" +LIB_TRIPLE = "${A64_LIB_TRIPLE}" +ARCH_FLAGS = "-march=armv8" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-c64-so.inc b/recipes-core/musl/musl-morello-c64-so.inc new file mode 100644 index 0000000..b6c8c75 --- /dev/null +++ b/recipes-core/musl/musl-morello-c64-so.inc @@ -0,0 +1,7 @@ +PROVIDES += "virtual/${OUTPUTS_NAME}-c64 virtual/crypt-c64" + +do_install:append() { + install -d ${D}${nonarch_base_libdir} + ln -rs ${TARGET_INSTALL_DIR}${libdir}/libc.so ${D}${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 + rm -f ${TARGET_INSTALL_DIR}${nonarch_base_libdir}/ld-musl-morello.so.1 +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-c64.inc b/recipes-core/musl/musl-morello-c64.inc new file mode 100644 index 0000000..761b9d2 --- /dev/null +++ b/recipes-core/musl/musl-morello-c64.inc @@ -0,0 +1,7 @@ +require musl-morello-common.inc + +EXTRA_CONFIGUREOPTS = "--enable-morello" + +ARCH_TRIPLE = "${C64_ARCH_TRIPLE}" +LIB_TRIPLE = "${C64_LIB_TRIPLE}" +ARCH_FLAGS = "-march=morello+c64 -mabi=purecap" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-common.inc b/recipes-core/musl/musl-morello-common.inc new file mode 100644 index 0000000..f296e08 --- /dev/null +++ b/recipes-core/musl/musl-morello-common.inc @@ -0,0 +1,65 @@ +require musl-morello-${MORELLO_RELEASE_VERSION}.inc + +DESCRIPTION = "CHERI enabled musl libc" +OUTPUTS_NAME = "libc" +LICENSE = "MIT" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +SUMMARY = "CHERI enabled musl libc" +SRC_URI = " \ + git://git.morello-project.org/morello/musl-libc;protocol=https;tag=${SRCTAG};branch=${SRCBRANCH} \ + file://files/compiler_rt.cmake \ +" + +SRCREV ="" + +PV = "git${SRCPV}" +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +TARGET_INSTALL_DIR = "${D}${MUSL_INSTALL_DIR}" + +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +CONFIGUREOPTS = " \ + --prefix=${prefix} \ + --exec-prefix=${exec_prefix} \ + --bindir=${bindir} \ + --libdir=${libdir} \ + --includedir=${includedir} \ + --syslibdir=${nonarch_base_libdir} \ + --target=${ARCH_TRIPLE} \ + --disable-libshim \ +" + +COMPILERRT_CMAKE = "-Wno-dev \ + -DCMAKE_TOOLCHAIN_FILE=compiler_rt.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_CONFIG_PATH='${LLVM_CONFIG}' \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_SKIP_BUILD_RPATH=OFF \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ + -DLLVM_TARGETS_TO_BUILD='AArch64' \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCOMPILER_RT_BUILD_XRAY=OFF \ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF \ +" +do_configure() { + export CFLAGS="" + local config="${CONFIGUREOPTS}" + echo "Install dir ${TARGET_INSTALL_DIR} with ${TCLIBC} MACHINE_INC ${MACHINE_INC}" + config="${config} --target=${ARCH_TRIPLE} ${EXTRA_CONFIGUREOPTS} --disable-shared" + ${S}/configure ${config} +} + +do_compile() { + export CFLAGS="" + oe_runmake +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-libs-native.bb b/recipes-core/musl/musl-morello-libs-native.bb new file mode 100644 index 0000000..6318aa9 --- /dev/null +++ b/recipes-core/musl/musl-morello-libs-native.bb @@ -0,0 +1,74 @@ +inherit cmake llvm-morello-native native +require musl-morello-${MORELLO_ARCH}.inc + +DESCRIPTION = "Libraries that go into the clang resource folder, \ + search path for that folder is relative to clang directory itself." + +DEPENDS += "musl-morello-native" +PROVIDES = "virtual/musl-morello-libs-native" + +B_COMPILERRT = "${WORKDIR}/build_compiler_rt" +S_CRT = "${LLVM_SHARED_SOURCE}/compiler-rt/lib/crt" +S_COMPILER_RT = "${LLVM_SHARED_SOURCE}/compiler-rt" + +do_install[depends] += "llvm-morello-native:do_symlink" + +FILES:${PN} += "$(${CC} -print-resource-dir)/lib/${LIB_TRIPLE}" +INSANE_SKIP:${PN} += "$(${CC} -print-resource-dir)/lib/${LIB_TRIPLE}" + +BUILD_CC = "${LLVM_PATH}/clang" +BUILD_CXX = "${LLVM_PATH}/clang++" +BUILD_CPP = "${LLVM_PATH}/clang" +BUILD_CCLD = "${LLVM_PATH}/clang" +BUILD_RANLIB = "${LLVM_PATH}/llvm-ranlib" +BUILD_AR = "${LLVM_PATH}/llvm-ar" +BUILD_AS = "${LLVM_PATH}/llvm-as" +BUILD_NM = "${LLVM_PATH}/llvm-nm" +BUILD_OBJDUMP = "${LLVM_PATH}/llvm-objdump" +BUILD_OBJCOPY = "${LLVM_PATH}/llvm-objcopy" +BUILD_STRIP = "${LLVM_PATH}/llvm-strip" +BUILD_STRINGS = "${LLVM_PATH}/llvm-strings" +BUILD_READELF = "${LLVM_PATH}/llvm-readelf" +BUILD_LD = "${LLVM_PATH}/ld.lld" +BUILD_LTO = "-fuse-ld=lld" +BUILD_HOSTCC = "${LLVM_PATH}/clang" + + +do_install() { + + export CFLAGS="" + + local resourcedir=$(${CC} -print-resource-dir) + local destdir="${resourcedir}/lib/${LIB_TRIPLE}" + local builddir="${B_COMPILERRT}/${ARCH_TRIPLE}" + local sysroot="${STAGING_LIBDIR_NATIVE}/musl-morello-native/${ARCH_TRIPLE}" + local target="${LIB_TRIPLE}" + + install -d ${destdir} + mkdir -p ${builddir} + + local ccflags="--target=${target} ${ARCH_FLAGS} -nostdinc -isystem ${sysroot}/include" + ${CC} ${ccflags} -c ${S_CRT}/crtbegin.c -o ${destdir}/clang_rt.crtbegin.o + ${CC} ${ccflags} -c ${S_CRT}/crtend.c -o ${destdir}/clang_rt.crtend.o + + cp -f ${WORKDIR}/files/compiler_rt.cmake ${builddir}/compiler_rt.cmake + + local config="${COMPILERRT_CMAKE}" + config="${config} -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${LIB_TRIPLE} \ + -DCMAKE_INSTALL_RPATH=$ORIGIN/../lib \ + -DCMAKE_TOOLCHAIN_FILE='${builddir}/compiler_rt.cmake' \ + " + cmake -S ${S_COMPILER_RT} -B ${builddir} ${config} -DCMAKE_C_FLAGS="-nostdinc -isystem ${sysroot}/include" -DCMAKE_C_COMPILER_TARGET="${LIB_TRIPLE} ${ARCH_FLAGS}" + + cd ${builddir} + make ${PARALLEL_MAKE} clang_rt.builtins-aarch64 + + install ${builddir}/lib/linux/libclang_rt.builtins-aarch64.a ${destdir}/libclang_rt.builtins.a + + install -d ${D}${libdir}/clang/${LLVM_VERSION}/lib/${LIB_TRIPLE} + local install_dir=${D}${libdir}/clang/${LLVM_VERSION}/lib/${LIB_TRIPLE} + + install ${destdir}/clang_rt.crtbegin.o ${install_dir}/clang_rt.crtbegin.o + install ${destdir}/clang_rt.crtend.o ${install_dir}/clang_rt.crtend.o + install ${destdir}/libclang_rt.builtins.a ${install_dir}/libclang_rt.builtins.a +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-native.bb b/recipes-core/musl/musl-morello-native.bb new file mode 100644 index 0000000..e7e6792 --- /dev/null +++ b/recipes-core/musl/musl-morello-native.bb @@ -0,0 +1,36 @@ +inherit llvm-morello-native native +require musl-morello-${MORELLO_ARCH}.inc + +DESCRIPTION = " That is right, we have a native libc sysroot that is needed as an intermediate step \ +to provide crt and compiler-rt that will be used by the cross compiler, this recipe exist to avoid having \ +a native recipe dependant on a target recipe... which is actually the case, but there you go. Note that the \ +libc sysroot is NOT actually native, it is just a trick." + +PROVIDES = "virtual/musl-morello-native" + +BUILD_CC = "${LLVM_PATH}/clang" +BUILD_CXX = "${LLVM_PATH}/clang++" +BUILD_CPP = "${LLVM_PATH}/clang" +BUILD_CCLD = "${LLVM_PATH}/clang" +BUILD_RANLIB = "${LLVM_PATH}/llvm-ranlib" +BUILD_AR = "${LLVM_PATH}/llvm-ar" +BUILD_AS = "${LLVM_PATH}/llvm-as" +BUILD_NM = "${LLVM_PATH}/llvm-nm" +BUILD_OBJDUMP = "${LLVM_PATH}/llvm-objdump" +BUILD_OBJCOPY = "${LLVM_PATH}/llvm-objcopy" +BUILD_STRIP = "${LLVM_PATH}/llvm-strip" +BUILD_STRINGS = "${LLVM_PATH}/llvm-strings" +BUILD_READELF = "${LLVM_PATH}/llvm-readelf" +BUILD_LD = "${LLVM_PATH}/ld.lld" +BUILD_LTO = "-fuse-ld=lld" +BUILD_HOSTCC = "${LLVM_PATH}/clang" + +FILES:${PN} += "${libdir}/${PN}/${ARCH_TRIPLE}" +INSTALL_DIR = "${D}/${ARCH_TRIPLE}" + +do_install() { + export CFLAGS="" + make install DESTDIR="${INSTALL_DIR}" + install -d ${D}${libdir}/${PN}/${ARCH_TRIPLE} + cp -rf ${INSTALL_DIR}${prefix}/* ${D}${libdir}/${PN}/${ARCH_TRIPLE} +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-target.inc b/recipes-core/musl/musl-morello-target.inc new file mode 100644 index 0000000..0b804fc --- /dev/null +++ b/recipes-core/musl/musl-morello-target.inc @@ -0,0 +1,52 @@ +inherit llvm-morello-native + +COMPATIBLE_MACHINE = "morello" +SECTION = "libs" + +DEPENDS:append = " virtual/musl-morello-libs-native" + +MUSL_LDSO_ARCH = "aarch64_purecap" + +FILES:${PN} = "${MUSL_INSTALL_DIR}" +FILES:${PN} += "${MUSL_INSTALL_DIR}${datadir} ${MUSL_INSTALL_DIR}${bindir} ${MUSL_INSTALL_DIR}${libdir}" +FILES:${PN} += "${MUSL_INSTALL_DIR}${includedir} ${MUSL_INSTALL_DIR}${includedir}/sys \ + ${MUSL_INSTALL_DIR}${includedir}/arpa ${MUSL_INSTALL_DIR}${includedir}/bits \ + ${MUSL_INSTALL_DIR}${includedir}/net ${MUSL_INSTALL_DIR}${includedir}/netinet \ + ${MUSL_INSTALL_DIR}${includedir}/netpacket ${MUSL_INSTALL_DIR}${includedir}/arpa \ + ${MUSL_INSTALL_DIR}${includedir}/scsi ${MUSL_INSTALL_DIR}${includedir}/sys" + +FILES:${PN} += "${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 ${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path" + +FILES:${PN}-staticdev = "${MUSL_INSTALL_DIR}${libdir}/libc.a" +FILES:${PN}-dev =+ "${MUSL_INSTALL_DIR}${libdir}/libcrypt.a ${MUSL_INSTALL_DIR}${libdir}/libdl.a ${MUSL_INSTALL_DIR}${libdir}/libm.a \ + ${MUSL_INSTALL_DIR}${libdir}/libpthread.a ${MUSL_INSTALL_DIR}${libdir}/libresolv.a \ + ${MUSL_INSTALL_DIR}${libdir}/librt.a ${MUSL_INSTALL_DIR}${libdir}/libutil.a ${MUSL_INSTALL_DIR}${libdir}/libxnet.a \ + " + +SYSROOT_DIRS += "${sysconfdir} ${MUSL_INSTALL_DIR}${includedir}" + +do_install() { + + echo "Installing into ${TARGET_INSTALL_DIR}" + + export CFLAGS="" + + install -d ${TARGET_INSTALL_DIR}${includedir} ${TARGET_INSTALL_DIR}${includedir}/sys ${TARGET_INSTALL_DIR}${includedir}/arpa \ + ${TARGET_INSTALL_DIR}${includedir}/bits ${TARGET_INSTALL_DIR}${includedir}/net ${TARGET_INSTALL_DIR}${includedir}/netinet \ + ${TARGET_INSTALL_DIR}${includedir}/netpacket ${TARGET_INSTALL_DIR}${includedir}/arpa ${TARGET_INSTALL_DIR}${includedir}/scsi \ + ${TARGET_INSTALL_DIR}${includedir}/sys + + local destdir="${TARGET_INSTALL_DIR}" + + local config="${CONFIGUREOPTS}" + config="${config} --target=${ARCH_TRIPLE} ${EXTRA_CONFIGUREOPTS}" + + ${S}/configure ${CONFIGUREOPTS} + oe_runmake + oe_runmake install DESTDIR="${destdir}" + + install -d ${TARGET_INSTALL_DIR}${sysconfdir} + + echo "${TARGET_INSTALL_DIR}${base_libdir}" > ${TARGET_INSTALL_DIR}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path + echo "${TARGET_INSTALL_DIR}${libdir}" >> ${TARGET_INSTALL_DIR}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path +} \ No newline at end of file diff --git a/recipes-core/musl/musl_%.bbappend b/recipes-core/musl/musl_%.bbappend new file mode 100644 index 0000000..cfe23e8 --- /dev/null +++ b/recipes-core/musl/musl_%.bbappend @@ -0,0 +1,17 @@ +require musl-morello-${MORELLO_ARCH}.inc musl-morello-${MORELLO_ARCH}-so.inc musl-morello-target.inc + +MACHINE_INC ?= "" +MACHINE_INC:morello-linux-glibc = "override-glibc.inc" +MACHINE_INC:morello-linux-musl = "override-musl.inc" + +require ${MACHINE_INC} + +DEPENDS:remove = "virtual/${TARGET_PREFIX}binutils \ + virtual/${TARGET_PREFIX}gcc \ + libgcc-initial \ + linux-libc-headers \ + bsd-headers \ + libssp-nonshared \ + " + +RDEPENDS:${PN}-dev:remove = "linux-libc-headers-dev bsd-headers-dev libssp-nonshared-staticdev" \ No newline at end of file diff --git a/recipes-core/musl/override-glibc.inc b/recipes-core/musl/override-glibc.inc new file mode 100644 index 0000000..9ccf9c2 --- /dev/null +++ b/recipes-core/musl/override-glibc.inc @@ -0,0 +1,4 @@ +PROVIDES:append = " virtual/musl-morello" +PROVIDES:remove = "virtual/libc virtual/libiconv virtual/libintl virtual/crypt" +RPROVIDES:${PN}-dev:remove = "libc-dev virtual-libc-dev" +RPROVIDES:${PN}:append = " musl-libc" \ No newline at end of file diff --git a/recipes-core/musl/override-musl.inc b/recipes-core/musl/override-musl.inc new file mode 100644 index 0000000..1a810e6 --- /dev/null +++ b/recipes-core/musl/override-musl.inc @@ -0,0 +1,2 @@ +PROVIDES:append = " virtual/musl-morello" +RPROVIDES:${PN}:append = " musl-libc" \ No newline at end of file