From a465a679831cff2d2d9324c28446669ffc066bfc Mon Sep 17 00:00:00 2001 From: yuncang123 <1050706328@qq.com> Date: Fri, 9 Aug 2024 19:52:44 +0800 Subject: [PATCH 1/4] fix three problems to support clang build --- 0015-place-__attribute__-after-struct.patch | 116 ++++++++++++++++++++ lcr.spec | 11 +- 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 0015-place-__attribute__-after-struct.patch diff --git a/0015-place-__attribute__-after-struct.patch b/0015-place-__attribute__-after-struct.patch new file mode 100644 index 0000000..4c6e3e7 --- /dev/null +++ b/0015-place-__attribute__-after-struct.patch @@ -0,0 +1,116 @@ +From e869f0718d2b0d50b3dcc2eebbb8b35cc69ec8d0 Mon Sep 17 00:00:00 2001 +From: yuncang123 <1050706328@qq.com> +Date: Fri, 9 Aug 2024 19:43:25 +0800 +Subject: [PATCH] place __attribute__ after struct + +--- + src/runtime/lcrcontainer.h | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +diff --git a/src/runtime/lcrcontainer.h b/src/runtime/lcrcontainer.h +index d4cef39..9475f62 100644 +--- a/src/runtime/lcrcontainer.h ++++ b/src/runtime/lcrcontainer.h +@@ -40,22 +40,22 @@ extern "C" { + + /* define console log config */ + +-__EXPORT__ struct lcr_console_config { ++struct lcr_console_config { + char *log_path; + unsigned int log_rotate; + char *log_file_size; +-}; ++}__EXPORT__; + +-__EXPORT__ struct blkio_stats { ++struct blkio_stats { + uint64_t read; + uint64_t write; + uint64_t total; +-}; ++}__EXPORT__; + + /* + * Store lcr container state + */ +-__EXPORT__ struct lcr_container_state { ++struct lcr_container_state { + /* Name of container */ + char *name; + /* State of container */ +@@ -84,7 +84,7 @@ __EXPORT__ struct lcr_container_state { + uint64_t cache; + uint64_t cache_total; + uint64_t inactive_file_total; +-}; ++}__EXPORT__; + + typedef enum { + lcr_msg_state, +@@ -92,14 +92,14 @@ typedef enum { + lcr_msg_exit_code, + } lcr_msg_type_t; + +-__EXPORT__ struct lcr_msg { ++struct lcr_msg { + lcr_msg_type_t type; + char name[NAME_MAX + 1]; + int value; + int pid; +-}; ++}__EXPORT__; + +-__EXPORT__ struct lcr_cgroup_resources { ++struct lcr_cgroup_resources { + uint64_t blkio_weight; + uint64_t cpu_shares; + uint64_t cpu_period; +@@ -112,7 +112,7 @@ __EXPORT__ struct lcr_cgroup_resources { + uint64_t kernel_memory_limit; + int64_t cpurt_period; + int64_t cpurt_runtime; +-}; ++}__EXPORT__; + + /* + * Create a container +@@ -150,7 +150,7 @@ __EXPORT__ bool lcr_create(const char *name, const char *lcrpath, void *oci_conf + * gid : user in which group + * additional_gids : Add additional groups to join + */ +-__EXPORT__ struct lcr_start_request { ++struct lcr_start_request { + const char *name; + const char *lcrpath; + +@@ -165,7 +165,7 @@ __EXPORT__ struct lcr_start_request { + const char *container_pidfile; + const char *exit_fifo; + bool image_type_oci; +-}; ++}__EXPORT__; + __EXPORT__ bool lcr_start(const struct lcr_start_request *request); + + /* +@@ -237,7 +237,7 @@ __EXPORT__ void lcr_free_console_config(struct lcr_console_config *config); + __EXPORT__ int lcr_log_init(const char *name, const char *file, const char *priority, + const char *prefix, int quiet, const char *lcrpath); + +-__EXPORT__ struct lcr_exec_request { ++struct lcr_exec_request { + const char *name; + const char *lcrpath; + +@@ -261,7 +261,7 @@ __EXPORT__ struct lcr_exec_request { + bool tty; + bool open_stdin; + char *workdir; +-}; ++}__EXPORT__; + /* + * Execute process inside a container + */ +-- +2.43.0 + diff --git a/lcr.spec b/lcr.spec index 10dafe1..0e534cf 100644 --- a/lcr.spec +++ b/lcr.spec @@ -27,6 +27,7 @@ Patch0011: 0011-remove-lcr-created-spec-only-if-create-failed.patch Patch0012: 0012-Fix-info-inproper-data-type-for-timestamp.patch Patch0013: 0013-fix-bug-for-potential-config-seccomp-ocihook-write-e.patch Patch0014: 0014-add-codecheck-fix.patch +Patch0015: 0015-place-__attribute__-after-struct.patch %define lxcver_lower 4.0.3-2022102400 %define lxcver_upper 5.0.3 @@ -80,6 +81,7 @@ mkdir -p build cd build %if "%toolchain" == "clang" %global cmake_opts -DCMAKE_C_FLAGS="${CFLAGS}" +CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument" %endif %if 0%{?enable_lxc} @@ -147,7 +149,14 @@ rm -rf %{buildroot} %{_includedir}/lcr/utils_compile.h %changelog -* Tue June 11 2024 jikai - 2.1.4-8 +* Sat Aug 10 2024 yuanchao<1050706328@qq.com> - 2.1.4-9 +- Type:enhancement +- CVE:NA +- SUG:NA +- DESC:support clang build + + +* Tue Jun 11 2024 jikai - 2.1.4-8 - Type:enhancement - CVE:NA - SUG:NA -- Gitee From 75cc94eaa63f51c9cfd09a59cd9089b54a4b567c Mon Sep 17 00:00:00 2001 From: yuncang123 <1050706328@qq.com> Date: Fri, 9 Aug 2024 20:11:02 +0800 Subject: [PATCH 2/4] blankline --- lcr.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/lcr.spec b/lcr.spec index 0e534cf..5569e19 100644 --- a/lcr.spec +++ b/lcr.spec @@ -155,7 +155,6 @@ rm -rf %{buildroot} - SUG:NA - DESC:support clang build - * Tue Jun 11 2024 jikai - 2.1.4-8 - Type:enhancement - CVE:NA -- Gitee From 9fde54672089112878bc6cb1a0bc8f9e353ebce5 Mon Sep 17 00:00:00 2001 From: yuncang123 <1050706328@qq.com> Date: Fri, 9 Aug 2024 22:58:39 +0800 Subject: [PATCH 3/4] add 0015-place-__attribute__-after-struct.patch --- 0015-place-__attribute__-after-struct.patch | 72 +++++---------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/0015-place-__attribute__-after-struct.patch b/0015-place-__attribute__-after-struct.patch index 4c6e3e7..d6dd10c 100644 --- a/0015-place-__attribute__-after-struct.patch +++ b/0015-place-__attribute__-after-struct.patch @@ -1,116 +1,76 @@ -From e869f0718d2b0d50b3dcc2eebbb8b35cc69ec8d0 Mon Sep 17 00:00:00 2001 +From 753f99be08f86b7ef4ff21b61ade537ca260058c Mon Sep 17 00:00:00 2001 From: yuncang123 <1050706328@qq.com> -Date: Fri, 9 Aug 2024 19:43:25 +0800 +Date: Fri, 9 Aug 2024 22:54:14 +0800 Subject: [PATCH] place __attribute__ after struct --- - src/runtime/lcrcontainer.h | 28 ++++++++++++++-------------- - 1 file changed, 14 insertions(+), 14 deletions(-) + src/runtime/lcrcontainer.h | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/runtime/lcrcontainer.h b/src/runtime/lcrcontainer.h -index d4cef39..9475f62 100644 +index d4cef39..6baa540 100644 --- a/src/runtime/lcrcontainer.h +++ b/src/runtime/lcrcontainer.h -@@ -40,22 +40,22 @@ extern "C" { +@@ -40,13 +40,13 @@ extern "C" { /* define console log config */ -__EXPORT__ struct lcr_console_config { -+struct lcr_console_config { ++struct __EXPORT__ lcr_console_config { char *log_path; unsigned int log_rotate; char *log_file_size; --}; -+}__EXPORT__; + }; -__EXPORT__ struct blkio_stats { -+struct blkio_stats { ++struct __EXPORT__ blkio_stats { uint64_t read; uint64_t write; uint64_t total; --}; -+}__EXPORT__; - +@@ -55,7 +55,7 @@ __EXPORT__ struct blkio_stats { /* * Store lcr container state */ -__EXPORT__ struct lcr_container_state { -+struct lcr_container_state { ++struct __EXPORT__ lcr_container_state { /* Name of container */ char *name; /* State of container */ -@@ -84,7 +84,7 @@ __EXPORT__ struct lcr_container_state { - uint64_t cache; - uint64_t cache_total; - uint64_t inactive_file_total; --}; -+}__EXPORT__; - - typedef enum { - lcr_msg_state, @@ -92,14 +92,14 @@ typedef enum { lcr_msg_exit_code, } lcr_msg_type_t; -__EXPORT__ struct lcr_msg { -+struct lcr_msg { ++struct __EXPORT__ lcr_msg { lcr_msg_type_t type; char name[NAME_MAX + 1]; int value; int pid; --}; -+}__EXPORT__; + }; -__EXPORT__ struct lcr_cgroup_resources { -+struct lcr_cgroup_resources { ++struct __EXPORT__ lcr_cgroup_resources { uint64_t blkio_weight; uint64_t cpu_shares; uint64_t cpu_period; -@@ -112,7 +112,7 @@ __EXPORT__ struct lcr_cgroup_resources { - uint64_t kernel_memory_limit; - int64_t cpurt_period; - int64_t cpurt_runtime; --}; -+}__EXPORT__; - - /* - * Create a container @@ -150,7 +150,7 @@ __EXPORT__ bool lcr_create(const char *name, const char *lcrpath, void *oci_conf * gid : user in which group * additional_gids : Add additional groups to join */ -__EXPORT__ struct lcr_start_request { -+struct lcr_start_request { ++struct __EXPORT__ lcr_start_request { const char *name; const char *lcrpath; -@@ -165,7 +165,7 @@ __EXPORT__ struct lcr_start_request { - const char *container_pidfile; - const char *exit_fifo; - bool image_type_oci; --}; -+}__EXPORT__; - __EXPORT__ bool lcr_start(const struct lcr_start_request *request); - - /* @@ -237,7 +237,7 @@ __EXPORT__ void lcr_free_console_config(struct lcr_console_config *config); __EXPORT__ int lcr_log_init(const char *name, const char *file, const char *priority, const char *prefix, int quiet, const char *lcrpath); -__EXPORT__ struct lcr_exec_request { -+struct lcr_exec_request { ++struct __EXPORT__ lcr_exec_request { const char *name; const char *lcrpath; -@@ -261,7 +261,7 @@ __EXPORT__ struct lcr_exec_request { - bool tty; - bool open_stdin; - char *workdir; --}; -+}__EXPORT__; - /* - * Execute process inside a container - */ -- 2.43.0 -- Gitee From 03933888618e32f618169ffef5daf69bab337dda Mon Sep 17 00:00:00 2001 From: yuncang123 <1050706328@qq.com> Date: Fri, 9 Aug 2024 23:55:03 +0800 Subject: [PATCH 4/4] release add 1 --- lcr.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lcr.spec b/lcr.spec index 5569e19..39cac60 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ %global _version 2.1.4 -%global _release 8 +%global _release 9 %global _inner_name isula_libutils %global enable_lxc 1 -- Gitee