From ed9b6c682f2484f2c9045875988eb03158d06791 Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Mon, 5 Sep 2022 15:06:02 +0800 Subject: [PATCH 01/35] compile: add musl compile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use the base C library based on the toolchain name * MUSL toolchain download: https://isrc.iscas.ac.cn/download/musl-cross-tools/musl-cross-tools.tar Signed-off-by: miaoyuxia --- scripts/compile.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/compile.sh b/scripts/compile.sh index 423f2d77cc2..67f4caa85d8 100644 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -134,6 +134,23 @@ set_env() DATETIME="$(date +%Y%m%d%H%M%S)" fi grep -q "DATETIME" conf/local.conf || echo "DATETIME = \"${DATETIME}\"" >> conf/local.conf + + if grep -q -wi "$LIBC" conf/local.conf ; then + sed -i '/LIBC/d' conf/local.conf + sed -i '/TCMODE-LIBC/d' conf/local.conf + sed -i '/crypt/d' conf/local.conf + fi + if [[ $TOOLCHAIN_DIR == *"musl"* ]];then + sed -i '$a\LIBC = "musl"' conf/local.conf + sed -i '$a\crypt = "musl"' conf/local.conf + sed -i '$a\TCMODE-LIBC = "musl"' conf/local.conf + sed -i 's/aarch64-openeuler-linux-gnu/aarch64-openeuler-linux-musl/g' conf/local.conf + else + sed -i '$a\LIBC = "glibc"' conf/local.conf + sed -i '$a\TCMODE-LIBC = "glibc-external"' conf/local.conf + sed -i '$a\crypt = "libxcrypt-external"' conf/local.conf + sed -i 's/aarch64-openeuler-linux-musl/aarch64-openeuler-linux-gnu/g' conf/local.conf + fi } main() -- Gitee From 5dbbe2dbf1ed2a1baebdecdbc584fd2608ab534b Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Mon, 5 Sep 2022 15:13:45 +0800 Subject: [PATCH 02/35] yocto: musl config support * Synchronize the base C library configuration Signed-off-by: miaoyuxia --- .../conf/distro/include/tcmode-external.inc | 12 ++++++------ meta-openeuler/conf/distro/openeuler.conf | 2 +- .../recipes-core/images/openeuler-image-common.inc | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/meta-openeuler/conf/distro/include/tcmode-external.inc b/meta-openeuler/conf/distro/include/tcmode-external.inc index c40e8eaa6c1..6419ec77dc0 100644 --- a/meta-openeuler/conf/distro/include/tcmode-external.inc +++ b/meta-openeuler/conf/distro/include/tcmode-external.inc @@ -25,11 +25,11 @@ PREFERRED_PROVIDER_gcc-sanitizers ?= "gcc-sanitizers-external" PREFERRED_PROVIDER_libgcc-initial = "libgcc-external" PREFERRED_PROVIDER_libtirpc = "libtirpc-external" PREFERRED_PROVIDER_libgfortran = "libgfortran-external" -PREFERRED_PROVIDER_glibc ?= "glibc-external" -PREFERRED_PROVIDER_virtual/libc ?= "glibc-external" -PREFERRED_PROVIDER_virtual/libintl ?= "glibc-external" -PREFERRED_PROVIDER_virtual/libiconv ?= "glibc-external" -PREFERRED_PROVIDER_virtual/crypt ?= "libxcrypt-external" +PREFERRED_PROVIDER_glibc ?= "${TCMODE-LIBC}" +PREFERRED_PROVIDER_virtual/libc ?= "${TCMODE-LIBC}" +PREFERRED_PROVIDER_virtual/libintl ?= "${TCMODE-LIBC}" +PREFERRED_PROVIDER_virtual/libiconv ?= "${TCMODE-LIBC}" +PREFERRED_PROVIDER_virtual/crypt ?= "${crypt}" PREFERRED_PROVIDER_gdb-cross-${TARGET_ARCH} ?= "gdb-external-cross-${TARGET_ARCH}" PREFERRED_PROVIDER_oprofile ??= "oprofile" # Work around bug where the implicitly created mlprefix preference isn't being @@ -38,7 +38,7 @@ PREFERRED_PROVIDER_${MLPREFIX}gdbserver ?= "${MLPREFIX}gdb" # This is defined in default-providers.inc, which is parsed before the tcmode, # so we can't use ?= -PREFERRED_PROVIDER_linux-libc-headers = "glibc-external" +PREFERRED_PROVIDER_linux-libc-headers = "${TCMODE-LIBC}" PNBLACKLIST[linux-libc-headers] = "not building with an external toolchain" PNBLACKLIST[linux-libc-headers-yocto] = "not building with an external toolchain" diff --git a/meta-openeuler/conf/distro/openeuler.conf b/meta-openeuler/conf/distro/openeuler.conf index 1ce3bcd3040..5f83f4c037b 100644 --- a/meta-openeuler/conf/distro/openeuler.conf +++ b/meta-openeuler/conf/distro/openeuler.conf @@ -48,7 +48,7 @@ DISTRO_EXTRA_RRECOMMENDS += "${OPENEULER_DEFAULT_EXTRA_RRECOMMENDS}" TCLIBCAPPEND = "" # by default glibc is used, in future muslc will be supported -TCLIBC = "glibc" +TCLIBC = "${LIBC}" # do not use default download dir, use openeuler's configuration OPENEULER_REPO_NAME ?= "${BPN}" diff --git a/meta-openeuler/recipes-core/images/openeuler-image-common.inc b/meta-openeuler/recipes-core/images/openeuler-image-common.inc index 40d8e6f1255..b1247d0b65b 100644 --- a/meta-openeuler/recipes-core/images/openeuler-image-common.inc +++ b/meta-openeuler/recipes-core/images/openeuler-image-common.inc @@ -42,4 +42,4 @@ set_permissions_from_rootfs() { } -DISTRO_FEATURES += "glibc" +DISTRO_FEATURES += "${LIBC}" -- Gitee From 257da9551a3969b7d7730aea4e8c850da57fa402 Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Tue, 6 Sep 2022 08:05:30 +0000 Subject: [PATCH 03/35] musl: import musl-1.2.3 support * import musl-1.2.3 config file * add musl support headers Signed-off-by: zhanglimin --- .../recipes-external/musl/musl_1.2.3.bb | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 meta-openeuler/recipes-external/musl/musl_1.2.3.bb diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb new file mode 100644 index 00000000000..40a128765b7 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -0,0 +1,75 @@ +SUMMARY = "An implementation of the standard library for Linux-based systems" +DESCRIPTION = "A new standard library to power a new generation of Linux-based devices. \ +musl is lightweight, fast, simple, free, and strives to be correct in the sense of \ +standards-conformance and safety." + +HOMEPAGE = "http://www.musl-libc.org/" +LICENSE = "MIT" +SECTION = "libs" + +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +PACKAGES = "${PN} ${PN}-dev ${PN}-staticdev" + +PROVIDES += "virtual/libc virtual/libiconv virtual/libintl virtual/crypt" + +DEPENDS = "virtual/${TARGET_PREFIX}gcc \ + bsd-headers \ + " +INHIBIT_DEFAULT_DEPS = "1" + +PR = "r1" + +#require ../../recipes-devtools/gcc/gcc-bin-toolchain.inc + + +SRC_URI = "file://aarch64-openeuler-linux-musl-cross" +#SRC_URI = "file://aarch64-linux-musl-cross" + +INHIBIT_SYSROOT_STRIP = "1" +INSANE_SKIP_${PN} += "already-stripped" + +S = "${WORKDIR}/aarch64-openeuler-linux-musl-cross" +#S = "${WORKDIR}/aarch64-linux-musl-cross" + +PSEUDO_DISABLED = "1" + +do_configure() { + : +} + +do_compile () { + : +} + + +do_install() { + install -m 0755 -d ${D}/ + install -m 0755 -d ${D}/lib/ + cp -pPR ${S}/aarch64-linux-musl/* ${D}/ + chmod -R 755 ${D}/lib/ + rm -rf ${D}/etc/rpc + rm -rf ${D}${datadir}/info + rm -rf ${D}/lib/debug + chown root:root ${D}/ -R +} + +FILES_${PN} = " \ + /lib/*.so \ + /lib/*.so.* \ + ${base_sbindir}/ldconfig \ +" +FILES_${PN}-staticdev = " \ + /lib/*.a \ +" + + +RDEPENDSPN_${}-dev += "bsd-headers-dev" + + +INSANE_SKIP_${PN} += "installed-vs-shipped" +INSANE_SKIP += "dev-elf dev-so" + + +SYSROOT_DIRS += "/*" + -- Gitee From 00691656b0b5425195e42c4dde023aab38b6b59b Mon Sep 17 00:00:00 2001 From: Zhang Limin Date: Fri, 9 Sep 2022 07:47:54 +0000 Subject: [PATCH 04/35] musl: delete libmetal config * libmetal adapts musl * modify config file and add patch Signed-off-by: zhanglimin --- .../recipes-openamp/libmetal/libmetal.inc | 4 ++- .../libmetal-delete-librt-hugetlbfs.patch | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 meta-openeuler/recipes-openamp/libmetal/libmetal/libmetal-delete-librt-hugetlbfs.patch diff --git a/meta-openeuler/recipes-openamp/libmetal/libmetal.inc b/meta-openeuler/recipes-openamp/libmetal/libmetal.inc index d6677028b3a..0cb0dbd5125 100644 --- a/meta-openeuler/recipes-openamp/libmetal/libmetal.inc +++ b/meta-openeuler/recipes-openamp/libmetal/libmetal.inc @@ -19,7 +19,9 @@ LIC_FILES_CHKSUM = "file://LICENSE.md;md5=fe0b8a4beea8f0813b606d15a3df3d3c" inherit cmake ### Build metadata: SRC_URI, SRCDATA, S, B, FILESEXTRAPATHS.... -SRC_URI = "file://libmetal/${BPN}-${PV}.tar.gz" +SRC_URI = "file://libmetal/${BPN}-${PV}.tar.gz \ + file://libmetal-delete-librt-hugetlbfs.patch \ +" S = "${WORKDIR}/${BPN}-${PV}" diff --git a/meta-openeuler/recipes-openamp/libmetal/libmetal/libmetal-delete-librt-hugetlbfs.patch b/meta-openeuler/recipes-openamp/libmetal/libmetal/libmetal-delete-librt-hugetlbfs.patch new file mode 100644 index 00000000000..1c14876b415 --- /dev/null +++ b/meta-openeuler/recipes-openamp/libmetal/libmetal/libmetal-delete-librt-hugetlbfs.patch @@ -0,0 +1,32 @@ +--- libmetal-2021.10.0-old/cmake/depends.cmake 2021-10-30 04:37:33.000000000 +0800 ++++ libmetal-2021.10.0/cmake/depends.cmake 2022-07-18 11:21:36.610139680 +0800 +@@ -7,12 +7,12 @@ + check_include_files (stdatomic.h HAVE_STDATOMIC_H) + check_include_files (linux/futex.h HAVE_FUTEX_H) + +- find_package (HugeTLBFS) +- if (HUGETLBFS_FOUND) +- collect (PROJECT_INC_DIRS "${HUGETLBFS_INCLUDE_DIR}") +- collect (PROJECT_LIB_DEPS "${HUGETLBFS_LIBRARIES}") +- add_definitions(-DHAVE_HUGETLBFS_H) +- endif(HUGETLBFS_FOUND) ++ # find_package (HugeTLBFS) ++ #if (HUGETLBFS_FOUND) ++ # collect (PROJECT_INC_DIRS "${HUGETLBFS_INCLUDE_DIR}") ++ # collect (PROJECT_LIB_DEPS "${HUGETLBFS_LIBRARIES}") ++ # add_definitions(-DHAVE_HUGETLBFS_H) ++ #endif(HUGETLBFS_FOUND) + + find_package (LibSysFS REQUIRED) + collect (PROJECT_INC_DIRS "${LIBSYSFS_INCLUDE_DIR}") +@@ -21,8 +21,8 @@ + find_package(Threads REQUIRED) + collect (PROJECT_LIB_DEPS "${CMAKE_THREAD_LIBS_INIT}") + +- find_package(LibRt REQUIRED) +- collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}") ++ #find_package(LibRt REQUIRED) ++ #collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}") + + else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + -- Gitee From a9602634053642eb4b6271b5283ec705094502ab Mon Sep 17 00:00:00 2001 From: Zhang Limin Date: Wed, 14 Sep 2022 01:56:20 +0000 Subject: [PATCH 05/35] musl: modify libmetal config * libmetal adapts musl * modify config file and add bbappend Signed-off-by: zhanglimin --- meta-openeuler/recipes-openamp/libmetal/libmetal.inc | 4 +--- meta-openeuler/recipes-openamp/libmetal/libmetal_%.bbappend | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 meta-openeuler/recipes-openamp/libmetal/libmetal_%.bbappend diff --git a/meta-openeuler/recipes-openamp/libmetal/libmetal.inc b/meta-openeuler/recipes-openamp/libmetal/libmetal.inc index 0cb0dbd5125..d6677028b3a 100644 --- a/meta-openeuler/recipes-openamp/libmetal/libmetal.inc +++ b/meta-openeuler/recipes-openamp/libmetal/libmetal.inc @@ -19,9 +19,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.md;md5=fe0b8a4beea8f0813b606d15a3df3d3c" inherit cmake ### Build metadata: SRC_URI, SRCDATA, S, B, FILESEXTRAPATHS.... -SRC_URI = "file://libmetal/${BPN}-${PV}.tar.gz \ - file://libmetal-delete-librt-hugetlbfs.patch \ -" +SRC_URI = "file://libmetal/${BPN}-${PV}.tar.gz" S = "${WORKDIR}/${BPN}-${PV}" diff --git a/meta-openeuler/recipes-openamp/libmetal/libmetal_%.bbappend b/meta-openeuler/recipes-openamp/libmetal/libmetal_%.bbappend new file mode 100644 index 00000000000..f0e1f65a521 --- /dev/null +++ b/meta-openeuler/recipes-openamp/libmetal/libmetal_%.bbappend @@ -0,0 +1,4 @@ +SRC_URI_append_libc-musl = " \ + file://libmetal-delete-librt-hugetlbfs.patch \ +" + -- Gitee From 5e888df2fa3a75a8dd748c1ab17189da94515796 Mon Sep 17 00:00:00 2001 From: Zhang Limin Date: Wed, 14 Sep 2022 06:56:24 +0000 Subject: [PATCH 06/35] musl: musl support config * adapts musl toolchain * modify config file Signed-off-by: zhanglimin --- .../recipes-external/musl/musl_1.2.3.bb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index 40a128765b7..9e9c29eabd6 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -20,17 +20,12 @@ INHIBIT_DEFAULT_DEPS = "1" PR = "r1" -#require ../../recipes-devtools/gcc/gcc-bin-toolchain.inc - - -SRC_URI = "file://aarch64-openeuler-linux-musl-cross" -#SRC_URI = "file://aarch64-linux-musl-cross" +SRC_URI = "file://aarch64-openeuler-linux-musl" INHIBIT_SYSROOT_STRIP = "1" INSANE_SKIP_${PN} += "already-stripped" -S = "${WORKDIR}/aarch64-openeuler-linux-musl-cross" -#S = "${WORKDIR}/aarch64-linux-musl-cross" +S = "${WORKDIR}/aarch64-openeuler-linux-musl" PSEUDO_DISABLED = "1" @@ -45,12 +40,14 @@ do_compile () { do_install() { install -m 0755 -d ${D}/ - install -m 0755 -d ${D}/lib/ - cp -pPR ${S}/aarch64-linux-musl/* ${D}/ - chmod -R 755 ${D}/lib/ + install -m 0755 -d ${D}/${base_libdir} + install -m 0755 -d ${D}/${libdir} + cp -pPR ${S}/aarch64-openeuler-linux-musl/sysroot/* ${D}/ + chmod -R 755 ${D}/${base_libdir} + chmod -R 755 ${D}/${libdir} rm -rf ${D}/etc/rpc rm -rf ${D}${datadir}/info - rm -rf ${D}/lib/debug + rm -rf ${D}${base_libdir}/debug chown root:root ${D}/ -R } -- Gitee From 14f19f3c5de5a3a25d89177e6cf4f85ddc8fcc5b Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Thu, 15 Sep 2022 02:05:34 +0000 Subject: [PATCH 07/35] musl: compile elfutils * remove unpatched patch Signed-off-by: miaoyuxia --- meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend b/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend index 9ad8e5f3ba2..cf08dd341c5 100644 --- a/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend +++ b/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend @@ -17,3 +17,8 @@ SRC_URI_remove += " \ file://0001-add-support-for-ipkg-to-debuginfod.cxx.patch \ https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \ " + + +SRC_URI_remove_libc-musl += " \ + file://0002-musl-libs.patch \ +" -- Gitee From a1569d50efb153e31bcb32edb5dd59c39763cbc3 Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Thu, 15 Sep 2022 10:33:52 +0800 Subject: [PATCH 08/35] musl: iproute * solve MAXPATHLEN undeclared Signed-off-by: miaoyuxia --- .../iproute2/iproute2/missing-include.patch | 10 ++++++++++ .../recipes-connectivity/iproute2/iproute2_%.bbappend | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 meta-openeuler/recipes-connectivity/iproute2/iproute2/missing-include.patch diff --git a/meta-openeuler/recipes-connectivity/iproute2/iproute2/missing-include.patch b/meta-openeuler/recipes-connectivity/iproute2/iproute2/missing-include.patch new file mode 100644 index 00000000000..8bc4b47e3db --- /dev/null +++ b/meta-openeuler/recipes-connectivity/iproute2/iproute2/missing-include.patch @@ -0,0 +1,10 @@ +--- iproute2-5.15.0.orig/include/namespace.h 2021-11-22 16:15:31.000000000 +0800 ++++ iproute2-5.15.0/include/namespace.h 2022-07-11 15:09:26.402839958 +0800 +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + + #ifndef NETNS_RUN_DIR + #define NETNS_RUN_DIR "/var/run/netns" diff --git a/meta-openeuler/recipes-connectivity/iproute2/iproute2_%.bbappend b/meta-openeuler/recipes-connectivity/iproute2/iproute2_%.bbappend index 00cfa205489..52e0583124c 100644 --- a/meta-openeuler/recipes-connectivity/iproute2/iproute2_%.bbappend +++ b/meta-openeuler/recipes-connectivity/iproute2/iproute2_%.bbappend @@ -7,3 +7,9 @@ SRC_URI += " \ " SRC_URI[sha256sum] = "56d7dcb05b564c94cf6e4549cec2f93f2dc58085355c08dcb2a8f8249c946080" + +# musl +FILESEXTRAPATHS_prepend := "${THISDIR}/iproute2:" +SRC_URI_append_libc-musl =" \ + file://missing-include.patch \ +" -- Gitee From 9c9ecf7924cac28eb99b4a3685ef2589cee6fe27 Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Thu, 15 Sep 2022 10:50:01 +0800 Subject: [PATCH 09/35] musl: lvm2 * solve mallinfo err Signed-off-by: miaoyuxia --- .../recipes-core/lvm2/lvm2/add_mallinfo.patch | 31 +++++++++++++++++++ .../recipes-core/lvm2/lvm2/lvmcmdline.patch | 29 +++++++++++++++++ .../recipes-core/lvm2/lvm2_%.bbappend | 5 +++ 3 files changed, 65 insertions(+) create mode 100644 meta-openeuler/recipes-core/lvm2/lvm2/add_mallinfo.patch create mode 100644 meta-openeuler/recipes-core/lvm2/lvm2/lvmcmdline.patch create mode 100644 meta-openeuler/recipes-core/lvm2/lvm2_%.bbappend diff --git a/meta-openeuler/recipes-core/lvm2/lvm2/add_mallinfo.patch b/meta-openeuler/recipes-core/lvm2/lvm2/add_mallinfo.patch new file mode 100644 index 00000000000..f6c16d34186 --- /dev/null +++ b/meta-openeuler/recipes-core/lvm2/lvm2/add_mallinfo.patch @@ -0,0 +1,31 @@ +--- LVM2.2.03.14.orig/lib/mm/memlock.c 2021-10-20 18:25:05.000000000 +0800 ++++ LVM2.2.03.14/lib/mm/memlock.c 2022-07-12 10:26:36.591427839 +0800 +@@ -158,6 +158,28 @@ + } + } + ++ ++struct mallinfo { ++ int arena; /* Non-mmapped space allocated (bytes) */ ++ int ordblks; /* Number of free chunks */ ++ int smblks; /* Number of free fastbin blocks */ ++ int hblks; /* Number of mmapped regions */ ++ int hblkhd; /* Space allocated in mmapped regions (bytes) */ ++ int usmblks; /* Maximum total allocated space (bytes) */ ++ int fsmblks; /* Space in freed fastbin blocks (bytes) */ ++ int uordblks; /* Total allocated space (bytes) */ ++ int fordblks; /* Total free space (bytes) */ ++ int keepcost; /* Top-most, releasable space (bytes) */ ++}; ++ ++struct mallinfo mallinfo(void) ++{ ++ struct mallinfo info; ++ memset(&info, 0, sizeof(info)); ++ return info; ++} ++ ++ + static void _allocate_memory(void) + { + #ifndef VALGRIND_POOL diff --git a/meta-openeuler/recipes-core/lvm2/lvm2/lvmcmdline.patch b/meta-openeuler/recipes-core/lvm2/lvm2/lvmcmdline.patch new file mode 100644 index 00000000000..0315661a5db --- /dev/null +++ b/meta-openeuler/recipes-core/lvm2/lvm2/lvmcmdline.patch @@ -0,0 +1,29 @@ +--- LVM2.2.03.14.orig/tools/lvmcmdline.c 2021-10-20 18:25:05.000000000 +0800 ++++ LVM2.2.03.14/tools/lvmcmdline.c 2022-07-12 14:53:51.202366506 +0800 +@@ -3384,7 +3384,7 @@ + int err = is_valid_fd(STDERR_FILENO); + + if (!is_valid_fd(STDIN_FILENO) && +- !(stdin = fopen(_PATH_DEVNULL, "r"))) { ++ !(fopen(_PATH_DEVNULL, "r"))) { + if (err) + perror("stdin stream open"); + else +@@ -3394,7 +3394,7 @@ + } + + if (!is_valid_fd(STDOUT_FILENO) && +- !(stdout = fopen(_PATH_DEVNULL, "w"))) { ++ !(fopen(_PATH_DEVNULL, "w"))) { + if (err) + perror("stdout stream open"); + /* else no stdout */ +@@ -3402,7 +3402,7 @@ + } + + if (!is_valid_fd(STDERR_FILENO) && +- !(stderr = fopen(_PATH_DEVNULL, "w"))) { ++ !(fopen(_PATH_DEVNULL, "w"))) { + printf("stderr stream open: %s\n", + strerror(errno)); + return 0; diff --git a/meta-openeuler/recipes-core/lvm2/lvm2_%.bbappend b/meta-openeuler/recipes-core/lvm2/lvm2_%.bbappend new file mode 100644 index 00000000000..846d761a977 --- /dev/null +++ b/meta-openeuler/recipes-core/lvm2/lvm2_%.bbappend @@ -0,0 +1,5 @@ +# for musl +SRC_URI_append_libc-musl =" \ + file://add_mallinfo.patch \ + file://lvmcmdline.patch \ +" -- Gitee From 78896aaf443b277b33b67dabb183ac17bf3db731 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Thu, 15 Sep 2022 11:57:10 +0800 Subject: [PATCH 10/35] musl: binutils * binutils adapts musl * modify config file and add patch Signed-off-by: zhangfei --- .../binutils/binutils/use-static_cast.patch | 23 +++++++++++++++++++ .../binutils/binutils_%.bbappend | 6 +++++ 2 files changed, 29 insertions(+) create mode 100644 meta-openeuler/recipes-devtools/binutils/binutils/use-static_cast.patch diff --git a/meta-openeuler/recipes-devtools/binutils/binutils/use-static_cast.patch b/meta-openeuler/recipes-devtools/binutils/binutils/use-static_cast.patch new file mode 100644 index 00000000000..883418b597d --- /dev/null +++ b/meta-openeuler/recipes-devtools/binutils/binutils/use-static_cast.patch @@ -0,0 +1,23 @@ +diff --git a/gold/gc.h b/gold/gc.h +index 6ebd81f3fd0..4a1368f5abe 100644 +--- a/gold/gc.h ++++ b/gold/gc.h +@@ -247,7 +247,7 @@ gc_process_relocs( + if (is_ordinary) + (*secvec).push_back(Section_id(src_obj, dst_indx)); + else +- (*secvec).push_back(Section_id(reinterpret_cast(NULL), 0)); ++ (*secvec).push_back(Section_id(static_cast(NULL), 0)); + // If the target of the relocation is an STT_SECTION symbol, + // make a note of that by storing -1 in the symbol vector. + if (lsym.get_st_type() == elfcpp::STT_SECTION) +@@ -329,7 +329,7 @@ gc_process_relocs( + if (is_ordinary && dst_obj != NULL) + (*secvec).push_back(Section_id(dst_obj, dst_indx)); + else +- (*secvec).push_back(Section_id(reinterpret_cast(NULL), 0)); ++ (*secvec).push_back(Section_id(static_cast(NULL), 0)); + (*symvec).push_back(gsym); + (*addendvec).push_back(std::make_pair( + static_cast(symvalue), + diff --git a/meta-openeuler/recipes-devtools/binutils/binutils_%.bbappend b/meta-openeuler/recipes-devtools/binutils/binutils_%.bbappend index 42dd3e6f17b..469e9efe6da 100644 --- a/meta-openeuler/recipes-devtools/binutils/binutils_%.bbappend +++ b/meta-openeuler/recipes-devtools/binutils/binutils_%.bbappend @@ -1 +1,7 @@ require binutils_src.inc + +# add patch to support musl +FILESEXTRAPATHS_prepend := "${THISDIR}/binutils/:" +SRC_URI_append_libc-musl = " \ + file://use-static_cast.patch \ +" -- Gitee From 7a6b9119a08d8b2b1619464b4633951dcb8d500a Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Thu, 15 Sep 2022 13:38:41 +0800 Subject: [PATCH 11/35] musl: lxc * lxc for musl Signed-off-by: miaoyuxia --- .../recipes-core/lxc/lxc/lxc-for-musl.patch | 151 ++++++++++++++++++ .../recipes-core/lxc/lxc_%.bbappend | 8 + 2 files changed, 159 insertions(+) create mode 100644 meta-openeuler/recipes-core/lxc/lxc/lxc-for-musl.patch create mode 100644 meta-openeuler/recipes-core/lxc/lxc_%.bbappend diff --git a/meta-openeuler/recipes-core/lxc/lxc/lxc-for-musl.patch b/meta-openeuler/recipes-core/lxc/lxc/lxc-for-musl.patch new file mode 100644 index 00000000000..09b0a71e280 --- /dev/null +++ b/meta-openeuler/recipes-core/lxc/lxc/lxc-for-musl.patch @@ -0,0 +1,151 @@ +diff -urN lxc-4.0.3.orig/src/lxc/json/defs.c lxc-4.0.3/src/lxc/json/defs.c +--- lxc-4.0.3.orig/src/lxc/json/defs.c 2022-09-07 17:05:55.714508559 +0800 ++++ lxc-4.0.3/src/lxc/json/defs.c 2022-09-07 17:05:55.711508533 +0800 +@@ -83,8 +83,8 @@ + strcmp(tree->u.object.keys[i], "args") && + strcmp(tree->u.object.keys[i], "env") && + strcmp(tree->u.object.keys[i], "timeout")) { +- if (ctx->stderr > 0) +- fprintf(ctx->stderr, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); ++ if (ctx->stderr1 > 0) ++ fprintf(ctx->stderr1, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); + } + } + return ret; +diff -urN lxc-4.0.3.orig/src/lxc/json/json_common.h lxc-4.0.3/src/lxc/json/json_common.h +--- lxc-4.0.3.orig/src/lxc/json/json_common.h 2022-09-07 17:05:55.714508559 +0800 ++++ lxc-4.0.3/src/lxc/json/json_common.h 2022-09-07 17:05:55.711508533 +0800 +@@ -39,7 +39,7 @@ + + struct parser_context { + unsigned int options; +- FILE *stderr; ++ FILE *stderr1; + }; + + yajl_gen_status reformat_number(void *ctx, const char *str, size_t len); +@@ -182,4 +182,4 @@ + } + #endif + +-#endif +\ No newline at end of file ++#endif +diff -urN lxc-4.0.3.orig/src/lxc/json/logger_json_file.c lxc-4.0.3/src/lxc/json/logger_json_file.c +--- lxc-4.0.3.orig/src/lxc/json/logger_json_file.c 2022-09-07 17:05:55.714508559 +0800 ++++ lxc-4.0.3/src/lxc/json/logger_json_file.c 2022-09-07 17:05:55.711508533 +0800 +@@ -50,8 +50,8 @@ + strcmp(tree->u.object.keys[i], "stream") && + strcmp(tree->u.object.keys[i], "time") && + strcmp(tree->u.object.keys[i], "attrs")) { +- if (ctx->stderr > 0) +- fprintf(ctx->stderr, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); ++ if (ctx->stderr1 > 0) ++ fprintf(ctx->stderr1, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); + } + } + return ret; +diff -urN lxc-4.0.3.orig/src/lxc/json/oci_runtime_spec.c lxc-4.0.3/src/lxc/json/oci_runtime_spec.c +--- lxc-4.0.3.orig/src/lxc/json/oci_runtime_spec.c 2022-09-07 17:05:55.714508559 +0800 ++++ lxc-4.0.3/src/lxc/json/oci_runtime_spec.c 2022-09-07 17:05:55.711508533 +0800 +@@ -67,8 +67,8 @@ + if (strcmp(tree->u.object.keys[i], "prestart") && + strcmp(tree->u.object.keys[i], "poststart") && + strcmp(tree->u.object.keys[i], "poststop")) { +- if (ctx->stderr > 0) +- fprintf(ctx->stderr, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); ++ if (ctx->stderr1 > 0) ++ fprintf(ctx->stderr1, "WARNING: unknown key found: %s\n", tree->u.object.keys[i]); + } + } + return ret; +diff -urN lxc-4.0.3.orig/src/lxc/utils.c lxc-4.0.3/src/lxc/utils.c +--- lxc-4.0.3.orig/src/lxc/utils.c 2022-09-07 17:05:55.715508568 +0800 ++++ lxc-4.0.3/src/lxc/utils.c 2022-09-08 14:33:40.632305172 +0800 +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + + #include "config.h" + #include "log.h" +@@ -2210,6 +2211,78 @@ + return startat; + } + ++static pthread_mutex_t pwent_mutex = PTHREAD_MUTEX_INITIALIZER; ++static int __fgetpwent_r(FILE *stream, struct passwd *pwd, char *buf, ++ size_t len, struct passwd **result) ++{ ++ struct passwd *pwtmp; ++ char *cursor = buf, *end = buf + len; ++ ++ *result = NULL; ++ pthread_mutex_lock(&pwent_mutex); ++ pwtmp = stream != NULL ? fgetpwent(stream) : getpwent(); ++ if (pwtmp == NULL) { ++ pthread_mutex_unlock(&pwent_mutex); ++ return ENOENT; ++ } ++ memcpy(pwd, pwtmp, sizeof(*pwd)); ++ if (pwtmp->pw_name != NULL) { ++ pwd->pw_name = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_name, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_passwd != NULL) { ++ pwd->pw_passwd = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_passwd, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_gecos != NULL) { ++ pwd->pw_gecos = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_gecos, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_dir != NULL) { ++ pwd->pw_dir = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_dir, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_shell != NULL) { ++ pwd->pw_shell = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_shell, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ pthread_mutex_unlock(&pwent_mutex); ++ *result = pwd; ++ ++ return 0; ++err_unlock: ++ pthread_mutex_unlock(&pwent_mutex); ++ return ERANGE; ++} ++ ++ ++int fgetpwent_r(FILE *stream, struct passwd *pwd, char *buf, size_t len, ++ struct passwd **result) ++{ ++ assert(stream != NULL); ++ ++ return __fgetpwent_r(stream, pwd, buf, len, result); ++} ++ ++ ++ ++ ++ + // isulad: set env home in container + int lxc_setup_env_home(uid_t uid) + { diff --git a/meta-openeuler/recipes-core/lxc/lxc_%.bbappend b/meta-openeuler/recipes-core/lxc/lxc_%.bbappend new file mode 100644 index 00000000000..3bac8351882 --- /dev/null +++ b/meta-openeuler/recipes-core/lxc/lxc_%.bbappend @@ -0,0 +1,8 @@ +SRC_URI_append_libc-musl = " \ + file://lxc-for-musl.patch \ +" +CFLAGS_append_libc-musl = " -Wno-error=stringop-overread -Wno-error=address -Wno-error=array-bounds -Wno-array-bounds " +do_compile_prepend_libc-musl() { + sed -i "s/init_lxc_static_LDFLAGS = -all-static -pthread/init_lxc_static_LDFLAGS = -pthread/" ${S}/src/lxc/Makefile.am +} + -- Gitee From cd428a1202597fd3581476a653663efc8246599b Mon Sep 17 00:00:00 2001 From: zhangfei Date: Thu, 15 Sep 2022 14:08:25 +0800 Subject: [PATCH 12/35] musl: lcr * modify bb file and add patch Signed-off-by: zhangfei --- .../recipes-core/lcr/lcr/lcr-for-musl.patch | 91 +++++++++++++++++++ .../recipes-core/lcr/lcr_%.bbappend | 4 + 2 files changed, 95 insertions(+) create mode 100644 meta-openeuler/recipes-core/lcr/lcr/lcr-for-musl.patch create mode 100644 meta-openeuler/recipes-core/lcr/lcr_%.bbappend diff --git a/meta-openeuler/recipes-core/lcr/lcr/lcr-for-musl.patch b/meta-openeuler/recipes-core/lcr/lcr/lcr-for-musl.patch new file mode 100644 index 00000000000..d0591be68c2 --- /dev/null +++ b/meta-openeuler/recipes-core/lcr/lcr/lcr-for-musl.patch @@ -0,0 +1,91 @@ +--- lcr-v2.0.7.orig/src/json/schema/container/attach-request.json 2022-07-27 11:10:10.478884003 +0800 ++++ lcr-v2.0.7/src/json/schema/container/attach-request.json 2022-07-27 14:46:21.943112460 +0800 +@@ -14,13 +14,13 @@ + "attach_stderr": { + "type": "boolean" + }, +- "stdin": { ++ "stdin1": { + "type": "string" + }, +- "stdout": { ++ "stdout1": { + "type": "string" + }, +- "stderr": { ++ "stderr1": { + "type": "string" + } + } + +--- lcr-v2.0.7.orig/third_party/libocispec/common_h.py 2022-07-27 11:10:10.474883971 +0800 ++++ lcr-v2.0.7/third_party/libocispec/common_h.py 2022-07-27 11:10:34.027071821 +0800 +@@ -84,7 +84,7 @@ + + struct parser_context { + unsigned int options; +- FILE *stderr; ++ FILE *stderr1; + }; + + yajl_gen_status gen_yajl_object_residual (yajl_val obj, yajl_gen g, parser_error *err); + +--- lcr-v2.0.7.orig/src/json/schema/container/exec-request.json 2022-07-27 11:10:10.478884003 +0800 ++++ lcr-v2.0.7/src/json/schema/container/exec-request.json 2022-07-27 14:55:18.501364215 +0800 +@@ -20,13 +20,13 @@ + "attach_stderr": { + "type": "boolean" + }, +- "stdin": { ++ "stdin1": { + "type": "string" + }, +- "stdout": { ++ "stdout1": { + "type": "string" + }, +- "stderr": { ++ "stderr1": { + "type": "string" + }, + "argv": { + +--- lcr-v2.0.7.orig/third_party/libocispec/sources.py 2022-07-27 11:10:10.474883971 +0800 ++++ lcr-v2.0.7/third_party/libocispec/sources.py 2022-07-27 11:11:42.696619530 +0800 +@@ -272,8 +272,8 @@ + } + if (ctx->options & OPT_PARSE_STRICT) + { +- if (j > 0 && ctx->stderr > 0) +- fprintf (ctx->stderr, "WARNING: unknown key found\\n"); ++ if (j > 0 && ctx->stderr1 > 0) ++ fprintf (ctx->stderr1, "WARNING: unknown key found\\n"); + } + if (ctx->options & OPT_PARSE_FULLKEY) + ret->_residual = resi; + +--- lcr-v2.0.7.orig/src/json/schema/container/start-request.json 2022-07-27 11:10:10.477883995 +0800 ++++ lcr-v2.0.7/src/json/schema/container/start-request.json 2022-07-27 14:56:51.082097502 +0800 +@@ -5,19 +5,19 @@ + "id": { + "type": "string" + }, +- "stdin": { ++ "stdin1": { + "type": "string" + }, + "attach-stdin": { + "type": "boolean" + }, +- "stdout": { ++ "stdout1": { + "type": "string" + }, + "attach-stdout": { + "type": "boolean" + }, +- "stderr": { ++ "stderr1": { + "type": "string" + }, + "attach-stderr": { diff --git a/meta-openeuler/recipes-core/lcr/lcr_%.bbappend b/meta-openeuler/recipes-core/lcr/lcr_%.bbappend new file mode 100644 index 00000000000..36163628199 --- /dev/null +++ b/meta-openeuler/recipes-core/lcr/lcr_%.bbappend @@ -0,0 +1,4 @@ +# add patch to support musl +SRC_URI_append_libc-musl = " \ + file://lcr-for-musl.patch \ +" -- Gitee From 648cc310d7309701f09897d8032cdd3ddf1b5a89 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 16 Sep 2022 09:48:02 +0800 Subject: [PATCH 13/35] musl: libhugetlbfs * modify libhugetlbfs bb file and add patch * modify bsd-headers bb file and add patch Signed-off-by: zhangfei --- .../libhugetlbfs/libhugetlbfs-musl.patch | 42 +++++++++++++++++++ .../libhugetlbfs/libhugetlbfs_%.bbappend | 4 ++ .../musl/bsd-headers.bbappend | 5 +++ .../musl/bsd-headers/sys-cdefs-musl.patch | 17 ++++++++ 4 files changed, 68 insertions(+) create mode 100644 meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs/libhugetlbfs-musl.patch create mode 100644 meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs_%.bbappend create mode 100644 meta-openeuler/recipes-external/musl/bsd-headers.bbappend create mode 100644 meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch diff --git a/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs/libhugetlbfs-musl.patch b/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs/libhugetlbfs-musl.patch new file mode 100644 index 00000000000..4509100b8ea --- /dev/null +++ b/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs/libhugetlbfs-musl.patch @@ -0,0 +1,42 @@ +--- libhugetlbfs-2.23/alloc.c 2022-09-15 22:23:48.589851908 +0800 ++++ libhugetlbfs-2.23/alloc.c 2022-09-15 22:23:11.770557710 +0800 +@@ -245,6 +245,7 @@ void free_huge_pages(void *ptr) + __free_huge_pages(ptr, 1); + } + ++#define _SC_LEVEL2_CACHE_LINESIZE 1150 + /* + * Offset the buffer using bytes wasted due to alignment to avoid using the + * same cache lines for the start of every buffer returned by + +--- libhugetlbfs-2.23/shm.c 2022-09-15 22:36:51.513384959 +0800 ++++ libhugetlbfs-2.23/shm.c 2022-09-15 22:37:35.385733745 +0800 +@@ -29,6 +29,7 @@ + #include "libhugetlbfs_internal.h" + #include "hugetlbfs.h" + #include ++#include + + #if defined(SYS_shmget) || defined(SYS_ipc) + #define HAVE_SHMGET_SYSCALL + +--- libhugetlbfs-2.23/tests/hugetests.h 2022-09-15 22:49:23.818330241 +0800 ++++ libhugetlbfs-2.23/tests/hugetests.h 2022-09-15 22:51:06.993110645 +0800 +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + #include "libhugetlbfs_privutils.h" + #include "libhugetlbfs_testprobes.h" + +--- libhugetlbfs-2.23/tests/gethugepagesizes.c 2022-09-15 22:55:18.499012983 +0800 ++++ libhugetlbfs-2.23/tests/gethugepagesizes.c 2022-09-15 22:57:51.207168038 +0800 +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + + #include "hugetests.h" diff --git a/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs_%.bbappend b/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs_%.bbappend new file mode 100644 index 00000000000..6f82cb38e58 --- /dev/null +++ b/meta-openeuler/recipes-core/libhugetlbfs/libhugetlbfs_%.bbappend @@ -0,0 +1,4 @@ +# add patch to support musl +SRC_URI_append_libc-musl = " \ + file://libhugetlbfs-musl.patch \ +" diff --git a/meta-openeuler/recipes-external/musl/bsd-headers.bbappend b/meta-openeuler/recipes-external/musl/bsd-headers.bbappend new file mode 100644 index 00000000000..e9200c545a9 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/bsd-headers.bbappend @@ -0,0 +1,5 @@ +# add patch to support musl +FILESEXTRAPATHS_prepend := "${THISDIR}/bsd-headers/:" +SRC_URI_append_libc-musl = " \ + file://sys-cdefs-musl.patch \ +" diff --git a/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch b/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch new file mode 100644 index 00000000000..61226edf455 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch @@ -0,0 +1,17 @@ +--- a/sys-cdefs.h 2022-09-15 17:08:35.541665900 +0800 ++++ b/sys-cdefs.h 2022-09-15 17:40:15.841270095 +0800 +@@ -1,4 +1,3 @@ +-#warning usage of non-standard #include is deprecated + + #undef __P + #undef __PMT +@@ -24,3 +23,9 @@ + # define __THROW + # define __NTH(fct) fct + #endif ++ ++#if defined(__GNUC__) && !defined(__cplusplus) ++# define __nonnull(params) __attribute__ ((__nonnull__ params)) ++#else ++# define __nonnull(params) ++#endif -- Gitee From 35ba463638f20f83dc2da4cfadad7b16703d1304 Mon Sep 17 00:00:00 2001 From: Miao Yuxia Date: Fri, 16 Sep 2022 02:56:57 +0000 Subject: [PATCH 14/35] musl: selinux * add fts header Signed-off-by: miaoyuxia --- .../recipes-core/selinux/libselinux_%.bbappend | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 meta-openeuler/recipes-core/selinux/libselinux_%.bbappend diff --git a/meta-openeuler/recipes-core/selinux/libselinux_%.bbappend b/meta-openeuler/recipes-core/selinux/libselinux_%.bbappend new file mode 100644 index 00000000000..ab3bd710700 --- /dev/null +++ b/meta-openeuler/recipes-core/selinux/libselinux_%.bbappend @@ -0,0 +1,9 @@ +PV = "3.3" + +DEPENDS += "${@bb.utils.contains('LIBC', 'musl', 'fts', '', d)}" + +do_configure_prepend_libc-musl () { + if ! grep -q "-lfts" ${S}/src/Makefile ; then sed -i 's/FTS_LDLIBS ?=/FTS_LDLIBS ?= -lfts/' ${S}/src/Makefile; fi + sed -i '/.*FTS_LDLIBS*/c\override LDLIBS += -lselinux -lfts' ${S}/utils/Makefile + sed -i 's/malloc_trim/malloc/g' ${S}/src/load_policy.c +} -- Gitee From a4b5ea2ee8bb2bbd596e2e912c0fb6c27c33ad96 Mon Sep 17 00:00:00 2001 From: Zhang Limin Date: Fri, 16 Sep 2022 03:10:03 +0000 Subject: [PATCH 15/35] musl: pseudo * pseudo for musl * modify config file add add patch Signed-off-by: zhanglimin --- .../pseudo/pseudo/pseudo0916.patch | 133 ++++++++++++++++++ .../recipes-devtools/pseudo/pseudo_%.bbappend | 9 ++ 2 files changed, 142 insertions(+) create mode 100644 meta-openeuler/recipes-devtools/pseudo/pseudo/pseudo0916.patch diff --git a/meta-openeuler/recipes-devtools/pseudo/pseudo/pseudo0916.patch b/meta-openeuler/recipes-devtools/pseudo/pseudo/pseudo0916.patch new file mode 100644 index 00000000000..9d9c078e39a --- /dev/null +++ b/meta-openeuler/recipes-devtools/pseudo/pseudo/pseudo0916.patch @@ -0,0 +1,133 @@ +diff -Nur pseudo-df1d1321fb093283485c387e3c933d2d264e509c/ports/linux/nostatx/portdefs.h pseudo-build/ports/linux/nostatx/portdefs.h +--- pseudo-df1d1321fb093283485c387e3c933d2d264e509c/ports/linux/nostatx/portdefs.h 2022-03-22 07:03:50.000000000 +0800 ++++ pseudo-build/ports/linux/nostatx/portdefs.h 2022-09-16 09:38:09.601383147 +0800 +@@ -7,32 +7,32 @@ + + struct statx_timestamp + { +- __int64_t tv_sec; +- __uint32_t tv_nsec; +- __int32_t __statx_timestamp_pad1[1]; ++ int64_t tv_sec; ++ uint32_t tv_nsec; ++ int32_t __statx_timestamp_pad1[1]; + }; + + struct statx + { +- __uint32_t stx_mask; +- __uint32_t stx_blksize; +- __uint64_t stx_attributes; +- __uint32_t stx_nlink; +- __uint32_t stx_uid; +- __uint32_t stx_gid; +- __uint16_t stx_mode; +- __uint16_t __statx_pad1[1]; +- __uint64_t stx_ino; +- __uint64_t stx_size; +- __uint64_t stx_blocks; +- __uint64_t stx_attributes_mask; ++ uint32_t stx_mask; ++ uint32_t stx_blksize; ++ uint64_t stx_attributes; ++ uint32_t stx_nlink; ++ uint32_t stx_uid; ++ uint32_t stx_gid; ++ uint16_t stx_mode; ++ uint16_t __statx_pad1[1]; ++ uint64_t stx_ino; ++ uint64_t stx_size; ++ uint64_t stx_blocks; ++ uint64_t stx_attributes_mask; + struct statx_timestamp stx_atime; + struct statx_timestamp stx_btime; + struct statx_timestamp stx_ctime; + struct statx_timestamp stx_mtime; +- __uint32_t stx_rdev_major; +- __uint32_t stx_rdev_minor; +- __uint32_t stx_dev_major; +- __uint32_t stx_dev_minor; +- __uint64_t __statx_pad2[14]; ++ uint32_t stx_rdev_major; ++ uint32_t stx_rdev_minor; ++ uint32_t stx_dev_major; ++ uint32_t stx_dev_minor; ++ uint64_t __statx_pad2[14]; + }; +diff -Nur pseudo-df1d1321fb093283485c387e3c933d2d264e509c/ports/linux/wrapfuncs.in pseudo-build/ports/linux/wrapfuncs.in +--- pseudo-df1d1321fb093283485c387e3c933d2d264e509c/ports/linux/wrapfuncs.in 2022-03-22 07:03:50.000000000 +0800 ++++ pseudo-build/ports/linux/wrapfuncs.in 2022-09-16 09:38:09.601383147 +0800 +@@ -1,4 +1,3 @@ +-int open(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ + char *get_current_dir_name(void); + int __xstat(int ver, const char *path, struct stat *buf); + int __lxstat(int ver, const char *path, struct stat *buf); /* flags=AT_SYMLINK_NOFOLLOW */ +@@ -6,7 +5,6 @@ + int lchmod(const char *path, mode_t mode); /* flags=AT_SYMLINK_NOFOLLOW */ + int lchown(const char *path, uid_t owner, gid_t group); /* flags=AT_SYMLINK_NOFOLLOW */ + int __fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags); +-int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ + int __openat_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ + int mknod(const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknod */ + int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknodat */ +@@ -20,28 +18,15 @@ + int open64(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ + int openat64(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ + int __openat64_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW, noignore_path=1 */ +-int creat64(const char *path, mode_t mode); +-int stat(const char *path, struct stat *buf); /* real_func=pseudo_stat */ +-int lstat(const char *path, struct stat *buf); /* real_func=pseudo_lstat, flags=AT_SYMLINK_NOFOLLOW */ + int fstat(int fd, struct stat *buf); /* real_func=pseudo_fstat */ + int fstatat(int dirfd, const char *path, struct stat *buf, int flags); + int stat64(const char *path, struct stat64 *buf); /* real_func=pseudo_stat64 */ + int lstat64(const char *path, struct stat64 *buf); /* real_func=pseudo_lstat64, flags=AT_SYMLINK_NOFOLLOW */ +-int fstat64(int fd, struct stat64 *buf); /* real_func=pseudo_fstat64 */ +-int fstatat64(int dirfd, const char *path, struct stat64 *buf, int flags); + int __xstat64(int ver, const char *path, struct stat64 *buf); + int __lxstat64(int ver, const char *path, struct stat64 *buf); /* flags=AT_SYMLINK_NOFOLLOW */ + int __fxstat64(int ver, int fd, struct stat64 *buf); + int __fxstatat64(int ver, int dirfd, const char *path, struct stat64 *buf, int flags); +-FILE *fopen64(const char *path, const char *mode); /* noignore_path=1 */ +-int nftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int, struct FTW *), int nopenfd, int flag); /* noignore_path=1 */ +-FILE *freopen64(const char *path, const char *mode, FILE *stream); /* noignore_path=1 */ +-int ftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int), int nopenfd); +-int glob64(const char *pattern, int flags, int (*errfunc)(const char *, int), glob64_t *pglob); + int scandir64(const char *path, struct dirent64 ***namelist, int (*filter)(const struct dirent64 *), int (*compar)()); +-int truncate64(const char *path, off64_t length); +-int mkostemp64(char *template, int oflags); /* flags=AT_SYMLINK_NOFOLLOW */ +-int mkstemp64(char *template); /* flags=AT_SYMLINK_NOFOLLOW */ + int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups); + int setgroups(size_t size, const gid_t *list); + int setfsgid(gid_t fsgid); +@@ -50,7 +35,6 @@ + int setresuid(uid_t ruid, uid_t euid, uid_t suid); + int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); + int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); +-int scandir(const char *path, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)()); + int getgroups(int size, gid_t *list); + int lckpwdf(void); + int ulckpwdf(void); +diff -Nur pseudo-df1d1321fb093283485c387e3c933d2d264e509c/pseudolog.c pseudo-build/pseudolog.c +--- pseudo-df1d1321fb093283485c387e3c933d2d264e509c/pseudolog.c 2022-03-22 07:03:50.000000000 +0800 ++++ pseudo-build/pseudolog.c 2022-09-16 09:38:09.602383155 +0800 +@@ -9,7 +9,7 @@ + /* We need _XOPEN_SOURCE for strptime(), but if we define that, + * we then don't get S_IFSOCK... _GNU_SOURCE turns on everything. */ + #define _GNU_SOURCE +- ++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */ + #include + #include + #include +diff -Nur pseudo-df1d1321fb093283485c387e3c933d2d264e509c/pseudo_util.c pseudo-build/pseudo_util.c +--- pseudo-df1d1321fb093283485c387e3c933d2d264e509c/pseudo_util.c 2022-03-22 07:03:50.000000000 +0800 ++++ pseudo-build/pseudo_util.c 2022-09-16 09:38:09.602383155 +0800 +@@ -8,7 +8,7 @@ + */ + /* we need access to RTLD_NEXT for a horrible workaround */ + #define _GNU_SOURCE +- ++#define __restrict_arr restrict + #include + #include + #include diff --git a/meta-openeuler/recipes-devtools/pseudo/pseudo_%.bbappend b/meta-openeuler/recipes-devtools/pseudo/pseudo_%.bbappend index 6eb6a3e53a8..a33d5881401 100644 --- a/meta-openeuler/recipes-devtools/pseudo/pseudo_%.bbappend +++ b/meta-openeuler/recipes-devtools/pseudo/pseudo_%.bbappend @@ -2,6 +2,8 @@ # but we can use native sdk to build pseudo-native to remove the dependency of sqlite-native and attr-native DEPENDS_remove_class-native += "sqlite3-native attr-native" +DEPENDS_append_libc-musl = " fts " + OPENEULER_REPO_NAME = "yocto-pseudo" SRC_URI_remove_class-native = " \ @@ -11,6 +13,11 @@ SRC_URI_remove_class-native = " \ SRC_URI_prepend_class-native = "file://${BP}.tar.gz \ " +FILESEXTRAPATHS_prepend := "${THISDIR}/pseudo:" +SRC_URI_append_libc-musl = " \ + file://pseudo0916.patch \ +" + PV_class-native = "df1d1321fb093283485c387e3c933d2d264e509c" S_class-native = "${WORKDIR}/${BP}" @@ -28,3 +35,5 @@ do_compile_class-native () { fi oe_runmake ${MAKEOPTS} } + +COMPATIBLE_HOST_libc-musl = '.*-musl.*' -- Gitee From 7dbf5663ddf8fd23e5cd86242685a0c0cc3193f6 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Mon, 26 Sep 2022 13:33:43 +0800 Subject: [PATCH 16/35] musl: dsoftbus * modify dsoftbus bb file and add patch Signed-off-by: zhangfei --- .../dsoftbus/dsoftbus/change-musl-toolchain.patch | 12 ++++++++++++ .../dsoftbus/dsoftbus/dsoftbus-musl.patch | 10 ++++++++++ .../recipes-core/dsoftbus/dsoftbus_%.bbappend | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 meta-openeuler/recipes-core/dsoftbus/dsoftbus/change-musl-toolchain.patch create mode 100644 meta-openeuler/recipes-core/dsoftbus/dsoftbus/dsoftbus-musl.patch create mode 100644 meta-openeuler/recipes-core/dsoftbus/dsoftbus_%.bbappend diff --git a/meta-openeuler/recipes-core/dsoftbus/dsoftbus/change-musl-toolchain.patch b/meta-openeuler/recipes-core/dsoftbus/dsoftbus/change-musl-toolchain.patch new file mode 100644 index 00000000000..d1fce2ee9ae --- /dev/null +++ b/meta-openeuler/recipes-core/dsoftbus/dsoftbus/change-musl-toolchain.patch @@ -0,0 +1,12 @@ +diff -uprN a/toolchain/linux/BUILD.gn b/toolchain/linux/BUILD.gn +--- a/toolchain/linux/BUILD.gn 2022-09-14 16:44:09.577085155 +0800 ++++ b/toolchain/linux/BUILD.gn 2022-09-14 16:47:56.430068282 +0800 +@@ -23,7 +23,7 @@ clang_toolchain("clang_arm64") { + + gcc_toolchain("arm64") { + tool_path = rebase_path("//toolchain/bin", root_build_dir) +- toolprefix = "${tool_path}/aarch64-openeuler-linux-gnu-" ++ toolprefix = "${tool_path}/aarch64-openeuler-linux-musl-" + + cc = "${toolprefix}gcc" + cxx = "${toolprefix}g++" diff --git a/meta-openeuler/recipes-core/dsoftbus/dsoftbus/dsoftbus-musl.patch b/meta-openeuler/recipes-core/dsoftbus/dsoftbus/dsoftbus-musl.patch new file mode 100644 index 00000000000..f9da29ee606 --- /dev/null +++ b/meta-openeuler/recipes-core/dsoftbus/dsoftbus/dsoftbus-musl.patch @@ -0,0 +1,10 @@ +--- dsoftbus_standard/sdk/transmission/session/cpp/src/session_service_impl.cpp 2022-09-21 13:09:22.233828647 +0800 ++++ dsoftbus_standard/sdk/transmission/session/cpp/src/session_service_impl.cpp 2022-09-21 13:19:47.388403539 +0800 +@@ -21,6 +21,7 @@ + #include "softbus_def.h" + #include "softbus_errcode.h" + #include "softbus_log.h" ++#include + + namespace Communication { + namespace SoftBus { diff --git a/meta-openeuler/recipes-core/dsoftbus/dsoftbus_%.bbappend b/meta-openeuler/recipes-core/dsoftbus/dsoftbus_%.bbappend new file mode 100644 index 00000000000..a17264d53ea --- /dev/null +++ b/meta-openeuler/recipes-core/dsoftbus/dsoftbus_%.bbappend @@ -0,0 +1,5 @@ +# add patch to support musl +SRC_URI_append_libc-musl = " \ + file://change-musl-toolchain.patch;patchdir=${S}/build \ + file://dsoftbus-musl.patch;patchdir=${WORKDIR}/dsoftbus_standard \ +" -- Gitee From 5308ef8878ac34fcd9138fb227eede9bd4b03839 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Mon, 26 Sep 2022 13:50:45 +0800 Subject: [PATCH 17/35] musl: libgpg-error * modify libgpg-error bb file and add patch Signed-off-by: zhangfei --- .../files/libgpg-error-musl.patch | 29 +++++++++++++++++++ .../libgpg-error/libgpg-error_%.bbappend | 5 ++++ 2 files changed, 34 insertions(+) create mode 100644 meta-openeuler/recipes-support/libgpg-error/files/libgpg-error-musl.patch diff --git a/meta-openeuler/recipes-support/libgpg-error/files/libgpg-error-musl.patch b/meta-openeuler/recipes-support/libgpg-error/files/libgpg-error-musl.patch new file mode 100644 index 00000000000..1d5e0591f34 --- /dev/null +++ b/meta-openeuler/recipes-support/libgpg-error/files/libgpg-error-musl.patch @@ -0,0 +1,29 @@ +--- a/src/syscfg/lock-obj-pub.linux-musl.h 1970-01-01 08:00:00.000000000 +0800 ++++ b/src/syscfg/lock-obj-pub.linux-musl.h 2022-09-22 10:45:41.214400997 +0800 +@@ -0,0 +1,26 @@ ++## lock-obj-pub.linux-musl.h ++## File created by gen-posix-lock-obj - DO NOT EDIT ++## To be included by mkheader into gpg-error.h ++ ++typedef struct ++{ ++ long _vers; ++ union { ++ volatile char _priv[48]; ++ long _x_align; ++ long *_xp_align; ++ } u; ++} gpgrt_lock_t; ++ ++#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0}}} ++## ++## Local Variables: ++## mode: c ++## buffer-read-only: t ++## End: ++## diff --git a/meta-openeuler/recipes-support/libgpg-error/libgpg-error_%.bbappend b/meta-openeuler/recipes-support/libgpg-error/libgpg-error_%.bbappend index e033eca08e0..911a9de5c61 100644 --- a/meta-openeuler/recipes-support/libgpg-error/libgpg-error_%.bbappend +++ b/meta-openeuler/recipes-support/libgpg-error/libgpg-error_%.bbappend @@ -18,3 +18,8 @@ FILESEXTRAPATHS_append := "${THISDIR}/files/:" # checksum changed SRC_URI[sha256sum] = "a260706dbab849b85f6eabe418f6dc58e22bddf4b9d7fccb681907e43408d0c9" + +# add patch to support musl +SRC_URI_append_libc-musl += " \ + file://libgpg-error-musl.patch \ +" -- Gitee From 341da5f4fa0abee2ff8613ac7cdab892e99e10ac Mon Sep 17 00:00:00 2001 From: zhangfei Date: Wed, 28 Sep 2022 14:18:40 +0800 Subject: [PATCH 18/35] musl: systemd * modify systemd bb file and add patch Signed-off-by: zhangfei --- ...use-glibc-specific-qsort_r-openeuler.patch | 165 +++++ ...are_fn_t-and-comparison_fn_openeuler.patch | 78 +++ ...intf_format-implementation-openeuler.patch | 434 +++++++++++++ ...check-for-missing-strndupa-openeuler.patch | 590 ++++++++++++++++++ ...Include-netinet-if_ether.h-openeuler.patch | 328 ++++++++++ ...NOFOLLOW-flag-to-faccessat-openeuler.patch | 100 +++ ...strerror_r-from-GNU-specif-openeuler.patch | 62 ++ ...le-buffer-in-writing-files-openeuler.patch | 376 +++++++++++ ...026-Handle-missing-gshadow-openeuler.patch | 174 ++++++ ...-MIPS-ABI-defines-for-musl-openeuler.patch | 36 ++ .../systemd/files/systemd-musl.patch | 44 ++ .../recipes-core/systemd/systemd_%.bbappend | 29 + 12 files changed, 2416 insertions(+) create mode 100644 meta-openeuler/recipes-core/systemd/files/0002-don-t-use-glibc-specific-qsort_r-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0004-add-fallback-parse_printf_format-implementation-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0005-src-basic-missing.h-check-for-missing-strndupa-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0006-Include-netinet-if_ether.h-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0022-do-not-disable-buffer-in-writing-files-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0026-Handle-missing-gshadow-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl-openeuler.patch create mode 100644 meta-openeuler/recipes-core/systemd/files/systemd-musl.patch diff --git a/meta-openeuler/recipes-core/systemd/files/0002-don-t-use-glibc-specific-qsort_r-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0002-don-t-use-glibc-specific-qsort_r-openeuler.patch new file mode 100644 index 00000000000..0b0653e444a --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0002-don-t-use-glibc-specific-qsort_r-openeuler.patch @@ -0,0 +1,165 @@ +From 66ece0b870b3a34fdabc48b88437e6cc354e9fce Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 13:41:41 +0800 +Subject: [PATCH 02/26] don't use glibc-specific qsort_r + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +[Rebased for v241] +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +[Rebased for v247] +Signed-off-by: Luca Boccassi +--- + src/basic/sort-util.h | 14 ------------ + src/shared/hwdb-util.c | 19 +++++++++++----- + src/shared/format-table.c | 36 ++++++++++++++++++++---------- + 3 files changed, 38 insertions(+), 31 deletions(-) + +diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h +index 1d194a1f04..3394c9eb72 100644 +--- a/src/basic/sort-util.h ++++ b/src/basic/sort-util.h +@@ -55,18 +55,4 @@ static inline void _qsort_safe(void *bas + _qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ + }) + +-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) { +- if (nmemb <= 1) +- return; +- +- assert(base); +- qsort_r(base, nmemb, size, compar, userdata); +-} +- +-#define typesafe_qsort_r(p, n, func, userdata) \ +- ({ \ +- int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \ +- qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \ +- }) +- + int cmp_int(const int *a, const int *b); +diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c +index 4c94ba9c88..95495dba6d 100644 +--- a/src/shared/hwdb-util.c ++++ b/src/shared/hwdb-util.c +@@ -126,9 +126,13 @@ static void trie_free(struct trie *trie) { + + DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); + +-static int trie_values_cmp(const struct trie_value_entry *a, const struct trie_value_entry *b, struct trie *trie) { +- return strcmp(trie->strings->buf + a->key_off, +- trie->strings->buf + b->key_off); ++static struct trie *trie_node_add_value_trie; ++static int trie_values_cmp(const void *v1, const void *v2) { ++ const struct trie_value_entry *a = v1; ++ const struct trie_value_entry *b = v2; ++ ++ return strcmp(trie_node_add_value_trie->strings->buf + a->key_off, ++ trie_node_add_value_trie->strings->buf + b->key_off); + } + + static int trie_node_add_value(struct trie *trie, struct trie_node *node, +@@ -156,7 +160,10 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, + .value_off = v, + }; + +- val = typesafe_bsearch_r(&search, node->values, node->values_count, trie_values_cmp, trie); ++ trie_node_add_value_trie = trie; ++ val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); ++ trie_node_add_value_trie = NULL; ++ + if (val) { + /* At this point we have 2 identical properties on the same match-string. + * Since we process files in order, we just replace the previous value. */ +@@ -182,7 +189,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, + .line_number = line_number, + }; + node->values_count++; +- typesafe_qsort_r(node->values, node->values_count, trie_values_cmp, trie); ++ trie_node_add_value_trie = trie; ++ qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); ++ trie_node_add_value_trie = NULL; + return 0; + } + +diff --git a/src/shared/format-table.c b/src/shared/format-table.c +index a13a198b7a..bce10bc607 100644 +--- a/src/shared/format-table.c ++++ b/src/shared/format-table.c +@@ -1243,30 +1243,32 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t + return CMP(index_a, index_b); + } + +-static int table_data_compare(const size_t *a, const size_t *b, Table *t) { ++static Table *user_table; ++static int table_data_compare(const void *x, const void *y) { ++ const size_t *a = x, *b=y; + int r; + +- assert(t); +- assert(t->sort_map); ++ assert(user_table); ++ assert(user_table->sort_map); + + /* Make sure the header stays at the beginning */ +- if (*a < t->n_columns && *b < t->n_columns) ++ if (*a < user_table->n_columns && *b < user_table->n_columns) + return 0; +- if (*a < t->n_columns) ++ if (*a < user_table->n_columns) + return -1; +- if (*b < t->n_columns) ++ if (*b < user_table->n_columns) + return 1; + + /* Order other lines by the sorting map */ +- for (size_t i = 0; i < t->n_sort_map; i++) { ++ for (size_t i = 0; i < user_table->n_sort_map; i++) { + TableData *d, *dd; + +- d = t->data[*a + t->sort_map[i]]; +- dd = t->data[*b + t->sort_map[i]]; ++ d = user_table->data[*a + user_table->sort_map[i]]; ++ dd = user_table->data[*b + user_table->sort_map[i]]; + + r = cell_data_compare(d, *a, dd, *b); + if (r != 0) +- return t->reverse_map && t->reverse_map[t->sort_map[i]] ? -r : r; ++ return user_table->reverse_map && user_table->reverse_map[user_table->sort_map[i]] ? -r : r; + } + + /* Order identical lines by the order there were originally added in */ +@@ -1844,7 +1846,12 @@ int table_print(Table *t, FILE *f) { + for (size_t i = 0; i < n_rows; i++) + sorted[i] = i * t->n_columns; + +- typesafe_qsort_r(sorted, n_rows, table_data_compare, t); ++ if (n_rows <= 1) ++ return 0; ++ assert(sorted); ++ user_table = t; ++ qsort(sorted, n_rows, sizeof(size_t), table_data_compare); ++ user_table = NULL; + } + + if (t->display_map) +@@ -2440,7 +2447,12 @@ int table_to_json(Table *t, JsonVariant **ret) { + for (size_t i = 0; i < n_rows; i++) + sorted[i] = i * t->n_columns; + +- typesafe_qsort_r(sorted, n_rows, table_data_compare, t); ++ if (n_rows <= 1) ++ return 0; ++ assert(sorted); ++ user_table = t; ++ qsort(sorted, n_rows, sizeof(size_t), table_data_compare); ++ user_table = NULL; + } + + if (t->display_map) +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_openeuler.patch new file mode 100644 index 00000000000..a573c557bdb --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_openeuler.patch @@ -0,0 +1,78 @@ +From 9f0d5996bbb2db3679a4075fa8301750b786c03b Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 13:55:12 +0800 +Subject: [PATCH 03/26] missing_type.h: add __compare_fn_t and comparison_fn_t + +Make it work with musl where comparison_fn_t and __compare_fn_t +is not provided. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Alex Kiernan +[Rebased for v244] +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +--- + src/basic/missing_type.h | 9 +++++++++ + src/basic/sort-util.h | 1 + + src/core/kmod-setup.c | 1 + + src/libsystemd/sd-journal/catalog.c | 1 + + 4 files changed, 12 insertions(+) + +diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h +index f6233090a9..aeaf6ad5ec 100644 +--- a/src/basic/missing_type.h ++++ b/src/basic/missing_type.h +@@ -10,3 +10,12 @@ + #if !HAVE_CHAR16_T + #define char16_t uint16_t + #endif ++ ++#ifndef __GLIBC__ ++typedef int (*comparison_fn_t)(const void *, const void *); ++#endif ++ ++#ifndef __COMPAR_FN_T ++#define __COMPAR_FN_T ++typedef int (*__compar_fn_t)(const void *, const void *); ++#endif +diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h +index 3394c9eb72..d9cb2aecb6 100644 +--- a/src/basic/sort-util.h ++++ b/src/basic/sort-util.h +@@ -4,6 +4,7 @@ + #include + + #include "macro.h" ++#include "missing_type.h" + + void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, + __compar_d_fn_t compar, void *arg); +diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c +index 8a7f82812a..a56f12f47f 100644 +--- a/src/core/kmod-setup.c ++++ b/src/core/kmod-setup.c +@@ -10,6 +10,7 @@ + #include "kmod-setup.h" + #include "macro.h" + #include "string-util.h" ++#include "missing_type.h" + + #if HAVE_KMOD + #include "module-util.h" +diff --git a/src/libsystemd/sd-journal/catalog.c b/src/libsystemd/sd-journal/catalog.c +index 0f6ad8a29e..4e1077ade4 100644 +--- a/src/libsystemd/sd-journal/catalog.c ++++ b/src/libsystemd/sd-journal/catalog.c +@@ -28,6 +28,7 @@ + #include "string-util.h" + #include "strv.h" + #include "tmpfile-util.h" ++#include "missing_type.h" + + const char * const catalog_file_dirs[] = { + "/usr/local/lib/systemd/catalog/", +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0004-add-fallback-parse_printf_format-implementation-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0004-add-fallback-parse_printf_format-implementation-openeuler.patch new file mode 100644 index 00000000000..9fbd8a5ab97 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0004-add-fallback-parse_printf_format-implementation-openeuler.patch @@ -0,0 +1,434 @@ +From f3dbe29f7620a063af4d8eb3ea7c48ecd410200d Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 14:04:21 +0800 +Subject: [PATCH 04/26] add fallback parse_printf_format implementation + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Emil Renner Berthing +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray +--- + meson.build | 1 + + src/basic/meson.build | 5 + + src/basic/parse-printf-format.c | 273 ++++++++++++++++++++++++++++++++ + src/basic/parse-printf-format.h | 57 +++++++ + src/basic/stdio-util.h | 2 +- + src/libsystemd/sd-journal/journal-send.c | 2 +- + 6 files changed, 338 insertions(+), 2 deletions(-) + create mode 100644 src/basic/parse-printf-format.c + create mode 100644 src/basic/parse-printf-format.h + +diff --git a/meson.build b/meson.build +index f406d595e6..6aa47fc755 100644 +--- a/meson.build ++++ b/meson.build +@@ -657,6 +657,7 @@ endif + foreach header : ['crypt.h', + 'linux/memfd.h', + 'linux/vm_sockets.h', ++ 'printf.h', + 'sys/auxv.h', + 'valgrind/memcheck.h', + 'valgrind/valgrind.h', +diff --git a/src/basic/meson.build b/src/basic/meson.build +index 1183ea83ad..aa5c958850 100644 +--- a/src/basic/meson.build ++++ b/src/basic/meson.build +@@ -322,6 +322,10 @@ endforeach + + basic_sources += generated_gperf_headers + ++if conf.get('HAVE_PRINTF_H') != 1 ++ basic_sources += [files('parse-printf-format.c')] ++endif ++ + ############################################################ + + arch_list = [ +diff --git a/src/basic/parse-printf-format.c b/src/basic/parse-printf-format.c +new file mode 100644 +index 0000000000..49437e5445 +--- /dev/null ++++ b/src/basic/parse-printf-format.c +@@ -0,0 +1,273 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++/*** ++ This file is part of systemd. ++ ++ Copyright 2014 Emil Renner Berthing ++ ++ With parts from the musl C library ++ Copyright 2005-2014 Rich Felker, et al. ++ ++ systemd is free software; you can redistribute it and/or modify it ++ under the terms of the GNU Lesser General Public License as published by ++ the Free Software Foundation; either version 2.1 of the License, or ++ (at your option) any later version. ++ ++ systemd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public License ++ along with systemd; If not, see . ++***/ ++ ++#include ++#include ++ ++#include "parse-printf-format.h" ++ ++static const char *consume_nonarg(const char *fmt) ++{ ++ do { ++ if (*fmt == '\0') ++ return fmt; ++ } while (*fmt++ != '%'); ++ return fmt; ++} ++ ++static const char *consume_num(const char *fmt) ++{ ++ for (;*fmt >= '0' && *fmt <= '9'; fmt++) ++ /* do nothing */; ++ return fmt; ++} ++ ++static const char *consume_argn(const char *fmt, size_t *arg) ++{ ++ const char *p = fmt; ++ size_t val = 0; ++ ++ if (*p < '1' || *p > '9') ++ return fmt; ++ do { ++ val = 10*val + (*p++ - '0'); ++ } while (*p >= '0' && *p <= '9'); ++ ++ if (*p != '$') ++ return fmt; ++ *arg = val; ++ return p+1; ++} ++ ++static const char *consume_flags(const char *fmt) ++{ ++ while (1) { ++ switch (*fmt) { ++ case '#': ++ case '0': ++ case '-': ++ case ' ': ++ case '+': ++ case '\'': ++ case 'I': ++ fmt++; ++ continue; ++ } ++ return fmt; ++ } ++} ++ ++enum state { ++ BARE, ++ LPRE, ++ LLPRE, ++ HPRE, ++ HHPRE, ++ BIGLPRE, ++ ZTPRE, ++ JPRE, ++ STOP ++}; ++ ++enum type { ++ NONE, ++ PTR, ++ INT, ++ UINT, ++ ULLONG, ++ LONG, ++ ULONG, ++ SHORT, ++ USHORT, ++ CHAR, ++ UCHAR, ++ LLONG, ++ SIZET, ++ IMAX, ++ UMAX, ++ PDIFF, ++ UIPTR, ++ DBL, ++ LDBL, ++ MAXTYPE ++}; ++ ++static const short pa_types[MAXTYPE] = { ++ [NONE] = PA_INT, ++ [PTR] = PA_POINTER, ++ [INT] = PA_INT, ++ [UINT] = PA_INT, ++ [ULLONG] = PA_INT | PA_FLAG_LONG_LONG, ++ [LONG] = PA_INT | PA_FLAG_LONG, ++ [ULONG] = PA_INT | PA_FLAG_LONG, ++ [SHORT] = PA_INT | PA_FLAG_SHORT, ++ [USHORT] = PA_INT | PA_FLAG_SHORT, ++ [CHAR] = PA_CHAR, ++ [UCHAR] = PA_CHAR, ++ [LLONG] = PA_INT | PA_FLAG_LONG_LONG, ++ [SIZET] = PA_INT | PA_FLAG_LONG, ++ [IMAX] = PA_INT | PA_FLAG_LONG_LONG, ++ [UMAX] = PA_INT | PA_FLAG_LONG_LONG, ++ [PDIFF] = PA_INT | PA_FLAG_LONG_LONG, ++ [UIPTR] = PA_INT | PA_FLAG_LONG, ++ [DBL] = PA_DOUBLE, ++ [LDBL] = PA_DOUBLE | PA_FLAG_LONG_DOUBLE ++}; ++ ++#define S(x) [(x)-'A'] ++#define E(x) (STOP + (x)) ++ ++static const unsigned char states[]['z'-'A'+1] = { ++ { /* 0: bare types */ ++ S('d') = E(INT), S('i') = E(INT), ++ S('o') = E(UINT),S('u') = E(UINT),S('x') = E(UINT), S('X') = E(UINT), ++ S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), ++ S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), ++ S('c') = E(CHAR),S('C') = E(INT), ++ S('s') = E(PTR), S('S') = E(PTR), S('p') = E(UIPTR),S('n') = E(PTR), ++ S('m') = E(NONE), ++ S('l') = LPRE, S('h') = HPRE, S('L') = BIGLPRE, ++ S('z') = ZTPRE, S('j') = JPRE, S('t') = ZTPRE ++ }, { /* 1: l-prefixed */ ++ S('d') = E(LONG), S('i') = E(LONG), ++ S('o') = E(ULONG),S('u') = E(ULONG),S('x') = E(ULONG),S('X') = E(ULONG), ++ S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), ++ S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), ++ S('c') = E(INT), S('s') = E(PTR), S('n') = E(PTR), ++ S('l') = LLPRE ++ }, { /* 2: ll-prefixed */ ++ S('d') = E(LLONG), S('i') = E(LLONG), ++ S('o') = E(ULLONG),S('u') = E(ULLONG), ++ S('x') = E(ULLONG),S('X') = E(ULLONG), ++ S('n') = E(PTR) ++ }, { /* 3: h-prefixed */ ++ S('d') = E(SHORT), S('i') = E(SHORT), ++ S('o') = E(USHORT),S('u') = E(USHORT), ++ S('x') = E(USHORT),S('X') = E(USHORT), ++ S('n') = E(PTR), ++ S('h') = HHPRE ++ }, { /* 4: hh-prefixed */ ++ S('d') = E(CHAR), S('i') = E(CHAR), ++ S('o') = E(UCHAR),S('u') = E(UCHAR), ++ S('x') = E(UCHAR),S('X') = E(UCHAR), ++ S('n') = E(PTR) ++ }, { /* 5: L-prefixed */ ++ S('e') = E(LDBL),S('f') = E(LDBL),S('g') = E(LDBL), S('a') = E(LDBL), ++ S('E') = E(LDBL),S('F') = E(LDBL),S('G') = E(LDBL), S('A') = E(LDBL), ++ S('n') = E(PTR) ++ }, { /* 6: z- or t-prefixed (assumed to be same size) */ ++ S('d') = E(PDIFF),S('i') = E(PDIFF), ++ S('o') = E(SIZET),S('u') = E(SIZET), ++ S('x') = E(SIZET),S('X') = E(SIZET), ++ S('n') = E(PTR) ++ }, { /* 7: j-prefixed */ ++ S('d') = E(IMAX), S('i') = E(IMAX), ++ S('o') = E(UMAX), S('u') = E(UMAX), ++ S('x') = E(UMAX), S('X') = E(UMAX), ++ S('n') = E(PTR) ++ } ++}; ++ ++size_t parse_printf_format(const char *fmt, size_t n, int *types) ++{ ++ size_t i = 0; ++ size_t last = 0; ++ ++ memset(types, 0, n); ++ ++ while (1) { ++ size_t arg; ++ unsigned int state; ++ ++ fmt = consume_nonarg(fmt); ++ if (*fmt == '\0') ++ break; ++ if (*fmt == '%') { ++ fmt++; ++ continue; ++ } ++ arg = 0; ++ fmt = consume_argn(fmt, &arg); ++ /* flags */ ++ fmt = consume_flags(fmt); ++ /* width */ ++ if (*fmt == '*') { ++ size_t warg = 0; ++ fmt = consume_argn(fmt+1, &warg); ++ if (warg == 0) ++ warg = ++i; ++ if (warg > last) ++ last = warg; ++ if (warg <= n && types[warg-1] == NONE) ++ types[warg-1] = INT; ++ } else ++ fmt = consume_num(fmt); ++ /* precision */ ++ if (*fmt == '.') { ++ fmt++; ++ if (*fmt == '*') { ++ size_t parg = 0; ++ fmt = consume_argn(fmt+1, &parg); ++ if (parg == 0) ++ parg = ++i; ++ if (parg > last) ++ last = parg; ++ if (parg <= n && types[parg-1] == NONE) ++ types[parg-1] = INT; ++ } else { ++ if (*fmt == '-') ++ fmt++; ++ fmt = consume_num(fmt); ++ } ++ } ++ /* length modifier and conversion specifier */ ++ state = BARE; ++ do { ++ unsigned char c = *fmt++; ++ ++ if (c < 'A' || c > 'z') ++ continue; ++ state = states[state]S(c); ++ if (state == 0) ++ continue; ++ } while (state < STOP); ++ ++ if (state == E(NONE)) ++ continue; ++ ++ if (arg == 0) ++ arg = ++i; ++ if (arg > last) ++ last = arg; ++ if (arg <= n) ++ types[arg-1] = state - STOP; ++ } ++ ++ if (last > n) ++ last = n; ++ for (i = 0; i < last; i++) ++ types[i] = pa_types[types[i]]; ++ ++ return last; ++} +diff --git a/src/basic/parse-printf-format.h b/src/basic/parse-printf-format.h +new file mode 100644 +index 0000000000..47be7522d7 +--- /dev/null ++++ b/src/basic/parse-printf-format.h +@@ -0,0 +1,57 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++/*** ++ This file is part of systemd. ++ ++ Copyright 2014 Emil Renner Berthing ++ ++ With parts from the GNU C Library ++ Copyright 1991-2014 Free Software Foundation, Inc. ++ ++ systemd is free software; you can redistribute it and/or modify it ++ under the terms of the GNU Lesser General Public License as published by ++ the Free Software Foundation; either version 2.1 of the License, or ++ (at your option) any later version. ++ ++ systemd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public License ++ along with systemd; If not, see . ++***/ ++ ++#pragma once ++ ++#include "config.h" ++ ++#if HAVE_PRINTF_H ++#include ++#else ++ ++#include ++ ++enum { /* C type: */ ++ PA_INT, /* int */ ++ PA_CHAR, /* int, cast to char */ ++ PA_WCHAR, /* wide char */ ++ PA_STRING, /* const char *, a '\0'-terminated string */ ++ PA_WSTRING, /* const wchar_t *, wide character string */ ++ PA_POINTER, /* void * */ ++ PA_FLOAT, /* float */ ++ PA_DOUBLE, /* double */ ++ PA_LAST ++}; ++ ++/* Flag bits that can be set in a type returned by `parse_printf_format'. */ ++#define PA_FLAG_MASK 0xff00 ++#define PA_FLAG_LONG_LONG (1 << 8) ++#define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG ++#define PA_FLAG_LONG (1 << 9) ++#define PA_FLAG_SHORT (1 << 10) ++#define PA_FLAG_PTR (1 << 11) ++ ++size_t parse_printf_format(const char *fmt, size_t n, int *types); ++ ++#endif /* HAVE_PRINTF_H */ +diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h +index 6dc1e72312..cea76b36cf 100644 +--- a/src/basic/stdio-util.h ++++ b/src/basic/stdio-util.h +@@ -1,13 +1,13 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + #pragma once + +-#include + #include + #include + #include + + #include "macro.h" + #include "memory-util.h" ++#include "parse-printf-format.h" + + #define snprintf_ok(buf, len, fmt, ...) \ + ((size_t) snprintf(buf, len, fmt, __VA_ARGS__) < (len)) +diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c +index fd3fd7ef9c..e8e6ad555b 100644 +--- a/src/libsystemd/sd-journal/journal-send.c ++++ b/src/libsystemd/sd-journal/journal-send.c +@@ -2,7 +2,6 @@ + + #include + #include +-#include + #include + #include + #include +@@ -21,6 +20,7 @@ + #include "stdio-util.h" + #include "string-util.h" + #include "tmpfile-util.h" ++#include "parse-printf-format.h" + + #define SNDBUF_SIZE (8*1024*1024) + +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0005-src-basic-missing.h-check-for-missing-strndupa-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0005-src-basic-missing.h-check-for-missing-strndupa-openeuler.patch new file mode 100644 index 00000000000..f3d9d4f130e --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0005-src-basic-missing.h-check-for-missing-strndupa-openeuler.patch @@ -0,0 +1,590 @@ +From 5aeae0ea89f5af74ed5d95bed1d87a03b3801ff0 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 14:18:21 +0800 +Subject: [PATCH 05/26] src/basic/missing.h: check for missing strndupa + +include missing.h for definition of strndupa + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +[rebased for systemd 243] +Signed-off-by: Scott Murray +Signed-off-by: Alex Kiernan +[rebased for systemd 244] +[Rebased for v247] +Signed-off-by: Luca Boccassi +--- + meson.build | 1 + + src/backlight/backlight.c | 1 + + src/basic/cgroup-util.c | 1 + + src/basic/env-util.c | 1 + + src/basic/log.c | 1 + + src/basic/missing_stdlib.h | 12 ++++++++++++ + src/basic/mkdir.c | 1 + + src/basic/parse-util.c | 1 + + src/basic/path-lookup.c | 1 + + src/basic/proc-cmdline.c | 1 + + src/basic/procfs-util.c | 1 + + src/shared/selinux-util.c | 1 + + src/basic/time-util.c | 1 + + src/boot/bless-boot.c | 1 + + src/core/dbus-cgroup.c | 1 + + src/core/dbus-execute.c | 1 + + src/core/dbus-util.c | 1 + + src/core/execute.c | 1 + + src/core/kmod-setup.c | 1 + + src/core/service.c | 1 + + src/coredump/coredump-vacuum.c | 1 + + src/journal-remote/journal-remote-main.c | 1 + + src/journal/journalctl.c | 1 + + src/libsystemd/sd-journal/sd-journal.c | 1 + + src/libsystemd/sd-bus/bus-message.c | 1 + + src/libsystemd/sd-bus/bus-objects.c | 1 + + src/libsystemd/sd-bus/bus-socket.c | 1 + + src/libsystemd/sd-bus/sd-bus.c | 1 + + src/libsystemd/sd-bus/test-bus-benchmark.c | 1 + + src/locale/keymap-util.c | 1 + + src/login/pam_systemd.c | 1 + + src/network/generator/network-generator.c | 1 + + src/nspawn/nspawn-settings.c | 1 + + src/nss-mymachines/nss-mymachines.c | 1 + + src/portable/portable.c | 1 + + src/resolve/resolvectl.c | 1 + + src/shared/bus-get-properties.c | 1 + + src/shared/bus-unit-procs.c | 1 + + src/shared/bus-unit-util.c | 1 + + src/shared/bus-util.c | 1 + + src/shared/dns-domain.c | 1 + + src/shared/journal-importer.c | 1 + + src/shared/logs-show.c | 1 + + src/shared/pager.c | 1 + + src/shared/uid-range.c | 1 + + src/socket-proxy/socket-proxyd.c | 1 + + src/test/test-hexdecoct.c | 1 + + src/udev/udev-builtin-path_id.c | 1 + + src/udev/udev-event.c | 1 + + src/udev/udev-rules.c | 1 + + 50 files changed, 61 insertions(+) + +--- a/meson.build ++++ b/meson.build +@@ -528,6 +528,7 @@ foreach ident : [ + ['mount_setattr', '''#include '''], + ['move_mount', '''#include '''], + ['open_tree', '''#include '''], ++ ['strndupa' , '''#include '''], + ] + + have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') +--- a/src/backlight/backlight.c ++++ b/src/backlight/backlight.c +@@ -19,6 +19,7 @@ + #include "string-util.h" + #include "strv.h" + #include "util.h" ++#include "missing_stdlib.h" + + static int help(void) { + _cleanup_free_ char *link = NULL; +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -38,6 +38,7 @@ + #include "unit-name.h" + #include "user-util.h" + #include "xattr-util.h" ++#include "missing_stdlib.h" + + static int cg_enumerate_items(const char *controller, const char *path, FILE **_f, const char *item) { + _cleanup_free_ char *fs = NULL; +--- a/src/basic/env-util.c ++++ b/src/basic/env-util.c +@@ -15,6 +15,7 @@ + #include "string-util.h" + #include "strv.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + /* We follow bash for the character set. Different shells have different rules. */ + #define VALID_BASH_ENV_NAME_CHARS \ +--- a/src/basic/log.c ++++ b/src/basic/log.c +@@ -36,6 +36,7 @@ + #include "terminal-util.h" + #include "time-util.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + #define SNDBUF_SIZE (8*1024*1024) + +--- a/src/basic/missing_stdlib.h ++++ b/src/basic/missing_stdlib.h +@@ -11,3 +11,15 @@ + # error "neither secure_getenv nor __secure_getenv are available" + # endif + #endif ++ ++/* string.h */ ++#if ! HAVE_STRNDUPA ++#define strndupa(s, n) \ ++ ({ \ ++ const char *__old = (s); \ ++ size_t __len = strnlen(__old, (n)); \ ++ char *__new = (char *)alloca(__len + 1); \ ++ __new[__len] = '\0'; \ ++ (char *)memcpy(__new, __old, __len); \ ++ }) ++#endif +--- a/src/basic/mkdir.c ++++ b/src/basic/mkdir.c +@@ -14,6 +14,7 @@ + #include "stat-util.h" + #include "stdio-util.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + int mkdir_safe_internal( + const char *path, +--- a/src/basic/parse-util.c ++++ b/src/basic/parse-util.c +@@ -22,6 +22,7 @@ + #include "stat-util.h" + #include "string-util.h" + #include "strv.h" ++#include "missing_stdlib.h" + + int parse_boolean(const char *v) { + if (!v) +--- a/src/basic/path-lookup.c ++++ b/src/basic/path-lookup.c +@@ -15,6 +15,7 @@ + #include "strv.h" + #include "tmpfile-util.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + int xdg_user_runtime_dir(char **ret, const char *suffix) { + const char *e; +--- a/src/basic/proc-cmdline.c ++++ b/src/basic/proc-cmdline.c +@@ -15,6 +15,7 @@ + #include "string-util.h" + #include "util.h" + #include "virt.h" ++#include "missing_stdlib.h" + + int proc_cmdline(char **ret) { + const char *e; +--- a/src/basic/procfs-util.c ++++ b/src/basic/procfs-util.c +@@ -11,6 +11,7 @@ + #include "procfs-util.h" + #include "stdio-util.h" + #include "string-util.h" ++#include "missing_stdlib.h" + + int procfs_tasks_get_limit(uint64_t *ret) { + _cleanup_free_ char *value = NULL; +--- a/src/shared/selinux-util.c ++++ b/src/shared/selinux-util.c +@@ -27,6 +27,7 @@ + #include "selinux-util.h" + #include "stdio-util.h" + #include "time-util.h" ++#include "missing_stdlib.h" + + #if HAVE_SELINUX + DEFINE_TRIVIAL_CLEANUP_FUNC(context_t, context_free); +--- a/src/basic/time-util.c ++++ b/src/basic/time-util.c +@@ -27,6 +27,7 @@ + #include "string-util.h" + #include "strv.h" + #include "time-util.h" ++#include "missing_stdlib.h" + + static clockid_t map_clock_id(clockid_t c) { + +--- a/src/boot/bless-boot.c ++++ b/src/boot/bless-boot.c +@@ -18,6 +18,7 @@ + #include "util.h" + #include "verbs.h" + #include "virt.h" ++#include "missing_stdlib.h" + + static char **arg_path = NULL; + +--- a/src/core/dbus-cgroup.c ++++ b/src/core/dbus-cgroup.c +@@ -20,6 +20,7 @@ + #include "parse-util.h" + #include "path-util.h" + #include "percent-util.h" ++#include "missing_stdlib.h" + + BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", TasksMax, tasks_max_resolve); + +--- a/src/core/dbus-execute.c ++++ b/src/core/dbus-execute.c +@@ -41,6 +41,7 @@ + #include "unit-printf.h" + #include "user-util.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output, exec_output, ExecOutput); + static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input, exec_input, ExecInput); +--- a/src/core/dbus-util.c ++++ b/src/core/dbus-util.c +@@ -7,6 +7,7 @@ + #include "unit-printf.h" + #include "user-util.h" + #include "unit.h" ++#include "missing_stdlib.h" + + int bus_property_get_triggered_unit( + sd_bus *bus, +--- a/src/core/execute.c ++++ b/src/core/execute.c +@@ -96,6 +96,7 @@ + #include "unit.h" + #include "user-util.h" + #include "utmp-wtmp.h" ++#include "missing_stdlib.h" + + #define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC) + #define IDLE_TIMEOUT2_USEC (1*USEC_PER_SEC) +--- a/src/core/kmod-setup.c ++++ b/src/core/kmod-setup.c +@@ -11,6 +11,7 @@ + #include "macro.h" + #include "string-util.h" + #include "missing_type.h" ++#include "missing_stdlib.h" + + #if HAVE_KMOD + #include "module-util.h" +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -41,6 +41,7 @@ + #include "unit.h" + #include "utf8.h" + #include "util.h" ++#include "missing_stdlib.h" + + static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { + [SERVICE_DEAD] = UNIT_INACTIVE, +--- a/src/coredump/coredump-vacuum.c ++++ b/src/coredump/coredump-vacuum.c +@@ -16,6 +16,7 @@ + #include "string-util.h" + #include "time-util.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + #define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */ + #define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */ +--- a/src/journal-remote/journal-remote-main.c ++++ b/src/journal-remote/journal-remote-main.c +@@ -22,6 +22,7 @@ + #include "stat-util.h" + #include "string-table.h" + #include "strv.h" ++#include "missing_stdlib.h" + + #define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem" + #define CERT_FILE CERTIFICATE_ROOT "/certs/journal-remote.pem" +--- a/src/journal/journalctl.c ++++ b/src/journal/journalctl.c +@@ -73,6 +73,7 @@ + #include "unit-name.h" + #include "user-util.h" + #include "varlink.h" ++#include "missing_stdlib.h" + + #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE) + #define PROCESS_INOTIFY_INTERVAL 1024 /* Every 1,024 messages processed */ +--- a/src/libsystemd/sd-journal/sd-journal.c ++++ b/src/libsystemd/sd-journal/sd-journal.c +@@ -40,6 +40,7 @@ + #include "string-util.h" + #include "strv.h" + #include "syslog-util.h" ++#include "missing_stdlib.h" + + #define JOURNAL_FILES_MAX 7168 + +--- a/src/libsystemd/sd-bus/bus-message.c ++++ b/src/libsystemd/sd-bus/bus-message.c +@@ -21,6 +21,7 @@ + #include "strv.h" + #include "time-util.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored); + +--- a/src/libsystemd/sd-bus/bus-objects.c ++++ b/src/libsystemd/sd-bus/bus-objects.c +@@ -13,6 +13,7 @@ + #include "set.h" + #include "string-util.h" + #include "strv.h" ++#include "missing_stdlib.h" + + static int node_vtable_get_userdata( + sd_bus *bus, +--- a/src/libsystemd/sd-bus/bus-socket.c ++++ b/src/libsystemd/sd-bus/bus-socket.c +@@ -28,6 +28,7 @@ + #include "string-util.h" + #include "user-util.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + #define SNDBUF_SIZE (8*1024*1024) + +--- a/src/libsystemd/sd-bus/sd-bus.c ++++ b/src/libsystemd/sd-bus/sd-bus.c +@@ -42,6 +42,7 @@ + #include "string-util.h" + #include "strv.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + #define log_debug_bus_message(m) \ + do { \ +--- a/src/libsystemd/sd-bus/test-bus-benchmark.c ++++ b/src/libsystemd/sd-bus/test-bus-benchmark.c +@@ -14,6 +14,7 @@ + #include "missing_resource.h" + #include "time-util.h" + #include "util.h" ++#include "missing_stdlib.h" + + #define MAX_SIZE (2*1024*1024) + +--- a/src/locale/keymap-util.c ++++ b/src/locale/keymap-util.c +@@ -21,6 +21,7 @@ + #include "string-util.h" + #include "strv.h" + #include "tmpfile-util.h" ++#include "missing_stdlib.h" + + static bool startswith_comma(const char *s, const char *prefix) { + s = startswith(s, prefix); +--- a/src/login/pam_systemd.c ++++ b/src/login/pam_systemd.c +@@ -31,6 +31,7 @@ + #include "locale-util.h" + #include "login-util.h" + #include "macro.h" ++#include "missing_stdlib.h" + #include "pam-util.h" + #include "parse-util.h" + #include "path-util.h" +--- a/src/network/generator/network-generator.c ++++ b/src/network/generator/network-generator.c +@@ -13,6 +13,7 @@ + #include "string-table.h" + #include "string-util.h" + #include "strv.h" ++#include "missing_stdlib.h" + + /* + # .network +--- a/src/nspawn/nspawn-settings.c ++++ b/src/nspawn/nspawn-settings.c +@@ -16,6 +16,7 @@ + #include "strv.h" + #include "user-util.h" + #include "util.h" ++#include "missing_stdlib.h" + + Settings *settings_new(void) { + Settings *s; +--- a/src/nss-mymachines/nss-mymachines.c ++++ b/src/nss-mymachines/nss-mymachines.c +@@ -19,6 +19,7 @@ + #include "nss-util.h" + #include "signal-util.h" + #include "string-util.h" ++#include "missing_stdlib.h" + + NSS_GETHOSTBYNAME_PROTOTYPES(mymachines); + NSS_GETPW_PROTOTYPES(mymachines); +--- a/src/portable/portable.c ++++ b/src/portable/portable.c +@@ -31,6 +31,7 @@ + #include "strv.h" + #include "tmpfile-util.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + static const char profile_dirs[] = CONF_PATHS_NULSTR("systemd/portable/profile"); + +--- a/src/resolve/resolvectl.c ++++ b/src/resolve/resolvectl.c +@@ -37,6 +37,7 @@ + #include "terminal-util.h" + #include "utf8.h" + #include "verbs.h" ++#include "missing_stdlib.h" + + static int arg_family = AF_UNSPEC; + static int arg_ifindex = 0; +--- a/src/shared/bus-get-properties.c ++++ b/src/shared/bus-get-properties.c +@@ -4,6 +4,7 @@ + #include "rlimit-util.h" + #include "stdio-util.h" + #include "string-util.h" ++#include "missing_stdlib.h" + + int bus_property_get_bool( + sd_bus *bus, +--- a/src/shared/bus-unit-procs.c ++++ b/src/shared/bus-unit-procs.c +@@ -10,6 +10,7 @@ + #include "sort-util.h" + #include "string-util.h" + #include "terminal-util.h" ++#include "missing_stdlib.h" + + struct CGroupInfo { + char *cgroup_path; +--- a/src/shared/bus-unit-util.c ++++ b/src/shared/bus-unit-util.c +@@ -44,6 +44,7 @@ + #include "unit-def.h" + #include "user-util.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { + assert(message); +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -21,6 +21,7 @@ + #include "path-util.h" + #include "socket-util.h" + #include "stdio-util.h" ++#include "missing_stdlib.h" + + static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { + sd_event *e = userdata; +--- a/src/shared/dns-domain.c ++++ b/src/shared/dns-domain.c +@@ -17,6 +17,7 @@ + #include "string-util.h" + #include "strv.h" + #include "utf8.h" ++#include "missing_stdlib.h" + + int dns_label_unescape(const char **name, char *dest, size_t sz, DNSLabelFlags flags) { + const char *n; +--- a/src/shared/journal-importer.c ++++ b/src/shared/journal-importer.c +@@ -14,6 +14,7 @@ + #include "parse-util.h" + #include "string-util.h" + #include "unaligned.h" ++#include "missing_stdlib.h" + + enum { + IMPORTER_STATE_LINE = 0, /* waiting to read, or reading line */ +--- a/src/shared/logs-show.c ++++ b/src/shared/logs-show.c +@@ -41,6 +41,7 @@ + #include "utf8.h" + #include "util.h" + #include "web-util.h" ++#include "missing_stdlib.h" + + /* up to three lines (each up to 100 characters) or 300 characters, whichever is less */ + #define PRINT_LINE_THRESHOLD 3 +--- a/src/shared/pager.c ++++ b/src/shared/pager.c +@@ -26,6 +26,7 @@ + #include "strv.h" + #include "terminal-util.h" + #include "util.h" ++#include "missing_stdlib.h" + + static pid_t pager_pid = 0; + +--- a/src/shared/uid-range.c ++++ b/src/shared/uid-range.c +@@ -9,6 +9,7 @@ + #include "sort-util.h" + #include "uid-range.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) { + assert(range); +--- a/src/socket-proxy/socket-proxyd.c ++++ b/src/socket-proxy/socket-proxyd.c +@@ -26,6 +26,7 @@ + #include "socket-util.h" + #include "string-util.h" + #include "util.h" ++#include "missing_stdlib.h" + + #define BUFFER_SIZE (256 * 1024) + +--- a/src/test/test-hexdecoct.c ++++ b/src/test/test-hexdecoct.c +@@ -6,6 +6,7 @@ + #include "hexdecoct.h" + #include "macro.h" + #include "string-util.h" ++#include "missing_stdlib.h" + + static void test_hexchar(void) { + assert_se(hexchar(0xa) == 'a'); +--- a/src/udev/udev-builtin-path_id.c ++++ b/src/udev/udev-builtin-path_id.c +@@ -22,6 +22,7 @@ + #include "sysexits.h" + #include "udev-builtin.h" + #include "udev-util.h" ++#include "missing_stdlib.h" + + _printf_(2,3) + static void path_prepend(char **path, const char *fmt, ...) { +--- a/src/udev/udev-event.c ++++ b/src/udev/udev-event.c +@@ -34,6 +34,7 @@ + #include "udev-util.h" + #include "udev-watch.h" + #include "user-util.h" ++#include "missing_stdlib.h" + + typedef struct Spawn { + sd_device *device; +--- a/src/udev/udev-rules.c ++++ b/src/udev/udev-rules.c +@@ -30,6 +30,7 @@ + #include "udev-rules.h" + #include "user-util.h" + #include "virt.h" ++#include "missing_stdlib.h" + + #define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d") + +--- a/src/basic/mountpoint-util.c ++++ b/src/basic/mountpoint-util.c +@@ -10,6 +10,7 @@ + #include "fs-util.h" + #include "missing_stat.h" + #include "missing_syscall.h" ++#include "missing_stdlib.h" + #include "mkdir.h" + #include "mountpoint-util.h" + #include "parse-util.h" diff --git a/meta-openeuler/recipes-core/systemd/files/0006-Include-netinet-if_ether.h-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0006-Include-netinet-if_ether.h-openeuler.patch new file mode 100644 index 00000000000..e1673b7df6c --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0006-Include-netinet-if_ether.h-openeuler.patch @@ -0,0 +1,328 @@ +From d3ed0da271738fd0fc3d3e4d82d6f5810334b05e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 26 Oct 2017 22:10:42 -0700 +Subject: [PATCH 06/26] Include netinet/if_ether.h + +Fixes +/path/to/systemd/recipe-sysroot/usr/include/netinet/if_ether.h:101:8: error: redefinition of 'struct ethhdr' + struct ethhdr { + ^~~~~~ + +and related arphdr, arpreq, and arpreq_old errors +/path/to/systemd/recipe-sysroot/usr/include/net/if_arp.h:22:8: error: redefinition of 'struct arphdr' + struct arphdr { + ^~~~~~ + +The latter requires removing some includes of net/if_arp.h to avoid +conflicting with netinet/if_ether.h. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray +[rebased for systemd 247] +Signed-off-by: Luca Boccassi +--- + src/libsystemd-network/sd-dhcp6-client.c | 1 - + src/libsystemd/sd-netlink/netlink-types.c | 1 + + src/machine/machine-dbus.c | 1 + + src/network/netdev/bond.c | 1 + + src/network/netdev/bridge.c | 1 + + src/network/netdev/macsec.c | 1 + + src/network/netdev/netdev-gperf.gperf | 1 + + src/network/netdev/netdev.c | 1 + + src/network/networkd-bridge-vlan.c | 1 + + src/network/networkd-dhcp-common.c | 4 +++- + src/network/networkd-dhcp-server.c | 4 ++-- + src/network/networkd-dhcp4.c | 2 +- + src/network/networkd-dhcp6.c | 2 +- + src/network/networkd-link.c | 2 +- + src/network/networkd-network.c | 1 + + src/network/networkd-route.c | 5 ++++- + src/network/test-network-tables.c | 1 + + src/shared/ethtool-util.c | 1 + + src/shared/ethtool-util.h | 1 + + src/udev/net/link-config.c | 1 + + src/udev/udev-builtin-net_setup_link.c | 1 + + 21 files changed, 26 insertions(+), 8 deletions(-) + +diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c +index 66f87c4b95..de1264ae46 100644 +--- a/src/libsystemd-network/sd-dhcp6-client.c ++++ b/src/libsystemd-network/sd-dhcp6-client.c +@@ -5,7 +5,6 @@ + + #include + #include +-#include + #include + + #include "sd-dhcp6-client.h" +diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c +index 6fb6c147d9..8eda02d202 100644 +--- a/src/libsystemd/sd-netlink/netlink-types.c ++++ b/src/libsystemd/sd-netlink/netlink-types.c +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c +index bb67beb665..f5780f1aec 100644 +--- a/src/machine/machine-dbus.c ++++ b/src/machine/machine-dbus.c +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + + /* When we include libgen.h because we need dirname() we immediately + * undefine basename() since libgen.h defines it as a macro to the POSIX +diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c +index e27f36067b..8868f1da5d 100644 +--- a/src/network/netdev/bond.c ++++ b/src/network/netdev/bond.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include "alloc-util.h" + #include "bond.h" + #include "bond-util.h" +diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c +index 1f59cd8b42..5fdbae7e99 100644 +--- a/src/network/netdev/bridge.c ++++ b/src/network/netdev/bridge.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + + #include "bridge.h" +diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c +index 82e71c3920..fbae86e216 100644 +--- a/src/network/netdev/macsec.c ++++ b/src/network/netdev/macsec.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf +index 4e89761f2c..91251fa6ec 100644 +--- a/src/network/netdev/netdev-gperf.gperf ++++ b/src/network/netdev/netdev-gperf.gperf +@@ -2,6 +2,7 @@ + #if __GNUC__ >= 7 + _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") + #endif ++#include + #include + #include "bareudp.h" + #include "bond.h" +diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c +index 9f390b5781..62aeafb1e4 100644 +--- a/src/network/netdev/netdev.c ++++ b/src/network/netdev/netdev.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +diff --git a/src/network/networkd-bridge-vlan.c b/src/network/networkd-bridge-vlan.c +index e53c73c30c..9bf0771b84 100644 +--- a/src/network/networkd-bridge-vlan.c ++++ b/src/network/networkd-bridge-vlan.c +@@ -4,6 +4,7 @@ + ***/ + + #include ++#include + #include + #include + +diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c +index 9f58121350..554d006cb8 100644 +--- a/src/network/networkd-dhcp-common.c ++++ b/src/network/networkd-dhcp-common.c +@@ -1,7 +1,8 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++#include ++#include + + #include "dhcp-internal.h" + #include "dhcp6-internal.h" +@@ -10,6 +11,7 @@ + #include "networkd-dhcp-common.h" + #include "networkd-link.h" + #include "networkd-manager.h" ++#include + #include "networkd-network.h" + #include "parse-util.h" + #include "socket-util.h" +diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c +index cf279c640d..bae541029b 100644 +--- a/src/network/networkd-dhcp-server.c ++++ b/src/network/networkd-dhcp-server.c +@@ -1,8 +1,8 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include +-#include ++#include ++#include + + #include "sd-dhcp-server.h" + +diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c +index f3c1e5f609..e4ef6eca63 100644 +--- a/src/network/networkd-dhcp4.c ++++ b/src/network/networkd-dhcp4.c +@@ -1,9 +1,9 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +-#include + + #include "escape.h" + #include "alloc-util.h" +diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c +index 5c077c1ec8..fa98042aa5 100644 +--- a/src/network/networkd-dhcp6.c ++++ b/src/network/networkd-dhcp6.c +@@ -3,9 +3,9 @@ + Copyright © 2014 Intel Corporation. All rights reserved. + ***/ + ++#include + #include + #include +-#include + + #include "sd-dhcp6-client.h" + +diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c +index 3bfe636691..e0c68c8ad3 100644 +--- a/src/network/networkd-link.c ++++ b/src/network/networkd-link.c +@@ -1,8 +1,8 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include +-#include + #include + #include + +diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c +index 3254641461..f0ada419fd 100644 +--- a/src/network/networkd-network.c ++++ b/src/network/networkd-network.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c +index 0ed89584ef..e7e157c201 100644 +--- a/src/network/networkd-route.c ++++ b/src/network/networkd-route.c +@@ -1,7 +1,10 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++/* linux/ipv6_route.h conflicts with netinet/in.h so define manually */ ++#ifndef IP6_RT_PRIO_USER ++#define IP6_RT_PRIO_USER 1024 ++#endif + #include + + #include "alloc-util.h" +diff --git a/src/network/test-network-tables.c b/src/network/test-network-tables.c +index 475cac7527..9bae6eda16 100644 +--- a/src/network/test-network-tables.c ++++ b/src/network/test-network-tables.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include "bond.h" + #include "dhcp6-internal.h" + #include "dhcp6-protocol.h" +diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c +index e6fab262f2..41dd3d7df7 100644 +--- a/src/shared/ethtool-util.c ++++ b/src/shared/ethtool-util.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +diff --git a/src/shared/ethtool-util.h b/src/shared/ethtool-util.h +index f94b3e15bf..08a7e4fa09 100644 +--- a/src/shared/ethtool-util.h ++++ b/src/shared/ethtool-util.h +@@ -3,6 +3,7 @@ + + #include + #include ++#include + #include + + #include "conf-parser.h" +diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c +index d12fd0e299..636806dc23 100644 +--- a/src/udev/net/link-config.c ++++ b/src/udev/net/link-config.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include + #include + #include +diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c +index 87e1fb133e..13876029d0 100644 +--- a/src/udev/udev-builtin-net_setup_link.c ++++ b/src/udev/udev-builtin-net_setup_link.c +@@ -1,5 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + ++#include + #include "alloc-util.h" + #include "device-util.h" + #include "errno-util.h" +-- +2.25.1 + diff --git a/meta-openeuler/recipes-core/systemd/files/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat-openeuler.patch new file mode 100644 index 00000000000..63ef5ccb501 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat-openeuler.patch @@ -0,0 +1,100 @@ +From 03e89da266edf70121a19ffc32a78cc3b97585ef Mon Sep 17 00:00:00 2001 +From: Andre McCurdy +Date: Tue, 10 Oct 2017 14:33:30 -0700 +Subject: [PATCH 12/26] don't pass AT_SYMLINK_NOFOLLOW flag to faccessat() + +Avoid using AT_SYMLINK_NOFOLLOW flag. It doesn't seem like the right +thing to do and it's not portable (not supported by musl). See: + + http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003610.html + http://www.openwall.com/lists/musl/2015/02/05/2 + +Note that laccess() is never passing AT_EACCESS so a lot of the +discussion in the links above doesn't apply. Note also that +(currently) all systemd callers of laccess() pass mode as F_OK, so +only check for existence of a file, not access permissions. +Therefore, in this case, the only distiction between faccessat() +with (flag == 0) and (flag == AT_SYMLINK_NOFOLLOW) is the behaviour +for broken symlinks; laccess() on a broken symlink will succeed with +(flag == AT_SYMLINK_NOFOLLOW) and fail (flag == 0). + +The laccess() macros was added to systemd some time ago and it's not +clear if or why it needs to return success for broken symlinks. Maybe +just historical and not actually necessary or desired behaviour? + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Andre McCurdy +--- + src/basic/fs-util.h | 22 +++++++++++++++++++++- + src/shared/base-filesystem.c | 6 +++--- + 2 files changed, 24 insertions(+), 4 deletions(-) + +diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h +index 5dc8853eac..0491b3dae2 100644 +--- a/src/basic/fs-util.h ++++ b/src/basic/fs-util.h +@@ -47,8 +47,27 @@ int futimens_opath(int fd, const struct + int fd_warn_permissions(const char *path, int fd); + int stat_warn_permissions(const char *path, const struct stat *st); + +-#define laccess(path, mode) \ +- (faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) < 0 ? -errno : 0) ++/* ++ Avoid using AT_SYMLINK_NOFOLLOW flag. It doesn't seem like the right thing to ++ do and it's not portable (not supported by musl). See: ++ ++ http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003610.html ++ http://www.openwall.com/lists/musl/2015/02/05/2 ++ ++ Note that laccess() is never passing AT_EACCESS so a lot of the discussion in ++ the links above doesn't apply. Note also that (currently) all systemd callers ++ of laccess() pass mode as F_OK, so only check for existence of a file, not ++ access permissions. Therefore, in this case, the only distiction between ++ faccessat() with (flag == 0) and (flag == AT_SYMLINK_NOFOLLOW) is the ++ behaviour for broken symlinks; laccess() on a broken symlink will succeed ++ with (flag == AT_SYMLINK_NOFOLLOW) and fail (flag == 0). ++ ++ The laccess() macros was added to systemd some time ago and it's not clear if ++ or why it needs to return success for broken symlinks. Maybe just historical ++ and not actually necessary or desired behaviour? ++*/ ++ ++#define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), 0) + + int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); + int touch(const char *path); +diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c +index 1d05409086..1ed06c31ab 100644 +--- a/src/shared/base-filesystem.c ++++ b/src/shared/base-filesystem.c +@@ -53,7 +53,7 @@ int base_filesystem_create(const char *r + return log_error_errno(errno, "Failed to open root file system: %m"); + + for (size_t i = 0; i < ELEMENTSOF(table); i++) { +- if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0) ++ if (faccessat(fd, table[i].dir, F_OK, 0) >= 0) + continue; + + if (table[i].target) { +@@ -62,7 +62,7 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) { + + /* check if one of the targets exists */ + NULSTR_FOREACH(s, table[i].target) { +- if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0) ++ if (faccessat(fd, s, F_OK, 0) < 0) + continue; + + /* check if a specific file exists at the target path */ +@@ -73,7 +73,7 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) { + if (!p) + return log_oom(); + +- if (faccessat(fd, p, F_OK, AT_SYMLINK_NOFOLLOW) < 0) ++ if (faccessat(fd, p, F_OK, 0) < 0) + continue; + } + +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif-openeuler.patch new file mode 100644 index 00000000000..66b7f244ca8 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif-openeuler.patch @@ -0,0 +1,62 @@ +From e382845aed90cfe4496a8351d57d4466dd2e9a9c Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 10 Jul 2018 15:40:17 +0800 +Subject: [PATCH 15/26] distinguish XSI-compliant strerror_r from GNU-specifi + strerror_r + +XSI-compliant strerror_r and GNU-specifi strerror_r are different. + + int strerror_r(int errnum, char *buf, size_t buflen); + /* XSI-compliant */ + + char *strerror_r(int errnum, char *buf, size_t buflen); + /* GNU-specific */ + +We need to distinguish between them. Otherwise, we'll get an int value +assigned to (char *) variable, resulting in segment fault. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/libsystemd/sd-journal/journal-send.c | 5 +++++ + src/libsystemd/sd-bus/bus-error.c | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c +index e8e6ad555b..8ca5271d02 100644 +--- a/src/libsystemd/sd-journal/journal-send.c ++++ b/src/libsystemd/sd-journal/journal-send.c +@@ -348,7 +348,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove + char* j; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++ j = buffer + 8 + k; ++#else + j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++#endif + if (errno == 0) { + char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1]; + +diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c +index 8da2024a50..9605a9b869 100644 +--- a/src/libsystemd/sd-bus/bus-error.c ++++ b/src/libsystemd/sd-bus/bus-error.c +@@ -392,7 +392,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) { + return; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(error, m, k); ++ x = m; ++#else + x = strerror_r(error, m, k); ++#endif + if (errno == ERANGE || strlen(x) >= k - 1) { + free(m); + k *= 2; +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0022-do-not-disable-buffer-in-writing-files-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0022-do-not-disable-buffer-in-writing-files-openeuler.patch new file mode 100644 index 00000000000..7ba652b2d04 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0022-do-not-disable-buffer-in-writing-files-openeuler.patch @@ -0,0 +1,376 @@ +From 564dba5ad0cd884e3f69fa19ca64095413578ea5 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Fri, 1 Mar 2019 15:22:15 +0800 +Subject: [PATCH 22/26] do not disable buffer in writing files + +Do not disable buffer in writing files, otherwise we get +failure at boot for musl like below. + + [!!!!!!] Failed to allocate manager object. + +And there will be other failures, critical or not critical. +This is specific to musl. + +Upstream-Status: Inappropriate [musl] + +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +[rebased for systemd 243] +Signed-off-by: Scott Murray +--- + src/basic/cgroup-util.c | 10 +++++----- + src/basic/procfs-util.c | 4 ++-- + src/shared/smack-util.c | 2 +- + src/basic/util.c | 2 +- + src/binfmt/binfmt.c | 6 +++--- + src/core/main.c | 4 ++-- + src/core/smack-setup.c | 8 ++++---- + src/hibernate-resume/hibernate-resume.c | 2 +- + src/libsystemd/sd-device/sd-device.c | 2 +- + src/login/logind-dbus.c | 2 +- + src/nspawn/nspawn-cgroup.c | 2 +- + src/nspawn/nspawn.c | 6 +++--- + src/shared/cgroup-setup.c | 4 ++-- + src/basic/sysctl-util.c | 2 +- + src/sleep/sleep.c | 8 ++++---- + src/udev/udevadm-trigger.c | 2 +- + src/udev/udevd.c | 2 +- + src/vconsole/vconsole-setup.c | 2 +- + 18 files changed, 35 insertions(+), 35 deletions(-) + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index bb960f183c..cb804c5f4b 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -759,7 +759,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { + + sc = strstrip(contents); + if (isempty(sc)) { +- r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, agent, 0); + if (r < 0) + return r; + } else if (!path_equal(sc, agent)) +@@ -777,7 +777,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { + + sc = strstrip(contents); + if (streq(sc, "0")) { +- r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "1", 0); + if (r < 0) + return r; + +@@ -804,7 +804,7 @@ int cg_uninstall_release_agent(const char *controller) { + if (r < 0) + return r; + +- r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "0", 0); + if (r < 0) + return r; + +@@ -814,7 +814,7 @@ int cg_uninstall_release_agent(const char *controller) { + if (r < 0) + return r; + +- r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "", 0); + if (r < 0) + return r; + +@@ -1646,7 +1646,7 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri + if (r < 0) + return r; + +- return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file(p, value, 0); + } + + int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { +diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c +index 8f9eee8d36..480f8cc0b4 100644 +--- a/src/basic/procfs-util.c ++++ b/src/basic/procfs-util.c +@@ -86,13 +86,13 @@ int procfs_tasks_set_limit(uint64_t limit) { + * decrease it, as threads-max is the much more relevant sysctl. */ + if (limit > pid_max-1) { + sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ +- r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); + if (r < 0) + return r; + } + + sprintf(buffer, "%" PRIu64, limit); +- r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); + if (r < 0) { + uint64_t threads_max; + +diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c +index 3362ee3924..80c0f2a52e 100644 +--- a/src/shared/smack-util.c ++++ b/src/shared/smack-util.c +@@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { + return 0; + + p = procfs_file_alloca(pid, "attr/current"); +- r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(p, label, 0); + if (r < 0) + return r; + +diff --git a/src/basic/util.c b/src/basic/util.c +index f98ecf3858..13e0f7431f 100644 +--- a/src/basic/util.c ++++ b/src/basic/util.c +@@ -267,7 +267,7 @@ void disable_coredumps(void) { + if (detect_container() > 0) + return; + +- r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); + if (r < 0) + log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); + } +diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c +index 43ed2f385b..37a6f578f7 100644 +--- a/src/binfmt/binfmt.c ++++ b/src/binfmt/binfmt.c +@@ -48,7 +48,7 @@ static int delete_rule(const char *rule) { + if (!fn) + return log_oom(); + +- return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file(fn, "-1", 0); + } + + static int apply_rule(const char *rule) { +@@ -56,7 +56,7 @@ static int apply_rule(const char *rule) { + + (void) delete_rule(rule); + +- r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); + if (r < 0) + return log_error_errno(r, "Failed to add binary format: %m"); + +@@ -223,7 +223,7 @@ static int run(int argc, char *argv[]) { + } + + /* Flush out all rules */ +- (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); + + STRV_FOREACH(f, files) { + k = apply_file(*f, true); +diff --git a/src/core/main.c b/src/core/main.c +index a280b756ff..334532cd42 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1382,7 +1382,7 @@ static int bump_unix_max_dgram_qlen(void) { + if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) + return 0; + +- r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); ++ r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); + if (r < 0) + return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, + "Failed to bump AF_UNIX datagram queue length, ignoring: %m"); +@@ -1666,7 +1666,7 @@ static void initialize_core_pattern(bool skip_setup) { + if (getpid_cached() != 1) + return; + +- r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); + if (r < 0) + log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", arg_early_core_pattern); + } +diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c +index 1fe592af70..603942a000 100644 +--- a/src/core/smack-setup.c ++++ b/src/core/smack-setup.c +@@ -325,17 +325,17 @@ int mac_smack_setup(bool *loaded_policy) { + } + + #ifdef SMACK_RUN_LABEL +- r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); +- r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); + r = write_string_file("/sys/fs/smackfs/netlabel", +- "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ "0.0.0.0/0 " SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); +- r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); + #endif +diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c +index d8f91f4e66..a088e6e2d8 100644 +--- a/src/hibernate-resume/hibernate-resume.c ++++ b/src/hibernate-resume/hibernate-resume.c +@@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { + return EXIT_FAILURE; + } + +- r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/power/resume", major_minor, 0); + if (r < 0) { + log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor); + return EXIT_FAILURE; +diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c +index d06f90ce1d..43d0a58750 100644 +--- a/src/libsystemd/sd-device/sd-device.c ++++ b/src/libsystemd/sd-device/sd-device.c +@@ -1976,7 +1976,7 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, + if (!value) + return -ENOMEM; + +- r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); ++ r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); + if (r < 0) { + if (r == -ELOOP) + return -EINVAL; +diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c +index cb01b25bc6..e92051268b 100644 +--- a/src/nspawn/nspawn-cgroup.c ++++ b/src/nspawn/nspawn-cgroup.c +@@ -124,7 +124,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) { + fn = strjoina(tree, cgroup, "/cgroup.procs"); + + sprintf(pid_string, PID_FMT, pid); +- r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); ++ r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); + if (r < 0) { + log_error_errno(r, "Failed to move process: %m"); + goto finish; +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index 3528b7ff14..11b0c20f95 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -2667,7 +2667,7 @@ static int reset_audit_loginuid(void) { + if (streq(p, "4294967295")) + return 0; + +- r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/self/loginuid", "4294967295", 0); + if (r < 0) { + log_error_errno(r, + "Failed to reset audit login UID. This probably means that your kernel is too\n" +@@ -4148,7 +4148,7 @@ static int setup_uid_map( + return log_oom(); + + xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); +- r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(uid_map, s, 0); + if (r < 0) + return log_error_errno(r, "Failed to write UID map: %m"); + +@@ -4158,7 +4158,7 @@ static int setup_uid_map( + return log_oom(); + + xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); +- r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(uid_map, s, 0); + if (r < 0) + return log_error_errno(r, "Failed to write GID map: %m"); + +diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c +index f197f715c7..077f893177 100644 +--- a/src/shared/cgroup-setup.c ++++ b/src/shared/cgroup-setup.c +@@ -267,7 +267,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { + + xsprintf(c, PID_FMT "\n", pid); + +- r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, c, 0); + if (r < 0) + return r; + +@@ -799,7 +799,7 @@ int cg_enable_everywhere( + return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); + } + +- r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_stream(f, s, 0); + if (r < 0) { + log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", + FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); +diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c +index 670c33108b..7c7c3dcfb6 100644 +--- a/src/basic/sysctl-util.c ++++ b/src/basic/sysctl-util.c +@@ -93,7 +93,7 @@ int sysctl_write_ip_property(int af, const char *ifname, const char *property, c + + log_debug("Setting '%s' to '%s'", p, value); + +- return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | 0); + } + + int sysctl_read(const char *property, char **content) { +diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c +index 39ab554290..d0e566645d 100644 +--- a/src/sleep/sleep.c ++++ b/src/sleep/sleep.c +@@ -48,7 +48,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca + assert(hibernate_location->swap); + + xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); +- r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/power/resume", resume_str, 0); + if (r < 0) + return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", + hibernate_location->swap->device, resume_str); +@@ -75,7 +75,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca + } + + xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); +- r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/power/resume_offset", offset_str, 0); + if (r < 0) + return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", + hibernate_location->swap->device, offset_str); +@@ -92,7 +92,7 @@ static int write_mode(char **modes) { + STRV_FOREACH(mode, modes) { + int k; + +- k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); ++ k = write_string_file("/sys/power/disk", *mode, 0); + if (k >= 0) + return 0; + +@@ -114,7 +114,7 @@ static int write_state(FILE **f, char **states) { + STRV_FOREACH(state, states) { + int k; + +- k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); ++ k = write_string_stream(*f, *state, 0); + if (k >= 0) + return 0; + log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state); +diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c +index b28e2853e1..115b7233a0 100644 +--- a/src/vconsole/vconsole-setup.c ++++ b/src/vconsole/vconsole-setup.c +@@ -116,7 +116,7 @@ static int toggle_utf8_vc(const char *name, int fd, bool utf8) { + static int toggle_utf8_sysfs(bool utf8) { + int r; + +- r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); + if (r < 0) + return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); + +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0026-Handle-missing-gshadow-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0026-Handle-missing-gshadow-openeuler.patch new file mode 100644 index 00000000000..1aadd072cad --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0026-Handle-missing-gshadow-openeuler.patch @@ -0,0 +1,174 @@ +From 47bf88f74717b417e4adbcc04256334b2335c873 Mon Sep 17 00:00:00 2001 +From: Alex Kiernan +Date: Tue, 10 Mar 2020 11:05:20 +0000 +Subject: [PATCH 26/26] Handle missing gshadow + +gshadow usage is now present in the userdb code. Mask all uses of it to +allow compilation on musl + +Upstream-Status: Inappropriate [musl specific] +Signed-off-by: Alex Kiernan +[Rebased for v247] +Signed-off-by: Luca Boccassi +--- + src/shared/user-record-nss.c | 20 ++++++++++++++++++++ + src/shared/user-record-nss.h | 4 ++++ + src/shared/userdb.c | 6 ++++++ + 3 files changed, 30 insertions(+) + +diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c +index 88b8fc2f8f..a819d41bac 100644 +--- a/src/shared/user-record-nss.c ++++ b/src/shared/user-record-nss.c +@@ -331,8 +331,10 @@ int nss_group_to_group_record( + if (isempty(grp->gr_name)) + return -EINVAL; + ++#if ENABLE_GSHADOW + if (sgrp && !streq_ptr(sgrp->sg_namp, grp->gr_name)) + return -EINVAL; ++#endif + + g = group_record_new(); + if (!g) +@@ -348,6 +350,7 @@ int nss_group_to_group_record( + + g->gid = grp->gr_gid; + ++#if ENABLE_GSHADOW + if (sgrp) { + if (looks_like_hashed_password(utf8_only(sgrp->sg_passwd))) { + g->hashed_password = strv_new(sgrp->sg_passwd); +@@ -363,6 +366,7 @@ int nss_group_to_group_record( + if (r < 0) + return r; + } ++#endif + + r = json_build(&g->json, JSON_BUILD_OBJECT( + JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)), +@@ -388,6 +392,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re + assert(ret_sgrp); + assert(ret_buffer); + ++#if ENABLE_GSHADOW + for (;;) { + _cleanup_free_ char *buf = NULL; + struct sgrp sgrp, *result; +@@ -416,6 +421,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re + buflen *= 2; + buf = mfree(buf); + } ++#else ++ return -ESRCH; ++#endif + } + + int nss_group_record_by_name( +@@ -427,7 +435,9 @@ int nss_group_record_by_name( + struct group grp, *result; + bool incomplete = false; + size_t buflen = 4096; ++#if ENABLE_GSHADOW + struct sgrp sgrp, *sresult = NULL; ++#endif + int r; + + assert(name); +@@ -457,6 +467,7 @@ int nss_group_record_by_name( + buf = mfree(buf); + } + ++#if ENABLE_GSHADOW + if (with_shadow) { + r = nss_sgrp_for_group(result, &sgrp, &sbuf); + if (r < 0) { +@@ -468,6 +479,9 @@ int nss_group_record_by_name( + incomplete = true; + + r = nss_group_to_group_record(result, sresult, ret); ++#else ++ r = nss_group_to_group_record(result, NULL, ret); ++#endif + if (r < 0) + return r; + +@@ -484,7 +498,9 @@ int nss_group_record_by_gid( + struct group grp, *result; + bool incomplete = false; + size_t buflen = 4096; ++#if ENABLE_GSHADOW + struct sgrp sgrp, *sresult = NULL; ++#endif + int r; + + assert(ret); +@@ -512,6 +528,7 @@ int nss_group_record_by_gid( + buf = mfree(buf); + } + ++#if ENABLE_GSHADOW + if (with_shadow) { + r = nss_sgrp_for_group(result, &sgrp, &sbuf); + if (r < 0) { +@@ -523,6 +540,9 @@ int nss_group_record_by_gid( + incomplete = true; + + r = nss_group_to_group_record(result, sresult, ret); ++#else ++ r = nss_group_to_group_record(result, NULL, ret); ++#endif + if (r < 0) + return r; + +diff --git a/src/shared/user-record-nss.h b/src/shared/user-record-nss.h +index 22ab04d6ee..4e52e7a911 100644 +--- a/src/shared/user-record-nss.h ++++ b/src/shared/user-record-nss.h +@@ -2,7 +2,11 @@ + #pragma once + + #include ++#if ENABLE_GSHADOW + #include ++#else ++struct sgrp; ++#endif + #include + #include + +diff --git a/src/shared/userdb.c b/src/shared/userdb.c +index 2d480283d1..0d19764f2e 100644 +--- a/src/shared/userdb.c ++++ b/src/shared/userdb.c +@@ -1047,7 +1047,9 @@ int groupdb_iterator_get(UserDBIterator + if (gr) { + _cleanup_free_ char *buffer = NULL; + bool incomplete = false; ++#if ENABLE_GSHADOW + struct sgrp sgrp; ++#endif + + if (streq_ptr(gr->gr_name, "root")) + iterator->synthesize_root = false; +@@ -1055,6 +1057,7 @@ int groupdb_iterator_get(UserDBIterator + iterator->synthesize_nobody = false; + ++#if ENABLE_GSHADOW + if (!FLAGS_SET(iterator->flags, USERDB_SUPPRESS_SHADOW)) { + r = nss_sgrp_for_group(gr, &sgrp, &buffer); + if (r < 0) { + log_debug_errno(r, "Failed to acquire shadow entry for group %s, ignoring: %m", gr->gr_name); +@@ -1066,6 +1069,9 @@ int groupdb_iterator_get(UserDBIterator + } + + r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret); ++#else ++ r = nss_group_to_group_record(gr, NULL, ret); ++#endif + if (r < 0) + return r; + +-- +2.27.0 + diff --git a/meta-openeuler/recipes-core/systemd/files/0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl-openeuler.patch b/meta-openeuler/recipes-core/systemd/files/0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl-openeuler.patch new file mode 100644 index 00000000000..6e8334ef4a2 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl-openeuler.patch @@ -0,0 +1,36 @@ +From 7b32582c066549fea0f7180a6c575e7fa37a867f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 12 Apr 2021 23:44:53 -0700 +Subject: [PATCH] missing_syscall.h: Define MIPS ABI defines for musl + +musl does not define _MIPS_SIM_ABI32, _MIPS_SIM_NABI32, _MIPS_SIM_ABI64 +unlike glibc where these are provided by libc headers, therefore define +them here in case they are undefined + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + src/basic/missing_syscall.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h +index 0594a1b930..495d161334 100644 +--- a/src/basic/missing_syscall.h ++++ b/src/basic/missing_syscall.h +@@ -20,6 +20,12 @@ + #include + #endif + ++#ifndef _MIPS_SIM_ABI32 ++#define _MIPS_SIM_ABI32 1 ++#define _MIPS_SIM_NABI32 2 ++#define _MIPS_SIM_ABI64 3 ++#endif ++ + #include "missing_keyctl.h" + #include "missing_stat.h" + #include "missing_syscall_def.h" +-- +2.31.1 + diff --git a/meta-openeuler/recipes-core/systemd/files/systemd-musl.patch b/meta-openeuler/recipes-core/systemd/files/systemd-musl.patch new file mode 100644 index 00000000000..5d618909608 --- /dev/null +++ b/meta-openeuler/recipes-core/systemd/files/systemd-musl.patch @@ -0,0 +1,44 @@ +--- a/src/basic/percent-util.c 2022-09-27 18:00:07.812728549 +0800 ++++ b/src/basic/percent-util.c 2022-09-27 23:23:43.000326791 +0800 +@@ -3,6 +3,7 @@ + #include "percent-util.h" + #include "string-util.h" + #include "parse-util.h" ++#include "missing_stdlib.h" + + static int parse_parts_value_whole(const char *p, const char *symbol) { + const char *pc, *n; + +--- a/src/network/networkd-setlink.c 2022-09-28 09:33:59.989482374 +0800 ++++ b/src/network/networkd-setlink.c 2022-09-28 09:36:56.739808113 +0800 +@@ -2,7 +2,6 @@ + + #include + #include +-#include + + #include "missing_network.h" + #include "netlink-util.h" + +--- a/src/network/networkd-link.c 2022-09-28 09:38:52.390672185 +0800 ++++ b/src/network/networkd-link.c 2022-09-28 09:39:24.402911366 +0800 +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + + #include "alloc-util.h" + #include "batadv.h" + +--- a/src/basic/rlimit-util.c 2022-09-28 09:52:03.493582837 +0800 ++++ b/arc/basic/rlimit-util.c 2022-09-28 09:53:46.209350273 +0800 +@@ -43,7 +43,7 @@ int setrlimit_closest(int resource, cons + fixed.rlim_max == highest.rlim_max) + return 0; + +- log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", rlim->rlim_max, rlimit_to_string(resource), fixed.rlim_max); ++ log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", (uintmax_t)rlim->rlim_max, rlimit_to_string(resource), (uintmax_t)fixed.rlim_max); + + if (setrlimit(resource, &fixed) < 0) + return -errno; diff --git a/meta-openeuler/recipes-core/systemd/systemd_%.bbappend b/meta-openeuler/recipes-core/systemd/systemd_%.bbappend index b90f12734af..f4761298805 100644 --- a/meta-openeuler/recipes-core/systemd/systemd_%.bbappend +++ b/meta-openeuler/recipes-core/systemd/systemd_%.bbappend @@ -69,3 +69,32 @@ pkg_postinst_udev-hwdb () { : } +SRC_URI_remove_libc-musl += " ${SRC_URI_MUSL}" + +SRC_URI_append_libc-musl += " \ + file://0002-don-t-use-glibc-specific-qsort_r-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0004-add-fallback-parse_printf_format-implementation-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0005-src-basic-missing.h-check-for-missing-strndupa-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0006-Include-netinet-if_ether.h-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0008-add-missing-FTW_-macros-for-musl.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0009-fix-missing-of-__register_atfork-for-non-glibc-build.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0010-Use-uintmax_t-for-handling-rlim_t.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0011-test-sizeof.c-Disable-tests-for-missing-typedefs-in-.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0014-Do-not-disable-buffering-when-writing-to-oom_score_a.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0016-Hide-__start_BUS_ERROR_MAP-and-__stop_BUS_ERROR_MAP.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0017-missing_type.h-add-__compar_d_fn_t-definition.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0018-avoid-redefinition-of-prctl_mm_map-structure.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0019-Handle-missing-LOCK_EX.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0020-Fix-incompatible-pointer-type-struct-sockaddr_un.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0021-test-json.c-define-M_PIl.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0022-do-not-disable-buffer-in-writing-files-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0025-Handle-__cpu_mask-usage.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0026-Handle-missing-gshadow-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl-openeuler.patch;patchdir=${WORKDIR}/systemd-${PV} \ + file://systemd-musl.patch;patchdir=${WORKDIR}/systemd-${PV} \ +" -- Gitee From 165a83defc300fcb1a4991eeb5f168294bb064e0 Mon Sep 17 00:00:00 2001 From: Zhang Limin Date: Sun, 9 Oct 2022 09:21:58 +0000 Subject: [PATCH 19/35] musl: libxml-parser-perl * libxml-parser-perl for musl * modify config file Signed-off-by: zhanglimin --- .../recipes-devtools/perl/libxml-parser-perl_%.bbappend | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta-openeuler/recipes-devtools/perl/libxml-parser-perl_%.bbappend b/meta-openeuler/recipes-devtools/perl/libxml-parser-perl_%.bbappend index 771bc8a4423..ffb31024cd5 100644 --- a/meta-openeuler/recipes-devtools/perl/libxml-parser-perl_%.bbappend +++ b/meta-openeuler/recipes-devtools/perl/libxml-parser-perl_%.bbappend @@ -11,3 +11,7 @@ SRC_URI_prepend =+ " \ SRC_URI_remove += " \ http://www.cpan.org/modules/by-module/XML/XML-Parser-${PV}.tar.gz \ " +do_configure_append_libc-musl () { + sed -i 's/\-m64/\ /g' ${S}/Makefile + sed -i 's/\-m64/\ /g' ${S}/Expat/Makefile +} -- Gitee From c3da5244bcb2eaf1393682ecda9650b77f7d3b69 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 14 Oct 2022 09:34:32 +0800 Subject: [PATCH 20/35] musl: modify musl bb file * modify do_install and variables Signed-off-by: zhangfei --- meta-openeuler/recipes-external/musl/musl_1.2.3.bb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index 9e9c29eabd6..128e489bb4b 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -13,20 +13,15 @@ PACKAGES = "${PN} ${PN}-dev ${PN}-staticdev" PROVIDES += "virtual/libc virtual/libiconv virtual/libintl virtual/crypt" -DEPENDS = "virtual/${TARGET_PREFIX}gcc \ - bsd-headers \ +DEPENDS = "bsd-headers \ " INHIBIT_DEFAULT_DEPS = "1" PR = "r1" -SRC_URI = "file://aarch64-openeuler-linux-musl" - INHIBIT_SYSROOT_STRIP = "1" INSANE_SKIP_${PN} += "already-stripped" -S = "${WORKDIR}/aarch64-openeuler-linux-musl" - PSEUDO_DISABLED = "1" do_configure() { @@ -42,7 +37,7 @@ do_install() { install -m 0755 -d ${D}/ install -m 0755 -d ${D}/${base_libdir} install -m 0755 -d ${D}/${libdir} - cp -pPR ${S}/aarch64-openeuler-linux-musl/sysroot/* ${D}/ + cp -pPR ${EXTERNAL_TOOLCHAIN}/aarch64-openeuler-linux-musl/sysroot/* ${D}/ chmod -R 755 ${D}/${base_libdir} chmod -R 755 ${D}/${libdir} rm -rf ${D}/etc/rpc @@ -69,4 +64,3 @@ INSANE_SKIP += "dev-elf dev-so" SYSROOT_DIRS += "/*" - -- Gitee From 38d7a84d716815947b18e5c7702548c623229d6f Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 14 Oct 2022 16:09:37 +0800 Subject: [PATCH 21/35] musl: isulad * modify isulad bb file and add patch * add libexecinfo and libmallocutils Signed-off-by: zhangfei --- .../isulad/isulad/isulad-musl.patch | 532 ++++++++++++++++++ .../recipes-core/isulad/isulad_%.bbappend | 12 + .../recipes-external/musl/libexecinfo.bb | 35 ++ .../musl/libexecinfo/execinfo.c | 85 +++ .../musl/libexecinfo/execinfo.h | 9 + .../recipes-external/musl/libmallocutils.bb | 36 ++ .../musl/libmallocutils/malloc_utils.c | 13 + .../musl/libmallocutils/malloc_utils.h | 19 + 8 files changed, 741 insertions(+) create mode 100644 meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch create mode 100644 meta-openeuler/recipes-core/isulad/isulad_%.bbappend create mode 100644 meta-openeuler/recipes-external/musl/libexecinfo.bb create mode 100644 meta-openeuler/recipes-external/musl/libexecinfo/execinfo.c create mode 100644 meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h create mode 100644 meta-openeuler/recipes-external/musl/libmallocutils.bb create mode 100644 meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.c create mode 100644 meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h diff --git a/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch b/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch new file mode 100644 index 00000000000..1ea3a729351 --- /dev/null +++ b/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch @@ -0,0 +1,532 @@ +--- iSulad-v2.0.16/src/client/connect/protocol_type.h 2022-09-19 09:11:13.599835541 +0800 ++++ iSulad-v2.0.16/src/client/connect/protocol_type.h 2022-09-19 09:14:51.844509875 +0800 +@@ -54,11 +54,11 @@ struct isula_create_response { + + struct isula_start_request { + char *name; +- char *stdin; ++ char *stdin1; + bool attach_stdin; +- char *stdout; ++ char *stdout1; + bool attach_stdout; +- char *stderr; ++ char *stderr1; + bool attach_stderr; + }; + +@@ -323,9 +323,9 @@ struct isula_exec_request { + bool attach_stdin; + bool attach_stdout; + bool attach_stderr; +- char *stdin; +- char *stdout; +- char *stderr; ++ char *stdin1; ++ char *stdout1; ++ char *stderr1; + int argc; + char **argv; + size_t env_len; +@@ -344,9 +344,9 @@ struct isula_exec_response { + + struct isula_attach_request { + char *name; +- char *stdin; +- char *stdout; +- char *stderr; ++ char *stdin1; ++ char *stdout1; ++ char *stderr1; + bool attach_stdin; + bool attach_stdout; + bool attach_stderr; + +--- iSulad-v2.0.16/src/client/connect/protocol_type.c 2022-09-19 09:21:57.492775372 +0800 ++++ iSulad-v2.0.16/src/client/connect/protocol_type.c 2022-09-19 09:23:54.711674661 +0800 +@@ -280,14 +280,14 @@ void isula_start_request_free(struct isu + free(request->name); + request->name = NULL; + +- free(request->stdin); +- request->stdin = NULL; ++ free(request->stdin1); ++ request->stdin1 = NULL; + +- free(request->stdout); +- request->stdout = NULL; ++ free(request->stdout1); ++ request->stdout1 = NULL; + +- free(request->stderr); +- request->stderr = NULL; ++ free(request->stderr1); ++ request->stderr1 = NULL; + + free(request); + } +@@ -513,14 +513,14 @@ void isula_exec_request_free(struct isul + free(request->suffix); + request->suffix = NULL; + +- free(request->stdout); +- request->stdout = NULL; ++ free(request->stdout1); ++ request->stdout1 = NULL; + +- free(request->stdin); +- request->stdin = NULL; ++ free(request->stdin1); ++ request->stdin1 = NULL; + +- free(request->stderr); +- request->stderr = NULL; ++ free(request->stderr1); ++ request->stderr1 = NULL; + + free(request->user); + request->user = NULL; +@@ -562,14 +562,14 @@ void isula_attach_request_free(struct is + free(request->name); + request->name = NULL; + +- free(request->stderr); +- request->stderr = NULL; ++ free(request->stderr1); ++ request->stderr1 = NULL; + +- free(request->stdout); +- request->stdout = NULL; ++ free(request->stdout1); ++ request->stdout1 = NULL; + +- free(request->stdin); +- request->stdin = NULL; ++ free(request->stdin1); ++ request->stdin1 = NULL; + + free(request); + } + +--- iSulad-v2.0.16/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:27:58.672546293 +0800 ++++ iSulad-v2.0.16/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:38:59.355614190 +0800 +@@ -87,14 +87,14 @@ static int start_request_to_rest(const s + if (ls_request->name != NULL) { + crequest->id = util_strdup_s(ls_request->name); + } +- if (ls_request->stdout != NULL) { +- crequest->stdout = util_strdup_s(ls_request->stdout); ++ if (ls_request->stdout1 != NULL) { ++ crequest->stdout1 = util_strdup_s(ls_request->stdout1); + } +- if (ls_request->stdin != NULL) { +- crequest->stdin = util_strdup_s(ls_request->stdin); ++ if (ls_request->stdin1 != NULL) { ++ crequest->stdin1 = util_strdup_s(ls_request->stdin1); + } +- if (ls_request->stderr != NULL) { +- crequest->stderr = util_strdup_s(ls_request->stderr); ++ if (ls_request->stderr1 != NULL) { ++ crequest->stderr1 = util_strdup_s(ls_request->stderr1); + } + crequest->attach_stdin = ls_request->attach_stdin; + crequest->attach_stdout = ls_request->attach_stdout; +@@ -207,14 +207,14 @@ static int attach_request_to_rest(const + if (la_request->name != NULL) { + crequest->container_id = util_strdup_s(la_request->name); + } +- if (la_request->stdout != NULL) { +- crequest->stdout = util_strdup_s(la_request->stdout); ++ if (la_request->stdout1 != NULL) { ++ crequest->stdout1 = util_strdup_s(la_request->stdout1); + } +- if (la_request->stdin != NULL) { +- crequest->stdin = util_strdup_s(la_request->stdin); ++ if (la_request->stdin1 != NULL) { ++ crequest->stdin1 = util_strdup_s(la_request->stdin1); + } +- if (la_request->stderr != NULL) { +- crequest->stderr = util_strdup_s(la_request->stderr); ++ if (la_request->stderr1 != NULL) { ++ crequest->stderr1 = util_strdup_s(la_request->stderr1); + } + crequest->attach_stdin = la_request->attach_stdin; + crequest->attach_stdout = la_request->attach_stdout; +@@ -1611,14 +1611,14 @@ static int exec_request_to_rest(const st + if (le_request->name != NULL) { + crequest->container_id = util_strdup_s(le_request->name); + } +- if (le_request->stdout != NULL) { +- crequest->stdout = util_strdup_s(le_request->stdout); ++ if (le_request->stdout1 != NULL) { ++ crequest->stdout1 = util_strdup_s(le_request->stdout1); + } +- if (le_request->stdin != NULL) { +- crequest->stdin = util_strdup_s(le_request->stdin); ++ if (le_request->stdin1 != NULL) { ++ crequest->stdin1 = util_strdup_s(le_request->stdin1); + } +- if (le_request->stderr != NULL) { +- crequest->stderr = util_strdup_s(le_request->stderr); ++ if (le_request->stderr1 != NULL) { ++ crequest->stderr1 = util_strdup_s(le_request->stderr1); + } + if (le_request->suffix != NULL) { + crequest->suffix = util_strdup_s(le_request->suffix); + +--- iSulad-v2.0.16/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:43:42.136783044 +0800 ++++ iSulad-v2.0.16/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:42:58.598449116 +0800 +@@ -487,8 +487,8 @@ int rt_lcr_attach(const char *name, cons + goto out; + } + +- if (!engine_ops->engine_console_op(name, params->rootpath, (char *)params->stdin, (char *)params->stdout, +- (char *)params->stderr)) { ++ if (!engine_ops->engine_console_op(name, params->rootpath, (char *)params->stdin1, (char *)params->stdout1, ++ (char *)params->stderr1)) { + ERROR("attach failed"); + const char *tmpmsg = NULL; + if (engine_ops->engine_get_errmsg_op != NULL) { + +--- iSulad-v2.0.16/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:46:39.902146450 +0800 ++++ iSulad-v2.0.16/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:47:47.711666534 +0800 +@@ -834,9 +834,9 @@ int rt_isula_create(const char *id, cons + p.exit_fifo = (char *)params->exit_fifo; + p.open_tty = params->tty; + p.open_stdin = params->open_stdin; +- p.isulad_stdin = (char *)params->stdin; +- p.isulad_stdout = (char *)params->stdout; +- p.isulad_stderr = (char *)params->stderr; ++ p.isulad_stdin = (char *)params->stdin1; ++ p.isulad_stdout = (char *)params->stdout1; ++ p.isulad_stderr = (char *)params->stderr1; + p.runtime_args = (char **)runtime_args; + p.runtime_args_len = runtime_args_len; + copy_process(&p, config->process); +@@ -1343,4 +1343,4 @@ int rt_isula_kill(const char *id, const + } + + return 0; +-} +\ No newline at end of file ++} + +--- iSulad-v2.0.16/src/daemon/executor/container_cb/execution.c 2022-09-19 09:49:53.940634672 +0800 ++++ iSulad-v2.0.16/src/daemon/executor/container_cb/execution.c 2022-09-19 09:50:50.743070321 +0800 +@@ -270,7 +270,7 @@ static int prepare_start_io(container_t + goto out; + } + +- if (ready_copy_io_data(*sync_fd, false, request->stdin, request->stdout, request->stderr, stdinfd, ++ if (ready_copy_io_data(*sync_fd, false, request->stdin1, request->stdout1, request->stderr1, stdinfd, + stdout_handler, stderr_handler, (const char **)fifos, thread_id)) { + ret = -1; + goto out; + +--- iSulad-v2.0.16/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:52:35.190871412 +0800 ++++ iSulad-v2.0.16/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:54:16.304646931 +0800 +@@ -266,7 +266,7 @@ static int attach_prepare_console(const + goto out; + } + +- if (ready_copy_io_data(*sync_fd, false, request->stdin, request->stdout, request->stderr, stdinfd, ++ if (ready_copy_io_data(*sync_fd, false, request->stdin1, request->stdout1, request->stderr1, stdinfd, + stdout_handler, stderr_handler, (const char **)fifos, tid)) { + ret = -1; + goto out; +@@ -342,9 +342,9 @@ static int container_attach_cb(const con + } + + params.rootpath = cont->root_path; +- params.stdin = fifos[0]; +- params.stdout = fifos[1]; +- params.stderr = fifos[2]; ++ params.stdin1 = fifos[0]; ++ params.stdout1 = fifos[1]; ++ params.stderr1 = fifos[2]; + + (void)isulad_monitor_send_container_event(id, ATTACH, -1, 0, NULL, NULL); + +--- iSulad-v2.0.16/src/daemon/modules/api/runtime_api.h 2022-09-19 10:21:19.315094981 +0800 ++++ iSulad-v2.0.16/src/daemon/modules/api/runtime_api.h 2022-09-19 10:23:19.310015312 +0800 +@@ -70,9 +70,9 @@ typedef struct _rt_create_params_t { + const char *state; + void *oci_config_data; + bool terminal; +- const char *stdin; +- const char *stdout; +- const char *stderr; ++ const char *stdin1; ++ const char *stdout1; ++ const char *stderr1; + const char *exit_fifo; + bool tty; + bool open_stdin; +@@ -156,9 +156,9 @@ typedef struct _rt_resume_params_t { + + typedef struct _rt_attach_params_t { + const char *rootpath; +- const char *stdin; +- const char *stdout; +- const char *stderr; ++ const char *stdin1; ++ const char *stdout1; ++ const char *stderr1; + } rt_attach_params_t; + + typedef struct _rt_update_params_t { + +--- iSulad-v2.0.16/src/daemon/modules/service/service_container.c 2022-09-19 10:45:35.318254990 +0800 ++++ iSulad-v2.0.16/src/daemon/modules/service/service_container.c 2022-09-19 10:47:35.547173581 +0800 +@@ -825,9 +825,9 @@ static int do_start_container(container_ + create_params.state = cont->state_path; + create_params.oci_config_data = oci_spec; + create_params.terminal = tty; +- create_params.stdin = console_fifos[0]; +- create_params.stdout = console_fifos[1]; +- create_params.stderr = console_fifos[2]; ++ create_params.stdin1 = console_fifos[0]; ++ create_params.stdout1 = console_fifos[1]; ++ create_params.stderr1 = console_fifos[2]; + create_params.exit_fifo = exit_fifo; + create_params.tty = tty; + create_params.open_stdin = open_stdin; +@@ -1886,7 +1886,7 @@ static int exec_prepare_console(const co + ret = -1; + goto out; + } +- if (ready_copy_io_data(*sync_fd, false, request->stdin, request->stdout, request->stderr, stdinfd, ++ if (ready_copy_io_data(*sync_fd, false, request->stdin1, request->stdout1, request->stderr1, stdinfd, + stdout_handler, stderr_handler, (const char **)fifos, thread_id)) { + ret = -1; + goto out; + +--- iSulad-v2.0.16/src/cmd/isula/base/start.c 2022-09-19 11:16:14.838156121 +0800 ++++ iSulad-v2.0.16/src/cmd/isula/base/start.c 2022-09-19 11:18:12.374049157 +0800 +@@ -124,9 +124,9 @@ static int do_client_start(const struct + + request.name = args->name; + if (console_fifos != NULL && *console_fifos != NULL) { +- request.stdin = (*console_fifos)->stdin_name; +- request.stdout = (*console_fifos)->stdout_name; +- request.stderr = (*console_fifos)->stderr_name; ++ request.stdin1 = (*console_fifos)->stdin_name; ++ request.stdout1 = (*console_fifos)->stdout_name; ++ request.stderr1 = (*console_fifos)->stderr_name; + } + request.attach_stdin = args->custom_conf.attach_stdin; + request.attach_stdout = args->custom_conf.attach_stdout; + +--- iSulad-v2.0.16/src/cmd/isula/stream/exec.c 2022-09-19 11:22:01.760792010 +0800 ++++ iSulad-v2.0.16/src/cmd/isula/stream/exec.c 2022-09-19 11:22:29.969006333 +0800 +@@ -60,9 +60,9 @@ static int fill_exec_request(const struc + request->attach_stdout = args->custom_conf.attach_stdout; + request->attach_stderr = args->custom_conf.attach_stderr; + if (fifos != NULL) { +- request->stdin = util_strdup_s(fifos->stdin_name); +- request->stdout = util_strdup_s(fifos->stdout_name); +- request->stderr = util_strdup_s(fifos->stderr_name); ++ request->stdin1 = util_strdup_s(fifos->stdin_name); ++ request->stdout1 = util_strdup_s(fifos->stdout_name); ++ request->stderr1 = util_strdup_s(fifos->stderr_name); + } + + request->user = util_strdup_s(args->custom_conf.user); + +--- iSulad-v2.0.16/src/cmd/isula/stream/attach.c 2022-09-19 11:23:59.246684654 +0800 ++++ iSulad-v2.0.16/src/cmd/isula/stream/attach.c 2022-09-19 11:24:48.674060200 +0800 +@@ -398,9 +398,9 @@ static int client_attach(struct client_a + ret = ECOMMON; + goto out; + } +- request.stdin = util_strdup_s(attach_fifos->stdin_name); +- request.stdout = util_strdup_s(attach_fifos->stdout_name); +- request.stderr = util_strdup_s(attach_fifos->stderr_name); ++ request.stdin1 = util_strdup_s(attach_fifos->stdin_name); ++ request.stdout1 = util_strdup_s(attach_fifos->stdout_name); ++ request.stderr1 = util_strdup_s(attach_fifos->stderr_name); + #endif + + config = get_connect_config(args); + +--- iSulad-v2.0.16/src/CMakeLists.txt 2022-09-19 14:44:22.526007835 +0800 ++++ iSulad-v2.0.16/src/CMakeLists.txt 2022-09-19 14:43:07.452410938 +0800 +@@ -49,6 +49,7 @@ target_include_directories(libisulad_too + ) + set_target_properties(libisulad_tools PROPERTIES PREFIX "") + target_link_libraries(libisulad_tools ${ZLIB_LIBRARY} ${ISULA_LIBUTILS_LIBRARY} ${CRYPTO_LIBRARY}) ++target_link_libraries(libisulad_tools -lexecinfo -lmallocutils) + + if (ENABLE_OCI_IMAGE) + target_link_libraries(libisulad_tools ${LIBARCHIVE_LIBRARY}) + +--- iSulad-v2.0.16/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:24:19.359973622 +0800 ++++ iSulad-v2.0.16/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:44:38.957115144 +0800 +@@ -26,6 +26,8 @@ + #include + #include + #include ++#include ++#include + + #include "isula_libutils/log.h" + #include "err_msg.h" +@@ -42,6 +44,147 @@ + #define UnixPasswdPath "/etc/passwd" + #define UnixGroupPath "/etc/group" + ++static pthread_mutex_t pwent_mutex = PTHREAD_MUTEX_INITIALIZER; ++static int __fgetpwent_r(FILE *stream, struct passwd *pwd, char *buf, ++ size_t len, struct passwd **result) ++{ ++ struct passwd *pwtmp; ++ char *cursor = buf, *end = buf + len; ++ ++ *result = NULL; ++ pthread_mutex_lock(&pwent_mutex); ++ pwtmp = stream != NULL ? fgetpwent(stream) : getpwent(); ++ if (pwtmp == NULL) { ++ pthread_mutex_unlock(&pwent_mutex); ++ return ENOENT; ++ } ++ memcpy(pwd, pwtmp, sizeof(*pwd)); ++ if (pwtmp->pw_name != NULL) { ++ pwd->pw_name = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_name, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_passwd != NULL) { ++ pwd->pw_passwd = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_passwd, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_gecos != NULL) { ++ pwd->pw_gecos = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_gecos, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_dir != NULL) { ++ pwd->pw_dir = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_dir, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (pwtmp->pw_shell != NULL) { ++ pwd->pw_shell = cursor; ++ cursor += strlcpy(cursor, pwtmp->pw_shell, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ pthread_mutex_unlock(&pwent_mutex); ++ *result = pwd; ++ ++ return 0; ++err_unlock: ++ pthread_mutex_unlock(&pwent_mutex); ++ return ERANGE; ++} ++ ++int fgetpwent_r(FILE *stream, struct passwd *pwd, char *buf, size_t len, ++ struct passwd **result) ++{ ++ assert(stream != NULL); ++ ++ return __fgetpwent_r(stream, pwd, buf, len, result); ++} ++ ++#define ALIGN_PTR_TO_SIZE_OF(ptr, type) \ ++ ((type *) ((((uintptr_t)(ptr)) + sizeof(type) - 1) \ ++ & ~(sizeof(type) - 1))) ++ ++static pthread_mutex_t grent_mutex = PTHREAD_MUTEX_INITIALIZER; ++ ++static int __fgetgrent_r(FILE *stream, struct group *grp, char *buf, size_t len, ++ struct group **result) ++{ ++ struct group *grtmp; ++ char *cursor = buf, *end = buf + len; ++ ++ *result = NULL; ++ pthread_mutex_lock(&grent_mutex); ++ grtmp = stream != NULL ? fgetgrent(stream) : getgrent(); ++ if (grtmp == NULL) { ++ pthread_mutex_unlock(&grent_mutex); ++ return ENOENT; ++ } ++ memcpy(grp, grtmp, sizeof(*grp)); ++ if (grtmp->gr_name != NULL) { ++ grp->gr_name = cursor; ++ cursor += strlcpy(cursor, grtmp->gr_name, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (grtmp->gr_passwd != NULL) { ++ grp->gr_passwd = cursor; ++ cursor += strlcpy(cursor, grtmp->gr_passwd, end - cursor) + 1; ++ if (cursor > end) { ++ goto err_unlock; ++ } ++ } ++ if (grtmp->gr_mem != NULL) { ++ char **members = ALIGN_PTR_TO_SIZE_OF(cursor, char *); ++ ptrdiff_t nameslen = 0; ++ size_t nmem = 0; ++ ++ while (grtmp->gr_mem[nmem++] != NULL) { ++ nameslen += strlen(grtmp->gr_mem[nmem - 1]) + 1; ++ } ++ nameslen += nmem * sizeof(*members); ++ if (nameslen > end - ((char *) members)) { ++ goto err_unlock; ++ } ++ ++ for (size_t i = 0; i < nmem; ++i) { ++ members[i] = grtmp->gr_mem[i]; ++ } ++ ++ cursor = (char *) &members[nmem]; ++ for (size_t i = 0; i < nmem - 1; ++i) { ++ cursor = stpcpy(cursor, members[i]) + 1; ++ } ++ } ++ pthread_mutex_unlock(&grent_mutex); ++ *result = grp; ++ ++ return 0; ++ ++err_unlock: ++ pthread_mutex_unlock(&grent_mutex); ++ return ERANGE; ++} ++ ++int fgetgrent_r(FILE *stream, struct group *grp, char *buf, size_t len, ++ struct group **result) ++{ ++ assert(stream != NULL); ++ ++ return __fgetgrent_r(stream, grp, buf, len, result); ++} ++ + static void uids_gids_range_err_log() + { + ERROR("uids and gids must be in range 0-%lld", MAXUID); + +--- iSulad-v2.0.16/src/cmd/isulad/main.c 2022-10-14 14:04:50.303324243 +0800 ++++ iSulad-v2.0.16/src/cmd/isulad/main.c 2022-10-14 14:06:08.262895032 +0800 +@@ -40,6 +40,7 @@ + #include + #include + #include ++#include + #ifdef ENABLE_SUP_GROUPS + #include + #endif diff --git a/meta-openeuler/recipes-core/isulad/isulad_%.bbappend b/meta-openeuler/recipes-core/isulad/isulad_%.bbappend new file mode 100644 index 00000000000..2958a2d0f3e --- /dev/null +++ b/meta-openeuler/recipes-core/isulad/isulad_%.bbappend @@ -0,0 +1,12 @@ +# add libexecinfo libmallocutils DEPENDS to support musl +DEPENDS_append_libc-musl = " libexecinfo libmallocutils " + +SRC_URI_append_libc-musl = " \ + file://isulad-musl.patch \ +" + +do_configure_prepend_libc-musl () { + if grep -q "\-Werror" ${S}/cmake/set_build_flags.cmake ; then + sed -i 's/-Werror/-Werror -w/' ${S}/cmake/set_build_flags.cmake + fi +} diff --git a/meta-openeuler/recipes-external/musl/libexecinfo.bb b/meta-openeuler/recipes-external/musl/libexecinfo.bb new file mode 100644 index 00000000000..6a210f6fe3e --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libexecinfo.bb @@ -0,0 +1,35 @@ +SUMMARY = "libexecinfo for musl" +LICENSE="CLOSED" +LIC_FILES_CHKSUM="" +SECTION = "libs" + +SRC_URI = " \ + file://execinfo.c \ + file://execinfo.h \ +" + +DEPENDS = "virtual/${TARGET_PREFIX}binutils \ + virtual/${TARGET_PREFIX}gcc \ +" + +do_configure[noexec] = "1" + +S = "${WORKDIR}" + +do_compile() { + ${CC} -fpic -O2 -Wno-frame-address -Wno-unused-parameter -std=c99 -c execinfo.c -o execinfo.So + ${CC} -shared -Wl,-soname,libexecinfo.so.1 -o libexecinfo.so.1 execinfo.So + + ${CC} -O2 -Wno-frame-address -Wno-unused-parameter -std=c99 -c execinfo.c + ${AR} rcs libexecinfo.a execinfo.o +} +do_install() { + install -D -m755 libexecinfo.so.1 ${D}${libdir}/libexecinfo.so.1 + install -D -m644 libexecinfo.a ${D}${libdir}/libexecinfo.a + install -D -m644 execinfo.h ${D}${includedir}/execinfo.h +} + +# +# We will skip parsing for non-musl systems +# +COMPATIBLE_HOST = ".*-musl.*" diff --git a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.c b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.c new file mode 100644 index 00000000000..0de2ed0a117 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.c @@ -0,0 +1,85 @@ +#define _GNU_SOURCE +#define _BSD_SOURCE + +#include +#include +#include +#include +#include +#include + +#define get_frame_level(array, size, n) \ + do { \ + if (n >= size || __builtin_frame_address(n) == NULL) { \ + return n; \ + } \ + void *address = __builtin_return_address(n); \ + array[n] = __builtin_extract_return_addr(address); \ + if ((uintptr_t) array[n] < 0x1000) { \ + return n; \ + } \ + } while (0) + +int backtrace(void **array, int size) +{ + get_frame_level(array, size, 0); + get_frame_level(array, size, 1); + get_frame_level(array, size, 2); + get_frame_level(array, size, 3); + get_frame_level(array, size, 4); + get_frame_level(array, size, 5); + get_frame_level(array, size, 6); + get_frame_level(array, size, 7); + get_frame_level(array, size, 8); + get_frame_level(array, size, 9); + return 10; +} + +const char **backtrace_symbols(void *const *array, int size) +{ + const char **result = calloc(size, sizeof(char *)); + + if (result == NULL) { + return NULL; + } + for (int i = 0; i < size; ++i) { + Dl_info info; + + if (dladdr(array[i], &info) && info.dli_sname != NULL) { + result[i] = info.dli_sname; + } else { + result[i] = "??:0"; + } + } + + return result; +} + +void backtrace_symbols_fd(void *const *array, int size, int fd) +{ + for (int i = 0; i < size; ++i) { + Dl_info info; + const char *line; + int len; + + if (dladdr(array[i], &info) && info.dli_sname != NULL) { + line = info.dli_sname; + len = strlen(line); + } else { + line = "??:0"; + len = sizeof("??:0") - 1; + } + while (len > 0) { + int written = write(fd, line, len); + + if (written < 1) { + return; + } + line += written; + len -= written; + } + if (write(fd, "\n", 1) != 1) { + return; + } + } +} diff --git a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h new file mode 100644 index 00000000000..2e3675f172d --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif +int backtrace(void **, int); +char ** backtrace_symbols(void *const *, int); +void backtrace_symbols_fd(void *const *, int, int); +#ifdef __cplusplus +} +#endif diff --git a/meta-openeuler/recipes-external/musl/libmallocutils.bb b/meta-openeuler/recipes-external/musl/libmallocutils.bb new file mode 100644 index 00000000000..08ff1bdbf14 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libmallocutils.bb @@ -0,0 +1,36 @@ +SUMMARY = "mallopt and malloc_trim for musl" +LICENSE="CLOSED" +LIC_FILES_CHKSUM="" +SECTION = "libs" + +SRC_URI = " \ + file://malloc_utils.c \ + file://malloc_utils.h \ +" + +DEPENDS = "virtual/${TARGET_PREFIX}binutils \ + virtual/${TARGET_PREFIX}gcc \ +" + +do_configure[noexec] = "1" + +S = "${WORKDIR}" + +do_compile() { + ${CC} -fpic -O2 malloc_utils.c -c -o malloc_utils.So + ${CC} -shared -Wl,-soname,libmallocutils.so.1 -o libmallocutils.so.1 malloc_utils.So + + ${CC} -O2 -c malloc_utils.c + ${AR} rcs libmallocutils.a malloc_utils.o +} + +do_install() { + install -D -m755 libmallocutils.so.1 ${D}${libdir}/libmallocutils.so.1 + install -D -m644 libmallocutils.a ${D}${libdir}/libmallocutils.a + install -D -m644 malloc_utils.h ${D}${includedir}/malloc_utils.h +} + +# +# We will skip parsing for non-musl systems +# +COMPATIBLE_HOST = ".*-musl.*" diff --git a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.c b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.c new file mode 100644 index 00000000000..02e08b11e1b --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.c @@ -0,0 +1,13 @@ +#include + +int mallopt(int param_number, int value) +{ + /* This concept doesn't really map to musl's malloc */ + return 1; +} + +int malloc_trim(size_t pad) +{ + /* This concept doesn't really map to musl's malloc */ + return 1; +} diff --git a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h new file mode 100644 index 00000000000..5bb35013baa --- /dev/null +++ b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h @@ -0,0 +1,19 @@ +//#define __NEED_size_t +//#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define M_TRIM_THRESHOLD -1 +#define M_TOP_PAD -2 +#define M_MMAP_THRESHOLD -3 +#define M_ARENA_TEST -7 + +int mallopt(int param, int value); +int malloc_trim(size_t pad); + +#ifdef __cplusplus +} +#endif -- Gitee From 5812124c547073e0ecf100591e72af074f96d205 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Wed, 19 Oct 2022 09:54:22 +0800 Subject: [PATCH 22/35] musl: modify isulad-musl.patch * modify patch to adapt to the 2.0.17 version Signed-off-by: zhangfei --- .../isulad/isulad/isulad-musl.patch | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch b/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch index 1ea3a729351..4d2fc7e405a 100644 --- a/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch +++ b/meta-openeuler/recipes-core/isulad/isulad/isulad-musl.patch @@ -1,5 +1,5 @@ ---- iSulad-v2.0.16/src/client/connect/protocol_type.h 2022-09-19 09:11:13.599835541 +0800 -+++ iSulad-v2.0.16/src/client/connect/protocol_type.h 2022-09-19 09:14:51.844509875 +0800 +--- iSulad-v2.0.17/src/client/connect/protocol_type.h 2022-09-19 09:11:13.599835541 +0800 ++++ iSulad-v2.0.17/src/client/connect/protocol_type.h 2022-09-19 09:14:51.844509875 +0800 @@ -54,11 +54,11 @@ struct isula_create_response { struct isula_start_request { @@ -42,8 +42,8 @@ bool attach_stdout; bool attach_stderr; ---- iSulad-v2.0.16/src/client/connect/protocol_type.c 2022-09-19 09:21:57.492775372 +0800 -+++ iSulad-v2.0.16/src/client/connect/protocol_type.c 2022-09-19 09:23:54.711674661 +0800 +--- iSulad-v2.0.17/src/client/connect/protocol_type.c 2022-09-19 09:21:57.492775372 +0800 ++++ iSulad-v2.0.17/src/client/connect/protocol_type.c 2022-09-19 09:23:54.711674661 +0800 @@ -280,14 +280,14 @@ void isula_start_request_free(struct isu free(request->name); request->name = NULL; @@ -108,8 +108,8 @@ free(request); } ---- iSulad-v2.0.16/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:27:58.672546293 +0800 -+++ iSulad-v2.0.16/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:38:59.355614190 +0800 +--- iSulad-v2.0.17/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:27:58.672546293 +0800 ++++ iSulad-v2.0.17/src/client/connect/rest/rest_containers_client.c 2022-09-19 09:38:59.355614190 +0800 @@ -87,14 +87,14 @@ static int start_request_to_rest(const s if (ls_request->name != NULL) { crequest->id = util_strdup_s(ls_request->name); @@ -174,8 +174,8 @@ if (le_request->suffix != NULL) { crequest->suffix = util_strdup_s(le_request->suffix); ---- iSulad-v2.0.16/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:43:42.136783044 +0800 -+++ iSulad-v2.0.16/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:42:58.598449116 +0800 +--- iSulad-v2.0.17/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:43:42.136783044 +0800 ++++ iSulad-v2.0.17/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c 2022-09-19 09:42:58.598449116 +0800 @@ -487,8 +487,8 @@ int rt_lcr_attach(const char *name, cons goto out; } @@ -188,8 +188,8 @@ const char *tmpmsg = NULL; if (engine_ops->engine_get_errmsg_op != NULL) { ---- iSulad-v2.0.16/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:46:39.902146450 +0800 -+++ iSulad-v2.0.16/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:47:47.711666534 +0800 +--- iSulad-v2.0.17/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:46:39.902146450 +0800 ++++ iSulad-v2.0.17/src/daemon/modules/runtime/isula/isula_rt_ops.c 2022-09-19 09:47:47.711666534 +0800 @@ -834,9 +834,9 @@ int rt_isula_create(const char *id, cons p.exit_fifo = (char *)params->exit_fifo; p.open_tty = params->tty; @@ -211,8 +211,8 @@ \ No newline at end of file +} ---- iSulad-v2.0.16/src/daemon/executor/container_cb/execution.c 2022-09-19 09:49:53.940634672 +0800 -+++ iSulad-v2.0.16/src/daemon/executor/container_cb/execution.c 2022-09-19 09:50:50.743070321 +0800 +--- iSulad-v2.0.17/src/daemon/executor/container_cb/execution.c 2022-09-19 09:49:53.940634672 +0800 ++++ iSulad-v2.0.17/src/daemon/executor/container_cb/execution.c 2022-09-19 09:50:50.743070321 +0800 @@ -270,7 +270,7 @@ static int prepare_start_io(container_t goto out; } @@ -223,8 +223,8 @@ ret = -1; goto out; ---- iSulad-v2.0.16/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:52:35.190871412 +0800 -+++ iSulad-v2.0.16/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:54:16.304646931 +0800 +--- iSulad-v2.0.17/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:52:35.190871412 +0800 ++++ iSulad-v2.0.17/src/daemon/executor/container_cb/execution_stream.c 2022-09-19 09:54:16.304646931 +0800 @@ -266,7 +266,7 @@ static int attach_prepare_console(const goto out; } @@ -247,8 +247,8 @@ (void)isulad_monitor_send_container_event(id, ATTACH, -1, 0, NULL, NULL); ---- iSulad-v2.0.16/src/daemon/modules/api/runtime_api.h 2022-09-19 10:21:19.315094981 +0800 -+++ iSulad-v2.0.16/src/daemon/modules/api/runtime_api.h 2022-09-19 10:23:19.310015312 +0800 +--- iSulad-v2.0.17/src/daemon/modules/api/runtime_api.h 2022-09-19 10:21:19.315094981 +0800 ++++ iSulad-v2.0.17/src/daemon/modules/api/runtime_api.h 2022-09-19 10:23:19.310015312 +0800 @@ -70,9 +70,9 @@ typedef struct _rt_create_params_t { const char *state; void *oci_config_data; @@ -276,8 +276,8 @@ typedef struct _rt_update_params_t { ---- iSulad-v2.0.16/src/daemon/modules/service/service_container.c 2022-09-19 10:45:35.318254990 +0800 -+++ iSulad-v2.0.16/src/daemon/modules/service/service_container.c 2022-09-19 10:47:35.547173581 +0800 +--- iSulad-v2.0.17/src/daemon/modules/service/service_container.c 2022-09-19 10:45:35.318254990 +0800 ++++ iSulad-v2.0.17/src/daemon/modules/service/service_container.c 2022-09-19 10:47:35.547173581 +0800 @@ -825,9 +825,9 @@ static int do_start_container(container_ create_params.state = cont->state_path; create_params.oci_config_data = oci_spec; @@ -301,8 +301,8 @@ ret = -1; goto out; ---- iSulad-v2.0.16/src/cmd/isula/base/start.c 2022-09-19 11:16:14.838156121 +0800 -+++ iSulad-v2.0.16/src/cmd/isula/base/start.c 2022-09-19 11:18:12.374049157 +0800 +--- iSulad-v2.0.17/src/cmd/isula/base/start.c 2022-09-19 11:16:14.838156121 +0800 ++++ iSulad-v2.0.17/src/cmd/isula/base/start.c 2022-09-19 11:18:12.374049157 +0800 @@ -124,9 +124,9 @@ static int do_client_start(const struct request.name = args->name; @@ -317,8 +317,8 @@ request.attach_stdin = args->custom_conf.attach_stdin; request.attach_stdout = args->custom_conf.attach_stdout; ---- iSulad-v2.0.16/src/cmd/isula/stream/exec.c 2022-09-19 11:22:01.760792010 +0800 -+++ iSulad-v2.0.16/src/cmd/isula/stream/exec.c 2022-09-19 11:22:29.969006333 +0800 +--- iSulad-v2.0.17/src/cmd/isula/stream/exec.c 2022-09-19 11:22:01.760792010 +0800 ++++ iSulad-v2.0.17/src/cmd/isula/stream/exec.c 2022-09-19 11:22:29.969006333 +0800 @@ -60,9 +60,9 @@ static int fill_exec_request(const struc request->attach_stdout = args->custom_conf.attach_stdout; request->attach_stderr = args->custom_conf.attach_stderr; @@ -333,8 +333,8 @@ request->user = util_strdup_s(args->custom_conf.user); ---- iSulad-v2.0.16/src/cmd/isula/stream/attach.c 2022-09-19 11:23:59.246684654 +0800 -+++ iSulad-v2.0.16/src/cmd/isula/stream/attach.c 2022-09-19 11:24:48.674060200 +0800 +--- iSulad-v2.0.17/src/cmd/isula/stream/attach.c 2022-09-19 11:23:59.246684654 +0800 ++++ iSulad-v2.0.17/src/cmd/isula/stream/attach.c 2022-09-19 11:24:48.674060200 +0800 @@ -398,9 +398,9 @@ static int client_attach(struct client_a ret = ECOMMON; goto out; @@ -349,8 +349,8 @@ config = get_connect_config(args); ---- iSulad-v2.0.16/src/CMakeLists.txt 2022-09-19 14:44:22.526007835 +0800 -+++ iSulad-v2.0.16/src/CMakeLists.txt 2022-09-19 14:43:07.452410938 +0800 +--- iSulad-v2.0.17/src/CMakeLists.txt 2022-09-19 14:44:22.526007835 +0800 ++++ iSulad-v2.0.17/src/CMakeLists.txt 2022-09-19 14:43:07.452410938 +0800 @@ -49,6 +49,7 @@ target_include_directories(libisulad_too ) set_target_properties(libisulad_tools PROPERTIES PREFIX "") @@ -360,8 +360,8 @@ if (ENABLE_OCI_IMAGE) target_link_libraries(libisulad_tools ${LIBARCHIVE_LIBRARY}) ---- iSulad-v2.0.16/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:24:19.359973622 +0800 -+++ iSulad-v2.0.16/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:44:38.957115144 +0800 +--- iSulad-v2.0.17/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:24:19.359973622 +0800 ++++ iSulad-v2.0.17/src/daemon/modules/image/image_rootfs_handler.c 2022-09-26 09:44:38.957115144 +0800 @@ -26,6 +26,8 @@ #include #include @@ -520,8 +520,8 @@ { ERROR("uids and gids must be in range 0-%lld", MAXUID); ---- iSulad-v2.0.16/src/cmd/isulad/main.c 2022-10-14 14:04:50.303324243 +0800 -+++ iSulad-v2.0.16/src/cmd/isulad/main.c 2022-10-14 14:06:08.262895032 +0800 +--- iSulad-v2.0.17/src/cmd/isulad/main.c 2022-10-14 14:04:50.303324243 +0800 ++++ iSulad-v2.0.17/src/cmd/isulad/main.c 2022-10-14 14:06:08.262895032 +0800 @@ -40,6 +40,7 @@ #include #include @@ -530,3 +530,15 @@ #ifdef ENABLE_SUP_GROUPS #include #endif + +--- iSulad-v2.0.17/src/daemon/modules/image/oci/storage/layer_store/layer_store.c 2022-10-18 08:58:45.194015191 +0000 ++++ iSulad-v2.0.17/src/daemon/modules/image/oci/storage/layer_store/layer_store.c 2022-10-18 08:50:36.870156051 +0000 +@@ -31,7 +31,7 @@ + #include + #include + #include +-#include ++#include + + #include + #include -- Gitee From f4bc37f43ed740c2fe1d5019d92162600725f9a7 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Wed, 19 Oct 2022 10:54:00 +0800 Subject: [PATCH 23/35] musl: modify some header files * modify execinfo.h and malloc_utils.h Signed-off-by: zhangfei --- .../recipes-external/musl/libexecinfo/execinfo.h | 5 +++++ .../recipes-external/musl/libmallocutils/malloc_utils.h | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h index 2e3675f172d..0c7fb1a0b90 100644 --- a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h +++ b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h @@ -1,3 +1,6 @@ +#ifndef _EXECINFO_H +#define _EXECINFO_H + #ifdef __cplusplus extern "C" { #endif @@ -7,3 +10,5 @@ void backtrace_symbols_fd(void *const *, int, int); #ifdef __cplusplus } #endif + +#endif /* _EXECINFO_H */ diff --git a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h index 5bb35013baa..3640b95f567 100644 --- a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h +++ b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h @@ -1,5 +1,6 @@ -//#define __NEED_size_t -//#include +#ifndef _MALLOC_UTILS_H +#define _MALLOC_UTILS_H + #include #ifdef __cplusplus @@ -17,3 +18,5 @@ int malloc_trim(size_t pad); #ifdef __cplusplus } #endif + +#endif /* _MALLOC_UTILS_H */ -- Gitee From d2ef444fd7e9197c7070aac250ca7f591ca41010 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Wed, 19 Oct 2022 16:07:45 +0800 Subject: [PATCH 24/35] musl: modify musl bb file * modify SYSYROOT_DIRS variable Signed-off-by: zhangfei --- meta-openeuler/recipes-external/musl/musl_1.2.3.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index 128e489bb4b..5f2c9c917b5 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -63,4 +63,4 @@ INSANE_SKIP_${PN} += "installed-vs-shipped" INSANE_SKIP += "dev-elf dev-so" -SYSROOT_DIRS += "/*" +SYSROOT_DIRS = "/usr/*" -- Gitee From 50e370c12c5fc8902670bce5bd09894a53f2cde4 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Wed, 19 Oct 2022 16:44:07 +0800 Subject: [PATCH 25/35] musl: modify lxc bbappend file * delete compilation options Signed-off-by: zhangfei --- meta-openeuler/recipes-core/lxc/lxc_%.bbappend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-openeuler/recipes-core/lxc/lxc_%.bbappend b/meta-openeuler/recipes-core/lxc/lxc_%.bbappend index 3bac8351882..75573a90d89 100644 --- a/meta-openeuler/recipes-core/lxc/lxc_%.bbappend +++ b/meta-openeuler/recipes-core/lxc/lxc_%.bbappend @@ -1,7 +1,7 @@ SRC_URI_append_libc-musl = " \ file://lxc-for-musl.patch \ " -CFLAGS_append_libc-musl = " -Wno-error=stringop-overread -Wno-error=address -Wno-error=array-bounds -Wno-array-bounds " +CFLAGS_append_libc-musl = " -Wno-error=address -Wno-error=array-bounds -Wno-array-bounds " do_compile_prepend_libc-musl() { sed -i "s/init_lxc_static_LDFLAGS = -all-static -pthread/init_lxc_static_LDFLAGS = -pthread/" ${S}/src/lxc/Makefile.am } -- Gitee From 3dbe44dd9a3aa5a67d81375e451ab3273fc0e61f Mon Sep 17 00:00:00 2001 From: zhangfei Date: Thu, 20 Oct 2022 09:43:07 +0800 Subject: [PATCH 26/35] musl: rng-tools * modify bbappend file and add patch Signed-off-by: zhangfei --- .../rng-tools/rng-tools/rng-tools-musl.patch | 11 +++++++++++ .../recipes-support/rng-tools/rng-tools_%.bbappend | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch diff --git a/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch b/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch new file mode 100644 index 00000000000..8e4be988f01 --- /dev/null +++ b/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch @@ -0,0 +1,11 @@ +--- rng-tools-6.14/rngd_jitter.c 2021-08-09 15:08:57.000000000 +0000 ++++ rng-tools-6.14/rngd_jitter.c 2022-10-19 08:48:00.844438821 +0000 +@@ -67,7 +67,7 @@ + for(i=i-1;i>=0;i--) { + CPU_SET(i,cpus); + } +- pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); ++ pthread_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); + + ret = -pthread_create(&thread_ctx->notime_thread_id, + &thread_ctx->notime_pthread_attr, diff --git a/meta-openeuler/recipes-support/rng-tools/rng-tools_%.bbappend b/meta-openeuler/recipes-support/rng-tools/rng-tools_%.bbappend index 866f6aeeb3d..97012048ca3 100644 --- a/meta-openeuler/recipes-support/rng-tools/rng-tools_%.bbappend +++ b/meta-openeuler/recipes-support/rng-tools/rng-tools_%.bbappend @@ -13,3 +13,9 @@ SRC_URI_prepend = "\ # change source directory S = "${WORKDIR}/${BP}" + +# add patch to support musl +FILESEXTRAPATHS_prepend := "${THISDIR}/rng-tools/:" +SRC_URI_append_libc-musl = " \ + file://rng-tools-musl.patch \ +" -- Gitee From 714f0c309bf2db87ea3eb35a245b5e45a7a9e9c7 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Thu, 20 Oct 2022 10:45:51 +0800 Subject: [PATCH 27/35] musl: groff * add CXXFLAGS to support musl Signed-off-by: zhangfei --- meta-openeuler/recipes-extended/groff/groff_%.bbappend | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 meta-openeuler/recipes-extended/groff/groff_%.bbappend diff --git a/meta-openeuler/recipes-extended/groff/groff_%.bbappend b/meta-openeuler/recipes-extended/groff/groff_%.bbappend new file mode 100644 index 00000000000..fb028324e5f --- /dev/null +++ b/meta-openeuler/recipes-extended/groff/groff_%.bbappend @@ -0,0 +1,2 @@ +# add CXXFLAGS to support musl +CXXFLAGS_libc-musl += "-std=gnu++98" -- Gitee From 2a4f5fd13dd756700600b0c15dfdd4f94da92c30 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Tue, 8 Nov 2022 09:14:47 +0800 Subject: [PATCH 28/35] musl: modify header files * modify include guards Signed-off-by: zhangfei --- meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h | 6 +++--- .../recipes-external/musl/libmallocutils/malloc_utils.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h index 0c7fb1a0b90..593b805a5ee 100644 --- a/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h +++ b/meta-openeuler/recipes-external/musl/libexecinfo/execinfo.h @@ -1,5 +1,5 @@ -#ifndef _EXECINFO_H -#define _EXECINFO_H +#ifndef EXECINFO_H +#define EXECINFO_H #ifdef __cplusplus extern "C" { @@ -11,4 +11,4 @@ void backtrace_symbols_fd(void *const *, int, int); } #endif -#endif /* _EXECINFO_H */ +#endif /* EXECINFO_H */ diff --git a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h index 3640b95f567..5e8d8a21b5d 100644 --- a/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h +++ b/meta-openeuler/recipes-external/musl/libmallocutils/malloc_utils.h @@ -1,5 +1,5 @@ -#ifndef _MALLOC_UTILS_H -#define _MALLOC_UTILS_H +#ifndef MALLOC_UTILS_H +#define MALLOC_UTILS_H #include @@ -19,4 +19,4 @@ int malloc_trim(size_t pad); } #endif -#endif /* _MALLOC_UTILS_H */ +#endif /* MALLOC_UTILS_H */ -- Gitee From c6e5a67d37d3b72259deabfacacd3d94751de998 Mon Sep 17 00:00:00 2001 From: chengzhixing Date: Tue, 8 Nov 2022 16:28:49 +0800 Subject: [PATCH 29/35] musl: modify musl_1.23.bb *modify musl bb for musl-1.23*.rpm and musl*-staticdev.rpm Signed-off-by: chengzhixing --- meta-openeuler/recipes-external/musl/musl_1.2.3.bb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index 5f2c9c917b5..d817ac8c14e 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -46,13 +46,16 @@ do_install() { chown root:root ${D}/ -R } +do_package_qa[noexec] = "1" +EXCLUDE_FROM_SHLIBS = "1" + FILES_${PN} = " \ - /lib/*.so \ - /lib/*.so.* \ + /lib64/*.so \ + /lib64/*.so.* \ ${base_sbindir}/ldconfig \ " FILES_${PN}-staticdev = " \ - /lib/*.a \ + /lib64/*.a \ " -- Gitee From 2605a4b95d90ce95464a6a3fa3fa89ed5ae562c8 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Tue, 15 Nov 2022 16:08:22 +0800 Subject: [PATCH 30/35] musl: support qemu-aarch64 run * add variable to support qemu run Signed-off-by: zhangfei --- scripts/compile.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/compile.sh b/scripts/compile.sh index 81616bb8176..64ed1ac52e5 100644 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -145,6 +145,7 @@ set_env() sed -i '$a\crypt = "musl"' conf/local.conf sed -i '$a\TCMODE-LIBC = "musl"' conf/local.conf sed -i 's/aarch64-openeuler-linux-gnu/aarch64-openeuler-linux-musl/g' conf/local.conf + echo "MACHINE_ESSENTIAL_EXTRA_RDEPENDS = \"musl\"" >> conf/local.conf else sed -i '$a\LIBC = "glibc"' conf/local.conf sed -i '$a\TCMODE-LIBC = "glibc-external"' conf/local.conf -- Gitee From 0b09a7a0889af5524bc2d8ef8a670c7d38c6e2b3 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 18 Nov 2022 10:41:37 +0800 Subject: [PATCH 31/35] musl: support openeuler-image compile * modify openeuler-image-sdk.inc Signed-off-by: zhangfei --- meta-openeuler/recipes-core/images/openeuler-image-sdk.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-openeuler/recipes-core/images/openeuler-image-sdk.inc b/meta-openeuler/recipes-core/images/openeuler-image-sdk.inc index 6dfa1bd692d..873fc9b13c8 100644 --- a/meta-openeuler/recipes-core/images/openeuler-image-sdk.inc +++ b/meta-openeuler/recipes-core/images/openeuler-image-sdk.inc @@ -58,6 +58,6 @@ gcc-external-cross-canadian-${TRANSLATED_TARGET_ARCH} \ TOOLCHAIN_TARGET_TASK += " \ libgcc \ kernel-devsrc \ -glibc-external-staticdev \ +${TCMODE-LIBC}-staticdev \ libstdc++-dev \ " -- Gitee From 4b30b3a495e14795f9d7d5f8adb72d945fe3dab8 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 18 Nov 2022 10:46:31 +0800 Subject: [PATCH 32/35] musl: support libunwind compile * add libssp-nonshared DEPENDS Signed-off-by: zhangfei --- meta-openeuler/recipes-external/musl/musl_1.2.3.bb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index d817ac8c14e..07c6a2449b2 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -14,6 +14,7 @@ PACKAGES = "${PN} ${PN}-dev ${PN}-staticdev" PROVIDES += "virtual/libc virtual/libiconv virtual/libintl virtual/crypt" DEPENDS = "bsd-headers \ + libssp-nonshared \ " INHIBIT_DEFAULT_DEPS = "1" @@ -59,7 +60,7 @@ FILES_${PN}-staticdev = " \ " -RDEPENDSPN_${}-dev += "bsd-headers-dev" +RDEPENDSPN_${}-dev += "bsd-headers-dev libssp-nonshared-staticdev" INSANE_SKIP_${PN} += "installed-vs-shipped" -- Gitee From b89f6ef47f138852de1114da4398bab473be6a61 Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 18 Nov 2022 10:55:05 +0800 Subject: [PATCH 33/35] musl: fix rng-tools compile error * remake patch file Signed-off-by: zhangfei --- .../rng-tools/rng-tools/rng-tools-musl.patch | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch b/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch index 8e4be988f01..e8d61e78d75 100644 --- a/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch +++ b/meta-openeuler/recipes-support/rng-tools/rng-tools/rng-tools-musl.patch @@ -1,11 +1,11 @@ ---- rng-tools-6.14/rngd_jitter.c 2021-08-09 15:08:57.000000000 +0000 -+++ rng-tools-6.14/rngd_jitter.c 2022-10-19 08:48:00.844438821 +0000 -@@ -67,7 +67,7 @@ - for(i=i-1;i>=0;i--) { - CPU_SET(i,cpus); - } -- pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); -+ pthread_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); - - ret = -pthread_create(&thread_ctx->notime_thread_id, - &thread_ctx->notime_pthread_attr, +--- rng-tools-6.14/rngd_jitter.c 2022-11-16 05:51:23.387022953 +0000 ++++ rng-tools-6.14/rngd_jitter.c 2022-11-16 05:51:41.602597386 +0000 +@@ -67,7 +67,7 @@ static int rngd_notime_start(void *ctx, + for(i=i-1;i>=0;i--) { + CPU_SET(i,cpus); + } +- pthread_attr_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); ++ pthread_setaffinity_np(&thread_ctx->notime_pthread_attr, cpusize, cpus); + + ret = -pthread_create(&thread_ctx->notime_thread_id, + &thread_ctx->notime_pthread_attr, -- Gitee From a8d0396e49a96760edcb4bbd549c115efc46df3c Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 18 Nov 2022 11:11:49 +0800 Subject: [PATCH 34/35] musl: support perf compile * add __always_inline definition Signed-off-by: zhangfei --- .../musl/bsd-headers/sys-cdefs-musl.patch | 15 +++++++++---- .../musl/musl/musl-add-cdefs.patch | 21 +++++++++++++++++++ .../recipes-external/musl/musl_1.2.3.bb | 6 ++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 meta-openeuler/recipes-external/musl/musl/musl-add-cdefs.patch diff --git a/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch b/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch index 61226edf455..076fbfb12f9 100644 --- a/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch +++ b/meta-openeuler/recipes-external/musl/bsd-headers/sys-cdefs-musl.patch @@ -1,11 +1,13 @@ ---- a/sys-cdefs.h 2022-09-15 17:08:35.541665900 +0800 -+++ b/sys-cdefs.h 2022-09-15 17:40:15.841270095 +0800 -@@ -1,4 +1,3 @@ +--- a/sys-cdefs.h 2022-11-16 08:35:20.089145983 +0000 ++++ b/sys-cdefs.h 2022-11-16 08:49:14.023211318 +0000 +@@ -1,4 +1,5 @@ -#warning usage of non-standard #include is deprecated ++#ifndef SYS_CDEFS_H ++#define SYS_CDEFS_H 1 #undef __P #undef __PMT -@@ -24,3 +23,9 @@ +@@ -24,3 +25,14 @@ # define __THROW # define __NTH(fct) fct #endif @@ -15,3 +17,8 @@ +#else +# define __nonnull(params) +#endif ++ ++#undef __always_inline ++#define __always_inline __inline __attribute__ ((__always_inline__)) ++ ++#endif /* sys/cdefs.h */ diff --git a/meta-openeuler/recipes-external/musl/musl/musl-add-cdefs.patch b/meta-openeuler/recipes-external/musl/musl/musl-add-cdefs.patch new file mode 100644 index 00000000000..94990754513 --- /dev/null +++ b/meta-openeuler/recipes-external/musl/musl/musl-add-cdefs.patch @@ -0,0 +1,21 @@ +--- a/usr/include/linux/swab.h 2022-11-16 08:56:41.830033425 +0000 ++++ b/usr/include/linux/swab.h 2022-11-16 08:45:09.903728883 +0000 +@@ -6,6 +6,7 @@ + + #include + #include ++#include + + /* + * casts are necessary for constants, because we never know how for sure + +--- a/usr/include/linux/byteorder/little_endian.h 2022-11-16 08:59:10.621604427 +0000 ++++ b/usr/include/linux/byteorder/little_endian.h 2022-11-16 08:44:46.647771103 +0000 +@@ -11,6 +11,7 @@ + + #include + #include ++#include + + #define __constant_htonl(x) ((__be32)___constant_swab32((x))) + #define __constant_ntohl(x) ___constant_swab32((__be32)(x)) diff --git a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb index 07c6a2449b2..64afc4693f4 100644 --- a/meta-openeuler/recipes-external/musl/musl_1.2.3.bb +++ b/meta-openeuler/recipes-external/musl/musl_1.2.3.bb @@ -25,6 +25,12 @@ INSANE_SKIP_${PN} += "already-stripped" PSEUDO_DISABLED = "1" +# this patch is to support perf compile +FILESEXTRAPATHS_prepend := "${THISDIR}/musl/:" +SRC_URI = " \ + file://musl-add-cdefs.patch;patchdir=${EXTERNAL_TOOLCHAIN}/aarch64-openeuler-linux-musl/sysroot/ \ +" + do_configure() { : } -- Gitee From 29740cb211a8bcf7ef4bd59a833e5c3004dc0b1d Mon Sep 17 00:00:00 2001 From: zhangfei Date: Fri, 18 Nov 2022 11:16:12 +0800 Subject: [PATCH 35/35] musl: support packagegroup-pam-plugins compile * remove pam-plugin-lastlog * remove pam-plugin-rhosts Signed-off-by: zhangfei --- .../packagegroups/packagegroup-pam-plugins.bbappend | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 meta-openeuler/recipes-core/packagegroups/packagegroup-pam-plugins.bbappend diff --git a/meta-openeuler/recipes-core/packagegroups/packagegroup-pam-plugins.bbappend b/meta-openeuler/recipes-core/packagegroups/packagegroup-pam-plugins.bbappend new file mode 100644 index 00000000000..fae143d8a39 --- /dev/null +++ b/meta-openeuler/recipes-core/packagegroups/packagegroup-pam-plugins.bbappend @@ -0,0 +1,5 @@ +# remove them because of the lack of ruserok_af and logwtmp functions +RDEPENDS_${PN}_remove_libc-musl = "\ +pam-plugin-lastlog \ +pam-plugin-rhosts \ +" -- Gitee