diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/accountsservice.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/accountsservice.md" new file mode 100644 index 0000000000000000000000000000000000000000..14a824a0a74081ad04ebb1640a434031cb4814c7 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/accountsservice.md" @@ -0,0 +1,76 @@ +## accountsservice + +### 问题描述 + +#### 报错信息 + +##### 1. aarch64 —— meson.build: ERROR: Assert failed: Do not know which filename to watch for wtmp changes + +``` +[ 89s] Checking for function "setutxdb" : NO +[ 89s] Checking for function "fgetpwent" : YES +[ 89s] Header "utmpx.h" has symbol "WTMPX_FILENAME" : NO +[ 89s] Header "paths.h" has symbol "_PATH_WTMPX" : NO +[ 89s] +[ 89s] meson.build:107:2: ERROR: Assert failed: Do not know which filename to watch for wtmp changes +[ 89s] +[ 89s] A full log can be found at /home/abuild/rpmbuild/BUILD/accountsservice-23.13.9/aarch64-openEuler-linux-gnu/meson-logs/meson-log.txt +``` + +##### 2. error: call to undeclared function 'print_indent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + +``` +... +[ 131s] [75/109] clang -Isubprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p -Isubprojects/mocklibc-1.0/src -I../subprojects/mocklibc-1.0/src -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/generic-hardened-clang.cfg -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fsigned-char -MD -MQ subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -MF subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o.d -o subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -c ../subprojects/mocklibc-1.0/src/netgroup-debug.c +[ 131s] FAILED: subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o +[ 131s] clang -Isubprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p -Isubprojects/mocklibc-1.0/src -I../subprojects/mocklibc-1.0/src -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/generic-hardened-clang.cfg -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fsigned-char -MD -MQ subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -MF subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o.d -o subprojects/mocklibc-1.0/src/mocklibc-debug-netgroup.p/netgroup-debug.c.o -c ../subprojects/mocklibc-1.0/src/netgroup-debug.c +[ 131s] ../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: call to undeclared function 'print_indent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] +[ 131s] 25 | print_indent(stream, indent); +[ 131s] | ^ +[ 131s] ../subprojects/mocklibc-1.0/src/netgroup-debug.c:44:3: error: call to undeclared function 'print_indent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] +[ 131s] 44 | print_indent(stream, indent); +[ 131s] | ^ +[ 131s] ../subprojects/mocklibc-1.0/src/netgroup-debug.c:53:3: error: call to undeclared function 'print_indent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] +[ 131s] 53 | print_indent(stream, indent); +[ 131s] | ^ +[ 131s] 3 errors generated. +... +``` + +#### 相关PR + +- 上游社区PR: + - [Draft: Make checking for valid wtmp path optional, for musl. (!97) · Merge requests · accountsservice / accountsservice · GitLab](https://gitlab.freedesktop.org/accountsservice/accountsservice/-/merge_requests/97) + - [Fix compiler warnings (!131) · Merge requests · accountsservice / accountsservice · GitLab](https://gitee.com/link?target=https%3A%2F%2Fgitlab.freedesktop.org%2Faccountsservice%2Faccountsservice%2F-%2Fmerge_requests%2F131) +- openEuler仓库PR: + - [Remove wtmp check to supprt clang build in aarch64 · Pull Request !30 · src-openEuler/accountsservice - Gitee.com](https://gitee.com/src-openeuler/accountsservice/pulls/30) + - [Backport fix compiler warning/error in mocklibc to support clang build · Pull Request !29 · src-openEuler/accountsservice - Gitee.com](https://gitee.com/src-openeuler/accountsservice/pulls/29) + +### 修复过程 + +#### 1. Assert failed: Do not know which filename to watch for wtmp changes + +- 参考了上游社区的草稿PR:[Draft: Make checking for valid wtmp path optional, for musl. (!97) · Merge requests · accountsservice / accountsservice · GitLab](https://gitlab.freedesktop.org/accountsservice/accountsservice/-/merge_requests/97) + + - 作者是为了支持musl而提出的pr,他表示:musl根本不支持wtmp,只是将其实现为不做任何事情的stub,参见[这个链接](https://wiki.musl-libc.org/faq.html#Q:_Why_is_the_utmp/wtmp_functionality_only_implemented_as_stubs?) ,当使用`meson setup`配置accountsservice时,musl会失败,因为musl没有定义到wtmp的路径。作者维护的作者维护的使用到accountsservice的项目Gentoo中有多人报告了这个bug:[762442 – sys-apps/accountsservice-23.13.9 - meson.build:85:2: ERROR: Assert failed: Do not know which filename to watch for wtmp changes (on musl) (gentoo.org)](https://bugs.gentoo.org/762442)。虽然主要是为了支持musl,但是使用arm64 clang构建也能复现这个报错。 + + - 在上游pr中,作者一开始将wtmp该检查成设为可选的,使其适用于musl,并添加了musl需要的fgetspent_r的替换。后来在项目所有者的意见下改为将wtmp检查直接删除了。 + + - 目前该pr已经一年没有更新。但Alpine以及Gentoo中都采用了该pr的修改方式。且按照项目所有者的说法,他认为直接删除wtmp的检查而不进行选择是OK的。因此选择了继续采用该pr的修复方式。 + + - 由于本次修复目标是aarch64的构建问题,对于musl是否支持并没有检验,又因为经过测试,仅删除wtmp的检查即可构建成功,不需要添加fgetspent_r的替换,所以目前仅搬运了删除wtmp检查的部分。 + + +#### 2. call to undeclared function 'print_indent' + +- 该报错位于项目使用的一个子项目`mocklibc`,报错原因在于`print_indent`在`mocklibc`中的声明和定义位于`src/netgroup.c`中,而在`src/netgroup-debug.c`中未声明就进行了调用。 + +- 在上游社区查找到相关bug报告:https://bugs.freedesktop.org/show_bug.cgi?id=95342 + +- 在上游社区找到相关已合并PR和commit,其中选择的解决方案为在`subprojects/mocklibc.wrap`中加入一个`src/netgroup-debug.c`的补丁,使得`src/netgroup-debug.c`中加入`print_indent`的声明: + + - PR:[Fix compiler warnings (!131) · Merge requests · accountsservice / accountsservice · GitLab](https://gitee.com/link?target=https%3A%2F%2Fgitlab.freedesktop.org%2Faccountsservice%2Faccountsservice%2F-%2Fmerge_requests%2F131) + + - commit:[mocklibc: Fix compiler warning (da65bee1) · Commits · accountsservice / accountsservice · GitLab](https://gitee.com/link?target=https%3A%2F%2Fgitlab.freedesktop.org%2Faccountsservice%2Faccountsservice%2F-%2Fcommit%2Fda65bee12d9118fe1a49c8718d428fe61d232339) + +- 引入该commit的patch修改后,clang构建“call to undeclared function 'print_indent'”报错消失。 diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/alsa-tools.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/alsa-tools.md" new file mode 100644 index 0000000000000000000000000000000000000000..eb3a15249bed7efdbd357c3482f0c91d43bf5fef --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/alsa-tools.md" @@ -0,0 +1,30 @@ +## alsa-tools + +### 问题描述 + +#### 报错信息 + +修改前 clang 构建在 `echomixer.c` 出现多个类似下方片段的报错: + +``` +echomixer.c:2108:7: error: incompatible function pointer types passing 'void (GtkWidget *, gpointer)' (aka 'void (struct _GtkWidget *, void *)') to parameter of type 'GCallback' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types] + 2108 | gtk_signal_connect(GTK_OBJECT(menuitem), "activate", Digital_mode_activate, (gpointer)(long)i); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``` + +#### 相关PR + +- 已有上游社区 PR:[Fix build failure on Clang 16 by mazunki · Pull Request #17 · alsa-project/alsa-tools (github.com)](https://github.com/alsa-project/alsa-tools/pull/17); +- 已有上游社区 issue:[Build failure with upcoming Clang 16 (-Wincompatible-function-pointer-types) · Issue #12 · alsa-project/alsa-tools (github.com)](https://github.com/alsa-project/alsa-tools/issues/12) +- openEuler 仓库 PR:[Backport fix for clang build · Pull Request !32 · src-openEuler/alsa-tools - Gitee.com](https://gitee.com/src-openeuler/alsa-tools/pulls/32) + +### 修复过程 + +- 回合上游社区PR。 +- 修复内容为:以上文中片段为例,该报错的原因为`Digital_mode_activate`的类型并没有显式转换为`GCallback`,Clang 在类型检查方面相对于 GCC 更加严格,对于这种函数指针类型不兼容,GCC 不会默认处理为 error。解决方法则是将其显式转换为目标类型,比如: + + ``` + - gtk_signal_connect(GTK_OBJECT(menuitem), “activate”, Digital_mode_activate, (gPointer)(long)i); + + gtk_signal_connect(GTK_OBJECT(menuitem), “activate”, G_CALLBACK(Digital_mode_activate), (gpointer)(long)i); + ``` + diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/crash.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/crash.md" new file mode 100644 index 0000000000000000000000000000000000000000..73afc189247f936d7db0d10dc68e72def0fa61bd --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/crash.md" @@ -0,0 +1,71 @@ +## crash + +### 问题描述 + +#### 报错信息 + +修改前 clang 构建出现多个`error: integer value -1 is outside the valid range of values`报错,比如: + +``` +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from cp-valprint.c:20: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from d-lang.c:20: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from cp-namespace.c:21: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from d-namespace.c:20: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from ctfread.c:78: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +In file included from d-valprint.c:20: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'innermost_block_tracker_type' [-Wenum-constexpr-conversion] +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'innermost_block_tracker_type' [-Wenum-constexpr-conversion] +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 1] for the enumeration type 'btrace_insn_flag' [-Wenum-constexpr-conversion] +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'btrace_function_flag' [-Wenum-constexpr-conversion] +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 1] for the enumeration type 'btrace_insn_flag' [-Wenum-constexpr-conversion] +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'btrace_function_flag' [-Wenum-constexpr-conversion] +In file included from dbxread.c:33: +In file included from ./defs.h:65: +./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] + 85 | integer_for_size(T (-1) < T (0))>::type + | ^ +... +``` + +#### 相关PR + +- 在上游社区crash提出PR,链接为:[Backport gdb patch to fix integer value -1 outside valid range error in clang 16+ by yanyir · Pull Request #188 · crash-utility/crash (github.com)](https://github.com/crash-utility/crash/pull/188) +- openEuler仓库PR:[Backport a gdb patch to fix clang build "integer value -1 is outside the valid range of values" error · Pull Request !101 · src-openEuler/crash - Gitee.com](https://gitee.com/src-openeuler/crash/pulls/101) + +### 修复过程 + +- 这些报错都位于crash使用的gdb-10.2包当中,crash社区选择了对gdb 10.2进行patch的方式对gdb代码进行迭代,所有更新全部位于`gdb-10.2.patch`中。但并非所有gdb的更新都被其采用,能够解决本次pr涉及的报错的patch在之前并未被添加。GDB由于需要使用代码中的功能且未找到其他实现方式,故对该报错的解决方式为忽略`enum-flags.h`中的`-Wenum-constexpr-conversion`警告。 + + 对应的 GDB commit: + 8cbde735e40551a694d4ee5cfd4d525d3d77ff7e ("gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h") + gdb仓库地址:https://git.linaro.org/toolchain/binutils-gdb.git + +- 不影响原来的构建行为。修改后clang构建成功,OBS验证工程: + https://build.tarsier-infra.isrc.ac.cn/package/show/home:yy:branches:Mega-LLVM:crash diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cups.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cups.md" new file mode 100644 index 0000000000000000000000000000000000000000..dc13f277c46cdb5f16678753f551926ee94fb798 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cups.md" @@ -0,0 +1,55 @@ +## cups + +### 问题描述 + +#### 报错信息 + +修改前 clang 构建在 `testhttp.c` 出现报错: + +``` +testhttp.c:395:32: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion] + 395 | addrlist = httpAddrGetList(gethostname(localhostname, sizeof(localhostname)), AF_UNSPEC, NULL); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../cups/http.h:526:53: note: passing argument to parameter 'hostname' here + 526 | extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_API_1_2; + | ^ +1 error generated. +``` + +#### 相关PR + +- openEuler 仓库 PR:[Fix clang build incompatible integer to pointer conversion error · Pull Request !158 · src-openEuler/cups - Gitee.com](https://gitee.com/src-openeuler/cups/pulls/158) + +### 修复过程 + +- 该报错由openEuler中间仓的Patch: `fix-httpAddrGetList-test-case-fail.patch` 引入。`-Wint-conversion`在clang中默认为error,而在gcc中为warning,故当使用gcc构建时,不会报上述错误。该Patch对应PR为:[fix build error · Pull Request !103](https://gitee.com/src-openeuler/cups/pulls/103)。上游社区中报错这行代码至今仍未改变,为: + + ```c + addrlist = httpAddrGetList(hostname, AF_UNSPEC, NULL); + ``` + + 若将该Patch删除可以用clang构建成功,但目前版本(v2.4.7)中仍能复现[fix build error · Pull Request !103](https://gitee.com/src-openeuler/cups/pulls/103)中的构建失败问题,故选择在`fix-httpAddrGetList-test-case-fail.patch`的基础上修改,使得修改后使用clang也能构建成功。 + +- 错误信息表明试图将一个整数(`int`)类型的值传递给需要字符指针(`const char *`)类型的参数的函数。`gethostname`函数的参数和返回值要求如下: + + ```c + int gethostname(char *name, size_t len); + ``` + + `httpAddrGetList`需要的参数则是: + + ```c + extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_PUBLIC; + ``` + + `gethostname` 函数会将当前主机的名字复制到不超过 `len` 字节的`name` 指向的缓冲区中,如果 `len` 足够大,能够容纳完整的主机名以及末尾的空字符终止符,那么 `name` 缓冲区中的字符串将以空字符终止。返回的int值代表是否成功。 + +- 修改建议:按照原本的含义来说,传入`httpAddrGetList`的应该是`hostname`而非`gethostname`的返回值。因此应当将代码改为 + + ```c + gethostname(localhostname, sizeof(localhostname)); + addrlist = httpAddrGetList(localhostname, AF_UNSPEC, NULL); + ``` + + +- diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cyrus-sasl.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cyrus-sasl.md" new file mode 100644 index 0000000000000000000000000000000000000000..a32e444925085477215194691652abe52f88cd17 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/cyrus-sasl.md" @@ -0,0 +1,36 @@ +## cyrus-sasl + +### 问题描述 + +#### 报错信息 + +修改前 clang 构建在 `saslutil.c` 出现报错: + +``` +saslutil.c:280:3: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + 280 | time(&now); + | ^ +saslutil.c:364:34: error: call to undeclared function 'clock'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + 364 | ret[1] ^= (unsigned short) (clock() & 0xFFFF); + | ^ +saslutil.c:373:22: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + 373 | curtime = (long) time(NULL); /* better be at least 32 bits */ + | ^ +saslutil.c:377:33: error: call to undeclared function 'clock'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + 377 | ret[2] ^= (unsigned short) (clock() & 0xFFFF); + | ^ +saslutil.c:563:42: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare] + 563 | || strlen (result->ai_canonname) > namelen -1) { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~ +``` + +#### 相关PR + +- 上游社区 PR:[Fix check by thesamesam · Pull Request #709 · cyrusimap/cyrus-sasl (github.com)](https://github.com/cyrusimap/cyrus-sasl/pull/709) +- openEuler 仓库 PR:[Backport fix for time.h check for clang compilation · Pull Request !43 · src-openEuler/cyrus-sasl - Gitee.com](https://gitee.com/src-openeuler/cyrus-sasl/pulls/43) + +### 修复过程 + +- 回合上游已合并的PR。 +- 报错为调用未声明的函数,C99 标准及其以后的标准,隐式函数声明是不允许的,在调用函数之前,必须先声明或定义该函数。在clang16后,该warning升级为了error([New warnings and errors in Clang 16 ](https://www.redhat.com/en/blog/new-warnings-and-errors-clang-16))。本软件包中相关报错全部来源于`time.h`中的各种定义。backport的上游PR中,添加对`time.h`的include及头文件检查。 + diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/dpdk.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/dpdk.md" new file mode 100644 index 0000000000000000000000000000000000000000..42ac8f5eb8b8cd42aeb13ed9accfa991995a5a62 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/dpdk.md" @@ -0,0 +1,328 @@ +## dpdk + +#### 相关PR + +- 不涉及上游,openEuler仓库PR:[Support clang build (modify 2 meson.build and add -fgcc-compatible to cflags) · Pull Request !619 · src-openEuler/dpdk - Gitee.com](https://gitee.com/src-openeuler/dpdk/pulls/619) + +### 报错信息一 + +在修改前使用clang构建多次出现如下错误,软件包构建失败: + +``` +FAILED: drivers/libtmp_rte_common_mlx5.a.p/common_mlx5_linux_mlx5_glue.c.o +clang -Idrivers/libtmp_rte_common_mlx5.a.p -Idrivers -I../drivers -Idrivers/common/mlx5 -I../drivers/common/mlx5 -Idrivers/common/mlx5/linux -I../drivers/common/mlx5/linux -Ilib/hash -I../lib/hash -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/rcu -I../lib/rcu -Ilib/pci -I../lib/pci -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Idrivers/bus/auxiliary -I../drivers/bus/auxiliary -I/usr/include/libnl3 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c11 -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-missing-field-initializers -D_GNU_SOURCE -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/generic-hardened-clang.cfg -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcommon -fPIC -march=corei7 -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -fPIE -pie -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -std=c11 -Wno-strict-prototypes -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -UPEDANTIC -DRTE_LOG_DEFAULT_LOGTYPE=pmd.common.mlx5 -MD -MQ drivers/libtmp_rte_common_mlx5.a.p/common_mlx5_linux_mlx5_glue.c.o -MF drivers/libtmp_rte_common_mlx5.a.p/common_mlx5_linux_mlx5_glue.c.o.d -o drivers/libtmp_rte_common_mlx5.a.p/common_mlx5_linux_mlx5_glue.c.o -c ../drivers/common/mlx5/linux/mlx5_glue.c +clang: warning: -Wl,-z,relro,-z,now,-z,noexecstack: 'linker' input unused [-Wunused-command-line-argument] +clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument] +warning: unknown warning option '-Wtrampolines' [-Wunknown-warning-option] +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:58:6: error: redefinition of 'mlx5_ib_uapi_flow_action_packet_reformat_type' + 58 | enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, }; + | ^ +/usr/include/infiniband/mlx5_api.h:46:50: note: expanded from macro 'mlx5dv_flow_action_packet_reformat_type' + 46 | #define mlx5dv_flow_action_packet_reformat_type mlx5_ib_uapi_flow_action_packet_reformat_type + | ^ +/usr/include/infiniband/mlx5_user_ioctl_verbs.h:50:6: note: previous definition is here + 50 | enum mlx5_ib_uapi_flow_action_packet_reformat_type { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:59:6: error: redefinition of 'mlx5_ib_uapi_flow_table_type' + 59 | enum mlx5dv_flow_table_type { flow_table_type = 0, }; + | ^ +/usr/include/infiniband/mlx5_api.h:40:35: note: expanded from macro 'mlx5dv_flow_table_type' + 40 | #define mlx5dv_flow_table_type mlx5_ib_uapi_flow_table_type + | ^ +/usr/include/infiniband/mlx5_user_ioctl_verbs.h:42:6: note: previous definition is here + 42 | enum mlx5_ib_uapi_flow_table_type { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:68:8: error: redefinition of 'mlx5dv_devx_umem' + 68 | struct mlx5dv_devx_umem { uint32_t umem_id; }; + | ^ +/usr/include/infiniband/mlx5dv.h:1746:8: note: previous definition is here + 1746 | struct mlx5dv_devx_umem { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:69:8: error: redefinition of 'mlx5dv_devx_uar' + 69 | struct mlx5dv_devx_uar { void *reg_addr; void *base_addr; uint32_t page_id; }; + | ^ +/usr/include/infiniband/mlx5dv.h:1771:8: note: previous definition is here + 1771 | struct mlx5dv_devx_uar { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:78:7: error: redefinition of 'mlx5dv_dr_domain_type' + 78 | enum mlx5dv_dr_domain_type { unused, }; + | ^ +/usr/include/infiniband/mlx5dv.h:1933:6: note: previous definition is here + 1933 | enum mlx5dv_dr_domain_type { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:109:8: error: redefinition of 'mlx5dv_dr_flow_sampler_attr' + 109 | struct mlx5dv_dr_flow_sampler_attr { + | ^ +/usr/include/infiniband/mlx5dv.h:1953:8: note: previous definition is here + 1953 | struct mlx5dv_dr_flow_sampler_attr { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:119:6: error: redefinition of 'mlx5dv_dr_action_dest_type' + 119 | enum mlx5dv_dr_action_dest_type { + | ^ +/usr/include/infiniband/mlx5dv.h:2030:6: note: previous definition is here + 2030 | enum mlx5dv_dr_action_dest_type { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:120:2: error: redefinition of enumerator 'MLX5DV_DR_ACTION_DEST' + 120 | MLX5DV_DR_ACTION_DEST, + | ^ +/usr/include/infiniband/mlx5dv.h:2031:2: note: previous definition is here + 2031 | MLX5DV_DR_ACTION_DEST, + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:121:2: error: redefinition of enumerator 'MLX5DV_DR_ACTION_DEST_REFORMAT' + 121 | MLX5DV_DR_ACTION_DEST_REFORMAT, + | ^ +/usr/include/infiniband/mlx5dv.h:2032:2: note: previous definition is here + 2032 | MLX5DV_DR_ACTION_DEST_REFORMAT, + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:123:8: error: redefinition of 'mlx5dv_dr_action_dest_reformat' + 123 | struct mlx5dv_dr_action_dest_reformat { + | ^ +/usr/include/infiniband/mlx5dv.h:2035:8: note: previous definition is here + 2035 | struct mlx5dv_dr_action_dest_reformat { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:127:8: error: redefinition of 'mlx5dv_dr_action_dest_attr' + 127 | struct mlx5dv_dr_action_dest_attr { + | ^ +/usr/include/infiniband/mlx5dv.h:2040:8: note: previous definition is here + 2040 | struct mlx5dv_dr_action_dest_attr { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:137:8: error: redefinition of 'mlx5dv_devx_event_channel' + 137 | struct mlx5dv_devx_event_channel { int fd; }; + | ^ +/usr/include/infiniband/mlx5dv.h:1837:8: note: previous definition is here + 1837 | struct mlx5dv_devx_event_channel { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:139:9: warning: 'MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA' macro redefined [-Wmacro-redefined] + 139 | #define MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA 1 + | ^ +/usr/include/infiniband/mlx5_api.h:60:9: note: previous definition is here + 60 | #define MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA MLX5_IB_UAPI_DEVX_CR_EV_CH_FLAGS_OMIT_DATA + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:143:8: error: redefinition of 'mlx5dv_var' + 143 | struct mlx5dv_var { uint32_t page_id; uint32_t length; off_t mmap_off; + | ^ +/usr/include/infiniband/mlx5dv.h:1784:8: note: previous definition is here + 1784 | struct mlx5dv_var { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:152:8: error: redefinition of 'mlx5dv_steering_anchor_attr' + 152 | struct mlx5dv_steering_anchor_attr { + | ^ +/usr/include/infiniband/mlx5dv.h:748:8: note: previous definition is here + 748 | struct mlx5dv_steering_anchor_attr { + | ^ +In file included from ../drivers/common/mlx5/linux/mlx5_glue.c:17: +../drivers/common/mlx5/linux/mlx5_glue.h:158:8: error: redefinition of 'mlx5dv_steering_anchor' + 158 | struct mlx5dv_steering_anchor { + | ^ +/usr/include/infiniband/mlx5dv.h:754:8: note: previous definition is here + 754 | struct mlx5dv_steering_anchor { + | ^ +2 warnings and 15 errors generated. +``` + +#### 修复过程 + +- 上述错误的根源是,原本`0002-dpdk-add-secure-compile-option-and-fPIC-option.patch`使得在`drivers/meson.build`中增加如下代码: + + ``` + default_cflags += ['-fPIE', '-pie', '-fPIC', '-fstack-protector-strong', '-D_FORTIFY_SOURCE=2', '-O2', '-Wall'] + default_cflags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wtrampolines'] + ``` + + 于是构建时的`c_args`会添加上上述选项。而clang中链接选项需要传给链接器而不是以编译器参数传入,且不支持`-pie`和`-Wtrampolines`选项。 + + 这导致了在执行`drivers/common/mlx5/meson.build`中的 + + ``` + configure_file(output: 'mlx5_autoconf.h', configuration: mlx5_config) + ``` + + 时,在检测`infiniband/mlx5dv.h`等中的定义时,gcc对测试代码能成功编译并检测出定义情况,以`mlx5dv_devx_obj_create`为例: + + > gcc构建时:`build-gcc/meson-logs/meson-log.txt`片段: + > + > ``` + > Running compile: + > Working directory: /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-gcc/meson-private/tmpbopy1m2o + > Code: + > + > #include + > int main(void) { + > /* If it's not defined as a macro, try to use as a symbol */ + > #ifndef mlx5dv_devx_obj_create + > mlx5dv_devx_obj_create; + > #endif + > return 0; + > } + > ----------- + > Command line: `/usr/bin/gcc -I/usr/include/libnl3 /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-gcc/meson-private/tmpbopy1m2o/testfile.c -o /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-gcc/meson-private/tmpbopy1m2o/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -std=c11 -march=native -mno-avx512f -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -fPIE -pie -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -Wno-format-truncation -std=c11 -Wno-strict-prototypes -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -UPEDANTIC` -> 0 + > stderr: + > /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-gcc/meson-private/tmpbopy1m2o/testfile.c: In function 'main': + > /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-gcc/meson-private/tmpbopy1m2o/testfile.c:6:17: warning: statement with no effect [-Wunused-value] + > 6 | mlx5dv_devx_obj_create; + > | ^~~~~~~~~~~~~~~~~~~~~~ + > ----------- + > Header "infiniband/mlx5dv.h" has symbol "mlx5dv_devx_obj_create" with dependencies libmlx5, libibverbs: YES + > ``` + + 而clang编译由于命令行使用了`-Werror=unknown-warning-option -Werror=unused-command-line-argument`两个参数,所以会报错`clang: error: -Wl,-z,relro,-z,now,-z,noexecstack: 'linker' input unused [-Werror,-Wunused-command-line-argument]`从而导致检测失败(同理,`-pie`和`-Wtrampolines`也会导致clang error)。 + + > clang构建时:`build-clang/meson-logs/meson-log.txt`片段: + > + > ``` + > Running compile: + > Working directory: /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-clang/meson-private/tmp399v6yuc + > Code: + > + > #include + > int main(void) { + > /* If it's not defined as a macro, try to use as a symbol */ + > #ifndef mlx5dv_devx_obj_create + > mlx5dv_devx_obj_create; + > #endif + > return 0; + > } + > ----------- + > Command line: `/usr/bin/clang -I/usr/include/libnl3 /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-clang/meson-private/tmp399v6yuc/testfile.c -o /home/abuild/rpmbuild/BUILD/dpdk-23.11/build-clang/meson-private/tmp399v6yuc/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=c11 -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -fPIE -pie -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wall -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -std=c11 -Wno-strict-prototypes -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -UPEDANTIC` -> 1 + > stderr: + > clang: error: -Wl,-z,relro,-z,now,-z,noexecstack: 'linker' input unused [-Werror,-Wunused-command-line-argument] + > ----------- + > Header "infiniband/mlx5dv.h" has symbol "mlx5dv_devx_obj_create" with dependencies libmlx5, libibverbs: NO + > ``` + + 又因为在`drivers/common/mlx5/linux/meson.build`中使用了数组来确定是否定义宏: + + ``` + # input array for meson member search: + # [ "MACRO to define if found", "header for the search", + # "symbol to search", "struct member to search" ] + has_sym_args = [ + ... + [ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h', + 'mlx5dv_devx_obj_create' ], + ... + ] + ``` + + 从而,对于`build-clang/drivers/common/mlx5/mlx5_autoconf.h`,会对应地得到: + + ``` + #undef HAVE_IBV_DEVX_OBJ + ``` + + 而`build-gcc/drivers/common/mlx5/mlx5_autoconf.h`中则是: + + ``` + #define HAVE_IBV_DEVX_OBJ + ``` + + 而在`drivers/common/mlx5/linux/mlx5_glue.h`中通过该宏是否定义来决定是否定义一些结构体: + + ``` + #ifndef HAVE_IBV_DEVX_OBJ + struct mlx5dv_devx_obj; + struct mlx5dv_devx_umem { uint32_t umem_id; }; + struct mlx5dv_devx_uar { void *reg_addr; void *base_addr; uint32_t page_id; }; + #endif + ``` + + 由于上述原因clang构建时并没有定义`HAVE_IBV_DEVX_OBJ`,因此中间的几个原本在`infiniband/mlx5dv.h`中以及定义过的结构体被重新定义了,导致了开头所述的`error: redefinition of ...`的问题。 + + - 将`drivers/meson.build`中的`'-Wl,-z,relro,-z,now,-z,noexecstack'`改为作为链接参数而非编译参数传入;clang不支持的`-pie`和`-Wtrampolines`参数则改为当编译器支持时才添加后可以修复上述问题 + + + +### 报错信息二 + +- 上述问题修复后构建软件包会出现报错: + + ``` + [2284/2284] /usr/bin/make -j4 -C /lib/modules/6.6.0-15.0.0.13.mg2403.x86_64/build M=/home/abuild/rpmbuild/BUILD/dpdk-23.11/openEuler-linux-build/kernel/linux/igb_uio src=/home/abuild/rpmbuild/BUILD/dpdk-23.11/kernel/linux/igb_uio modules + FAILED: kernel/linux/igb_uio/igb_uio.ko + /usr/bin/make -j4 -C /lib/modules/6.6.0-15.0.0.13.mg2403.x86_64/build M=/home/abuild/rpmbuild/BUILD/dpdk-23.11/openEuler-linux-build/kernel/linux/igb_uio src=/home/abuild/rpmbuild/BUILD/dpdk-23.11/kernel/linux/igb_uio modules + make: Entering directory '/usr/src/kernels/6.6.0-15.0.0.13.mg2403.x86_64' + warning: the compiler differs from the one used to build the kernel + The kernel was built by: clang version 17.0.6 ( 17.0.6-8.mg2403) + You are using: gcc_old (GCC) 12.3.1 (openEuler 12.3.1-25.mg2403) + CC [M] /home/abuild/rpmbuild/BUILD/dpdk-23.11/openEuler-linux-build/kernel/linux/igb_uio/igb_uio.o + cc1: error: unrecognized command-line option ‘-mretpoline-external-thunk’ + cc1: note: unrecognized command-line option ‘-Wno-initializer-overrides’ may have been intended to silence earlier diagnostics + cc1: note: unrecognized command-line option ‘-Wno-tautological-constant-out-of-range-compare’ may have been intended to silence earlier diagnostics + cc1: note: unrecognized command-line option ‘-Wno-gnu’ may have been intended to silence earlier diagnostics + ``` + +#### 修复过程 + +- `igb_uio`由`0001-add-igb_uio.patch`引入,该报错的原因是`igb_uio`使用make构建时的命令并未指定编译器,默认使用了gcc而非clang,与kernel构建时使用的编译器clang不同。源代码中仅仅在`kernel/linux/meson.build`中指定了仅当交叉编译时会显式指定CC以及LD,而全部使用clang的情况并不会判定为交叉编译。 + +- 修复方式:向`kernel/linux/igb_uio/meson.build`中执行的`make`命令添加指定CC参数,当kernel使用clang时添加`CC=clang`后上述问题消失,clang构建成功。 添加的获取kernel使用的编译器是否为clang的代码比较粗糙。原本有一个很好的方案,即直接使用`CC=cc.get_id()`,但这样在OBS验证工程中并没有全部通过,在验证工程Mega:24.09有遇到过与上述报错恰恰相反的报错,即kernel使用gcc构建而其他都使用clang构建(也就是meson检测到的C编译器为clang)的情况,原因不太清楚。 + + + +### 报错信息三 + +在线上OBS验证工程Mega-LLVM:24.03中提供的standard_aarch64环境中,会出现如下失败日志: + +``` +... +[ 78s] Compiler for C supports arguments -Wcast-qual: NO +[ 78s] Compiler for C supports arguments -Wdeprecated: NO +[ 78s] Compiler for C supports arguments -Wformat: NO +[ 78s] Compiler for C supports arguments -Wformat-nonliteral: NO +[ 78s] Compiler for C supports arguments -Wformat-security: NO +[ 78s] Compiler for C supports arguments -Wmissing-declarations: NO +[ 78s] Compiler for C supports arguments -Wmissing-prototypes: NO +[ 78s] Compiler for C supports arguments -Wnested-externs: NO +[ 78s] Compiler for C supports arguments -Wold-style-definition: NO +[ 78s] Compiler for C supports arguments -Wpointer-arith: NO +[ 78s] Compiler for C supports arguments -Wsign-compare: NO +[ 78s] Compiler for C supports arguments -Wstrict-prototypes: NO +[ 78s] Compiler for C supports arguments -Wundef: NO +[ 78s] Compiler for C supports arguments -Wwrite-strings: NO +[ 78s] Compiler for C supports arguments -Wno-address-of-packed-member: NO +[ 78s] Compiler for C supports arguments -Wno-packed-not-aligned: NO +[ 78s] Compiler for C supports arguments -Wno-missing-field-initializers: NO +[ 78s] Message: Arm implementer: Generic armv8 +[ 78s] Message: Arm part number: generic +[ 78s] Compiler for C supports arguments -march=armv8-a: NO +[ 78s] +[ 78s] config/arm/meson.build:721:12: ERROR: Problem encountered: No suitable armv8 march version found. +[ 78s] +[ 78s] A full log can be found at /home/abuild/rpmbuild/BUILD/dpdk-23.11/openEuler-linux-build/meson-logs/meson-log.txt +[ 78s] error: Bad exit status from /var/tmp/rpm-tmp.GLGYUR (%build) +[ 78s] +[ 78s] RPM build errors: +[ 78s] Bad exit status from /var/tmp/rpm-tmp.GLGYUR (%build) +[ 78s] +[ 78s] failed "build dpdk.spec" at Thu Sep 19 05:59:41 UTC 2024. +``` + +#### 修复过程 + +- 分析过程:发现OBS里的Mega:24.09的aarch64不会出现该报错。经过对比构建日志发现二者环境中的CFLAGS不同,进而尝试之下发现添加`-fgcc-compatible`可以解决该问题。 + +- 原因分析:因为meson函数cc.has_argument函数会产生-wunused-commond-line报错,加-fgcc-compitable可以绕过。 + +- 修复方式:在spec中向`CFLAGS`中添加`-fgcc-compatible`: + + ``` + - CFLAGS="$(echo %{optflags} -fcommon)" \ + + CFLAGS="$(echo %{optflags} -fcommon %[ "%{toolchain}" == "clang" ? "-fgcc-compatible" : "" ])" \ + ``` + + (实际上由于版本升级中已经解决了该问题,故未进行修改当作已修复) diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freeradius.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freeradius.md" new file mode 100644 index 0000000000000000000000000000000000000000..414c129986b5879df8519edf8cfb33ae83ad17a4 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freeradius.md" @@ -0,0 +1,59 @@ +## freeradius + +### 问题描述 + +#### 报错信息 + +修改前clang构建失败,出现.d和.lo文件不生成的问题。出现类似: + +``` +[ 726s] mkdir -p build/objs/src/lib/ +[ 726s] echo CC src/lib/cbuff.c +[ 726s] CC src/lib/cbuff.c +[ 726s] build/make/jlibtool --silent --mode=compile clang -o build/objs/src/lib/cbuff.lo -c -MD -I. -Isrc -include src/freeradius-devel/autoconf.h -include src/freeradius-devel/build.h -include src/freeradius-devel/features.h -include src/freeradius-devel/radpaths.h -fno-strict-aliasing -Wno-date-time -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/generic-hardened-clang.cfg -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fsigned-char -Wall -std=c99 -D_GNU_SOURCE -Wno-unknown-warning-option -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DOPENSSL_NO_KRB5 -DNDEBUG -D_LIBRADIUS -I/home/abuild/rpmbuild/BUILD/freeradius-server-3.2.3/src src/lib/cbuff.c +[ 726s] mkdir -p build/make/src/src/lib/ +[ 726s] mkdir -p build/objs/src/lib/ +[ 726s] sed -e 's/#.*//' -e 's,^/home/abuild/rpmbuild/BUILD/freeradius-server-3.2.3,${top_srcdir},' -e 's, /home/abuild/rpmbuild/BUILD/freeradius-server-3.2.3, ${top_srcdir},' -e 's,^build,${BUILD_DIR},' -e 's, build/make/include/[^ :]*,,' -e 's, build, ${BUILD_DIR},' -e 's, /[^: ]*,,g' -e 's,^ *[^:]* *: *$,,' -e '/: build/make/src/src/lib/cbuff.mk +[ 726s] sed -e 's/#.*//' -e 's, build/make/include/[^ :]*,,' -e 's, /[^: ]*,,g' -e 's,^ *[^:]* *: *$,,' -e '/: > build/make/src/src/lib/cbuff.mk +[ 726s] /bin/sh: line 1: build/objs/src/lib/cbuff.d: No such file or directory +[ 726s] /bin/sh: line 1: build/objs/src/lib/cbuff.d: No such file or directory +``` + +等的很多.d文件`No such file or directory`的报错,最终在链接阶段由于.lo文件缺失导致构建失败: + +``` +[ 198s] build/make/jlibtool --silent --mode=link clang -o build/lib/libfreeradius-radius.la -rpath /usr/lib64/freeradius -Wl,-z,relro -Wl,-z,now -Wl,-z,relro -Wl,-z,now build/objs/src/lib/cbuff.lo build/objs/src/lib/cursor.lo build/objs/src/lib/debug.lo build/objs/src/lib/dict.lo build/objs/src/lib/filters.lo build/objs/src/lib/hash.lo build/objs/src/lib/hmacmd5.lo build/objs/src/lib/hmacsha1.lo build/objs/src/lib/isaac.lo build/objs/src/lib/log.lo build/objs/src/lib/misc.lo build/objs/src/lib/missing.lo build/objs/src/lib/md4.lo build/objs/src/lib/md5.lo build/objs/src/lib/net.lo build/objs/src/lib/pair.lo build/objs/src/lib/pcap.lo build/objs/src/lib/print.lo build/objs/src/lib/radius.lo build/objs/src/lib/rbtree.lo build/objs/src/lib/regex.lo build/objs/src/lib/sha1.lo build/objs/src/lib/snprintf.lo build/objs/src/lib/strlcat.lo build/objs/src/lib/strlcpy.lo build/objs/src/lib/socket.lo build/objs/src/lib/token.lo build/objs/src/lib/udpfromto.lo build/objs/src/lib/value.lo build/objs/src/lib/fifo.lo build/objs/src/lib/packet.lo build/objs/src/lib/event.lo build/objs/src/lib/getaddrinfo.lo build/objs/src/lib/heap.lo build/objs/src/lib/tcp.lo build/objs/src/lib/base64.lo build/objs/src/lib/version.lo build/objs/src/lib/atomic_queue.lo build/objs/src/lib/talloc.lo -lcrypto -lssl -ltalloc -latomic -lpcre -lresolv -ldl -lpthread -lreadline -lpcap +[ 198s] Can not find suitable object file for build/objs/src/lib/cbuff.lo +[ 198s] make: *** [scripts/boiler.mk:638: build/lib/libfreeradius-radius.la] Error 1 +``` + +#### 相关PR + +- 上游社区pr:[jlibtool: avoid conflict with Clang's --config option by yanyir · Pull Request #5443 · FreeRADIUS/freeradius-server (github.com)](https://github.com/FreeRADIUS/freeradius-server/pull/5443) +- openEuler仓库pr:[Fix clang build: avoid conflict with clang's "--config" option in jlibtool · Pull Request !92 · src-openEuler/freeradius - Gitee.com](https://gitee.com/src-openeuler/freeradius/pulls/92) + +### 修复过程 + +- 在构建目录下命令行单独执行 + + ``` + build/make/jlibtool --silent --mode=compile clang -o build/objs/src/lib/cbuff.lo -c -MD -I. -Isrc -include src/freeradius-devel/autoconf.h -include src/freeradius-devel/build.h -include src/freeradius-devel/features.h -include src/freeradius-devel/radpaths.h -fno-strict-aliasing -Wno-date-time -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/generic-hardened-clang.cfg -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fsigned-char -Wall -std=c99 -D_GNU_SOURCE -Wno-unknown-warning-option -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DOPENSSL_NO_KRB5 -DNDEBUG -D_LIBRADIUS -I/home/abuild/rpmbuild/BUILD/freeradius-server-3.2.3/src src/lib/cbuff.c + ``` + + 发现没有产生新的.d和.lo文件,但执行其中的clang -o ...可以正常执行并产生对应的.d和.lo文件,判断问题出现在jlibtool上。 + + 而使用gcc构建的工程可以成功产生.d和.lo文件,对应的命令为: + + ``` + build/make/jlibtool --silent --mode=compile gcc -o build/objs/src/lib/cbuff.lo -c -MD -I. -Isrc -include src/freeradius-devel/autoconf.h -include src/freeradius-devel/build.h -include src/freeradius-devel/features.h -include src/freeradius-devel/radpaths.h -fno-strict-aliasing -Wno-date-time -O2 -g -grecord-gcc-switches -pipe -fstack-protector-strong -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/generic-hardened-cc1 -fasynchronous-unwind-tables -fstack-clash-protection -Wall -std=c99 -D_GNU_SOURCE -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DOPENSSL_NO_KRB5 -DNDEBUG -D_LIBRADIUS -I/home/abuild/rpmbuild/BUILD/freeradius-server-3.2.3/src src/lib/cbuff.c + ``` + + 对比clang和gcc使用的命令发现问题可能出现在gcc构建时配置中是以`-specs=/usr/lib/rpm/generic-hardened-cc1`而非clang时的`--config /usr/lib/rpm/generic-hardened-clang.cfg`来指定的配置文件。 + +- 尝试在上述`build/make/jlibtool --silent --mode=compile clang -o...`中去掉`--config /usr/lib/rpm/generic-hardened-clang.cfg`,发现可以正常产生.d和.lo文件的。 + +- 查看jlibtool的代码,发现问题出现在jlibtool有一个`--config`参数,用于展示当前的配置项内容。然而clang中的`--config`参数是用于指定使用的配置文件,见: + [Clang command line argument reference — Clang 17.0.1 documentation (llvm.org)](https://gitee.com/link?target=https%3A%2F%2Freleases.llvm.org%2F17.0.1%2Ftools%2Fclang%2Fdocs%2FClangCommandLineReference.html%23cmdoption-clang-config) + 如果放任冲突存在,会导致原本CFLAGS中的 `--config `参数错误地被jlibtool接收,然后误认为只是要打印配置项,而非执行期望中传递给clang编译器进行编译的行为,从而不产生构建时需要的各种文件。 + +- **修改建议**:将`script/jlibtool.c`中的`--config`参数改为不与clang冲突的其他名称,如`--print-config` diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freerdp.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freerdp.md" new file mode 100644 index 0000000000000000000000000000000000000000..1eed3249473f9cec8bbe2258b124cf64be460131 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/freerdp.md" @@ -0,0 +1,46 @@ +## freerdp + +### 问题描述 + +#### 报错信息 + +修改前 clang 构建在 `wlfreerdp.c` 出现报错: + +``` +/home/abuild/rpmbuild/BUILD/freerdp-2.11.7/client/Wayland/wlfreerdp.c:637:19: error: incompatible function pointer types assigning to 'OBJECT_NEW_FN' (aka 'void *(*)(void *)') from 'void *(const void *)' [-Wincompatible-function-pointer-types] + 637 | obj->fnObjectNew = uwac_event_clone; + | ^ ~~~~~~~~~~~~~~~~ +``` + +#### 相关PR + +- 原有上游社区 PR:[Fixes clang error by wangmingyu84 · Pull Request #9373 · FreeRDP/FreeRDP (github.com)](https://github.com/FreeRDP/FreeRDP/pull/9373) + +- openEuler 仓库 PR:[Fix clang incompatible function pointer error · Pull Request !116 · src-openEuler/freerdp - Gitee.com](https://gitee.com/src-openeuler/freerdp/pulls/116) + +### 修复过程 + +- 在已有上游社区 PR:[Fixes clang error by wangmingyu84 · Pull Request #9373 · FreeRDP/FreeRDP (github.com)](https://github.com/FreeRDP/FreeRDP/pull/9373)当中: + + - 由于PR作者未更新到最新版本而是针对落后版本的`collection.h`进行了修改,因此该PR被上游代码仓管理者关闭。修复时中间仓freerdp版本为2.11.7,同样使用了未更新的`collection.h`,但更改到该行代码的上游commit:[Cleaned up collections: · FreeRDP/FreeRDP@6e3c007 (github.com)](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2FFreeRDP%2FFreeRDP%2Fcommit%2F6e3c00725aae99d03a0baa65430eceddebd9dee8)与2.11.7的commit:[release-2.11.7 · FreeRDP/FreeRDP@7f6cc93 (github.com)](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2FFreeRDP%2FFreeRDP%2Fcommit%2F7f6cc93c21d7f0faad6daacca06f494f29ce882c)之间涉及到的文件过多,更改过大,选择仅按照上游社区的代码修改变更报错涉及的三处代码。 + +- 该报错的原因为 clang 对类型的检查比 gcc 更严格,该clang error在gcc中只是warning。相关代码行中`obj->fnObjectNew`的类型定义为: + + ```c + typedef void* (*OBJECT_NEW_FN)(void* val); + ``` + + 即`void *(*)(void *)`,不符合需求的`void *(const void *)` + + 修改类型定义以及涉及的相应的函数参数类型即可修复,如: + + ``` + - typedef void* (*OBJECT_NEW_FN)(void* val); + + typedef void* (*OBJECT_NEW_FN)(const void* val); + ``` + + ``` + -static void* rfx_decoder_tile_new(void* val) + +static void* rfx_decoder_tile_new(const void* val) + ``` + diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/iSulad.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/iSulad.md" new file mode 100644 index 0000000000000000000000000000000000000000..6a2572fda2ac91696d9c4bff354a144e0356bfd6 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/iSulad.md" @@ -0,0 +1,340 @@ +## iSulad + +#### 相关PR + +- **上游社区pr**:[Fix clang build error · Pull Request !2500 · openEuler/iSulad - Gitee.com](https://gitee.com/openeuler/iSulad/pulls/2500) +- **openEuler中间仓pr**:[Fix clang build error · Pull Request !729 · src-openEuler/iSulad - Gitee.com](https://gitee.com/src-openeuler/iSulad/pulls/729) + +### 报错信息一 + +修改前 clang 构建在 `stream_server.h` 出现报错`error: 'cri_stream_server_url' has C-linkage specified, but returns user-defined type 'url::URLDatum' which is incompatible with C [-Werror,-Wreturn-type-c-linkage]`: + +``` +In file included from /home/abuild/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/connect/grpc/cri/cri_service.cc:19: +/home/abuild/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/streams/stream_server.h:30:15: error: 'cri_stream_server_url' has C-linkage specified, but returns user-defined type 'url::URLDatum' which is incompatible with C [-Werror,-Wreturn-type-c-linkage] + 30 | url::URLDatum cri_stream_server_url(void); + | ^ +1 error generated. +``` + +#### 修复过程 + +- **根因分析**: + + 原本`url::URLDatum cri_stream_server_url(void);`被包裹在`extern "C" {}`中: + + ```c + #ifdef __cplusplus + extern "C" { + #endif + + ... + url::URLDatum cri_stream_server_url(void); + + #ifdef __cplusplus + } + #endif + ``` + + `extern "C"`是C++特有的一个关键字,用来告诉编译器函数或者变量是以C语言的方式进行链接的。使用`extern "C"`来声明函数或变量时,是在告诉编译器虽然其中的内容是在C++代码中定义的,但应该用C语言的方式来进行链接。但`url::URLDatum`一个用户定义的类型,在C语言中是无法直接处理的。 + +- 参考了GitHub上对于该报错的修改方案,在移除了`stream_server.h`中的 + + ``` + #ifdef __cplusplus + extern "C" { + #endif + + #ifdef __cplusplus + } + #endif + ``` + + 后该报错消失。 + +- 在maintainer的建议下,发现没必要全部删除`extern "C"`,将涉及的代码移出`extern "C"`块更为合适。如: + + ```c + #ifdef __cplusplus + extern "C" { + #endif + + ... + + #ifdef __cplusplus + } + #endif + + url::URLDatum cri_stream_server_url(void); + ``` + + + +### 报错信息二 + +`error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_image_manager_service_impl.cc:152:26: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] + 152 | images.push_back(move(image)); + | ^ + | std:: +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc:693:30: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] + 693 | containers.push_back(move(container)); + | ^ + | std:: +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:1173:16: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] + 1173 | podStats = move(podStatsPtr); + | ^ + | std:: +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:1323:29: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] + 1323 | podsStats.push_back(move(podStats)); + | ^ + | std:: +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1alpha/cri_image_manager_service_impl.cc:152:26: + error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc:693:30: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:1173:16: + error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:1323:29: + error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call] +... +``` + +#### 修复过程 + +- 报错原因:代码中一些地方将应以`std::move`调用的`std::move`写成了`move`,如: + + ``` + containers.push_back(move(container)); + ``` + +- 修复方式:将对应的`move`改为`std::move`后解决 + + ``` + containers.push_back(std::move(container)); + ``` + + + +### 报错信息三 + +`error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:1182:38: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] + 1182 | cgroup_metrics_t cgroupMetrics { 0 }; + | ^ + | {} +... +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc:1574:38: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] + 1574 | cgroup_metrics_t cgroupMetrics { 0 }; + | ^ + | {} +``` + +#### 修复过程 + +- 报错原因:对象初始化的时候缺失花括号,如: + + ``` + cgroup_metrics_t cgroupMetrics { 0 }; + ``` + +- 修复方式:将初始化中的`{ 0 }`改为`{{ 0 }}` + + ``` + cgroup_metrics_t cgroupMetrics {{ 0 }}; + ``` + + + +### 报错信息四 + +`error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:508:15: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] + 508 | ERROR(tmp_errmsg.c_str()); + | ^~~~~~~~~~~~~~~~~~ + /usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^~~~~~ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:508:15: note: treat the string as an argument to avoid this + 508 | ERROR(tmp_errmsg.c_str()); + | ^ + | "%s", +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:523:19: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] + 523 | ERROR(list_response->errmsg); + | ^~~~~~~~~~~~~~~~~~~~~ +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^~~~~~ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:523:19: note: treat the string as an argument to avoid this + 523 | ERROR(list_response->errmsg); + | ^ + | "%s", +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:523:19: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] + 523 | ERROR(list_response->errmsg); + | ^~~~~~~~~~~~~~~~~~~~~ +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^~~~~~ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc:523:19: note: treat the string as an argument to avoid this + 523 | ERROR(list_response->errmsg); + | ^ + | "%s", +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^ +``` + +#### 修复过程 + +- 报错原因:两处传入字符串时未进行格式化,如: + + ``` + ERROR(tmp_errmsg.c_str()); + ``` + +- 修复方式:使用`%s`进行格式化: + + ``` + ERROR("%s", tmp_errmsg.c_str()); + ``` + + + +### 报错信息五 + +`error: cannot pass non-trivial object of type 'std::string' (aka 'basic_string') to variadic function; expected type from format string was 'char *' [-Wnon-pod-varargs]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/common/cri/cri_helpers.cc:528:92: error: cannot pass non-trivial object of type 'std::string' (aka 'basic_string') to variadic function; expected type from format string was 'char *' [-Wnon-pod-varargs] + 528 | SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path); + | ~~ ^~~~ +/usr/include/isula_libutils/log.h:414:32: note: expanded from macro 'SYSERROR' + 414 | ERROR("%s - " format, ptr, ##__VA_ARGS__); \ + | ~~~~~~ ^~~~~~~~~~~ +/usr/include/isula_libutils/log.h:356:32: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ~~~~~~ ^~~~~~~~~~~ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/common/cri/cri_helpers.cc:528:92: note: did you mean to call the c_str() method? +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/common/cri/cri_helpers.cc:529:96: error: cannot pass object of non-trivial type 'std::string' (aka 'basic_string') through variadic method; call will abort at runtime [-Wnon-pod-varargs] + 529 | error.Errorf("Failed to remove container %s log symlink %s.", containerID.c_str(), path); + | ^ +``` + +#### 修复过程 + +- 报错原因:在尝试将 `std::string` 类型的对象作为可变参数列表传递给函数时遇到了报错。在c++中,`std::string` 是一个复杂的类类型,它包含内部状态和方法,因此不能直接作为变长参数传递给函数,除非该函数明确地知道如何处理 `std::string` 对象。对应代码比如: + + ``` + SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path); + ``` + +- 修复方式:加入`.c_str()`调用,如: + + ``` + SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path.c_str()); + ``` + + + +### 报错信息六 + +`error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/sandbox/sandbox_ops.cc:75:19: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] + 75 | params.spec = std::move(std::unique_ptr(new std::string(oci_spec))); + | ^ +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/sandbox/sandbox_ops.cc:75:19: note: remove std::move call here + 75 | params.spec = std::move(std::unique_ptr(new std::string(oci_spec))); + | ^~~~~~~~~~~ +``` + +#### 修复过程 + +- 报错原因:代码中试图移动一个临时对象,建议删除`std::move`,关联代码: + + ``` + params.spec = std::move(std::unique_ptr(new std::string(oci_spec))); + ``` + +- 修复方式:将此处的`std::move`移除: + + ``` + params.spec = std::unique_ptr(new std::string(oci_spec)); + ``` + + + +### 报错信息七 + +`error: more '%' conversions than data arguments [-Werror,-Wformat-insufficient-args]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/sandbox/sandbox.cc:850:41: error: more '%' conversions than data arguments [-Werror,-Wformat-insufficient-args] + 850 | SYSERROR("Failed to write file %s"); + | ~^ +/usr/include/isula_libutils/log.h:414:17: note: expanded from macro 'SYSERROR' + 414 | ERROR("%s - " format, ptr, ##__VA_ARGS__); \ + | ^~~~~~ +/usr/include/isula_libutils/log.h:356:22: note: expanded from macro 'ERROR' + 356 | LXC_ERROR(&locinfo, format, ##__VA_ARGS__); \ + | ^~~~~~ +``` + +#### 修复过程 + +- 报错原因:代码中出现多余的`%s`,具体代码为: + + ``` + SYSERROR("Failed to write file %s"); + ``` + +- 修复方式:根据代码语义,加入`%s`的对应字符串`path.c_str()`: + + ``` + SYSERROR("Failed to write file %s", path.c_str()); + ``` + + + +### 报错信息八 + +`error: private field 'm_enablePodEvents' is not used [-Werror,-Wunused-private-field]` + +``` +/root/rpmbuild/BUILD/iSulad-v2.1.5/src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h:107:10: error: private field 'm_enablePodEvents' is not used [-Werror,-Wunused-private-field] + 107 | bool m_enablePodEvents; + | ^ +1 error generated. +``` + +#### 修复过程 + +- 报错原因:私有变量`m_enablePodEvents`被认为是没被用到的,但实际上并不是完全没有用到。 + +- 修复方式:参考StackOverflow的帖子([c++ - Good way to fix warning "field a is not used" if field is unused in configuration - Stack Overflow](https://stackoverflow.com/questions/48192418/good-way-to-fix-warning-field-a-is-not-used-if-field-is-unused-in-configuratio/48192493#48192493)),在声明之前添加了`[[maybe_unused]]` + + ``` + [[maybe_unused]] bool m_enablePodEvents; + ``` + + + diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/jemalloc.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/jemalloc.md" new file mode 100644 index 0000000000000000000000000000000000000000..3d93676a1754318aca325aa79c34c8f63763e451 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/jemalloc.md" @@ -0,0 +1,109 @@ +## jemalloc + +### 问题描述 + +#### 报错信息 + +修改前使用clang构建出现如下错误,导致软件包构建于check阶段失败: + +``` + test_alignment_errors:test/integration/aligned_alloc.c:24: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 0 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 9 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 17 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 33 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 129 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 257 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 513 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1025 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2049 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4097 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 8193 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 16385 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 32769 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65537 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 131073 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 262145 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 524289 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1048577 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2097153 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4194305 + test_alignment_errors (non-reentrant): fail + test_alignment_errors:test/integration/aligned_alloc.c:24: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 0 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 9 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 17 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 33 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 129 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 257 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 513 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1025 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2049 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4097 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 8193 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 16385 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 32769 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65537 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 131073 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 262145 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 524289 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1048577 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2097153 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4194305 + test_alignment_errors (libc-reentrant): fail + test_alignment_errors:test/integration/aligned_alloc.c:24: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 0 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 9 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 17 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 33 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 129 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 257 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 513 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1025 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2049 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4097 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 8193 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 16385 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 32769 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 65537 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 131073 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 262145 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 524289 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 1048577 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 2097153 + test_alignment_errors:test/integration/aligned_alloc.c:32: Failed assertion: (p != ((void*)0) || get_errno() != 22) == (0) --> true != false: Expected error for invalid alignment 4194305 + test_alignment_errors (arena_new-reentrant): fail + test_oom_errors:test/integration/aligned_alloc.c:63: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(9223372036854775808, 9223372036854775808) + test_oom_errors:test/integration/aligned_alloc.c:76: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(4611686018427387904, 13835058055282163713) + test_oom_errors:test/integration/aligned_alloc.c:88: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(&p, 16, 18446744073709551600) + test_oom_errors (non-reentrant): fail + test_oom_errors:test/integration/aligned_alloc.c:63: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(9223372036854775808, 9223372036854775808) + test_oom_errors:test/integration/aligned_alloc.c:76: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(4611686018427387904, 13835058055282163713) + test_oom_errors:test/integration/aligned_alloc.c:88: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(&p, 16, 18446744073709551600) + test_oom_errors (libc-reentrant): fail + test_oom_errors:test/integration/aligned_alloc.c:63: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(9223372036854775808, 9223372036854775808) + test_oom_errors:test/integration/aligned_alloc.c:76: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(4611686018427387904, 13835058055282163713) + test_oom_errors:test/integration/aligned_alloc.c:88: Failed assertion: (p != ((void*)0) || get_errno() != 12) == (0) --> true != false: Expected error for aligned_alloc(&p, 16, 18446744073709551600) + test_oom_errors (arena_new-reentrant): fail +``` + +#### 相关PR + +- 上游社区pr:[Add attribute to compile some tests in aligned_alloc.c with no optimization by yanyir · Pull Request #2704 · jemalloc/jemalloc (github.com)](https://github.com/jemalloc/jemalloc/pull/2704) + +- openEuler中间仓pr:[Support clang build -- Add attribute to compile some tests in aligned_alloc.c with no optimization · Pull Request !43 · src-openEuler/jemalloc - Gitee.com](https://gitee.com/src-openeuler/jemalloc/pulls/43) + +### 修复过程 + +- 上游社区已有对应issue:[Test failure on macOS Sonoma · Issue #2540 · jemalloc/jemalloc (github.com)](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Fjemalloc%2Fjemalloc%2Fissues%2F2540),issue作者使用apple的clang进行测试,遇到该问题,指出问题的根源在于clang将代码优化后关键代码消失,故不能产生预期输出。该作者向Homebrew社区提了issue并得到合并:[jemalloc: fix build with Xcode 15 by fxcoudert · Pull Request #146688 · Homebrew/homebrew-core (github.com)](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2FHomebrew%2Fhomebrew-core%2Fpull%2F146688)。但jemalloc的作者并未对此问题做出修正,issue作者的解决方案为在clang版本大于等于15时只执行`make`而非`make check`。 + +- 更好的做法应该是对这些特定的测试用例不做编译优化,比如使用`__attribute__((optnone))` + +- **修复建议**:在出问题的两个测试函数之前加上 + + ```c + #if __clang__ + __attribute__((optnone)) + #endif + ``` + diff --git "a/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/libXt.md" "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/libXt.md" new file mode 100644 index 0000000000000000000000000000000000000000..a4b4b9125b84cf7ae00877e833a50a1293267a70 --- /dev/null +++ "b/LLVM Parallel Universe Project/\351\227\256\351\242\230\345\256\232\344\275\215\346\200\273\347\273\223/OSPP2024-LLVM\346\236\204\345\273\272openEuler\350\275\257\344\273\266\345\214\205\345\205\274\345\256\271\346\200\247\351\227\256\351\242\230\345\210\206\346\236\220\345\217\212\350\247\243\345\206\263(Part III)/libXt.md" @@ -0,0 +1,260 @@ +## libXt + +### 问题描述 + +#### 报错信息 + +在修改前使用clang构建出现错误,软件包构建于check阶段失败: + +``` ++ make check +Making check in util +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/util' +make[1]: Nothing to be done for 'check'. +make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/util' +Making check in src +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/src' +make check-am +make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/src' +make[2]: Nothing to be done for 'check-am'. +make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/src' +make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/src' +Making check in include +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/include' +make[1]: Nothing to be done for 'check'. +make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/include' +Making check in man +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/man' +make[1]: Nothing to be done for 'check'. +make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/man' +Making check in specs +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/specs' +make[1]: Nothing to be done for 'check'. +make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/specs' +Making check in test +make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/test' +make Alloc Converters Event +make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/test' + CC Alloc.o + CCLD Alloc + CC Converters.o + CCLD Converters + CC Event.o +Event.c:51:1: warning: function 'sigalrm' could be declared with attribute 'noreturn' [-Wmissing-noreturn] + 51 | { + | ^ +1 warning generated. + CCLD Event +make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/test' +make check-TESTS +make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/test' +make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/libXt-1.3.0/test' +../test-driver: line 112: 9366 Aborted (core dumped) "$@" >> "$log_file" 2>&1 +FAIL: Alloc +PASS: Converters +PASS: Event +============================================================================ +Testsuite summary for libXt 1.3.0 +============================================================================ +# TOTAL: 3 +# PASS: 2 +# SKIP: 0 +# XFAIL: 0 +# FAIL: 1 +# XPASS: 0 +# ERROR: 0 +============================================================================ +See test/test-suite.log +Please report to https://gitlab.freedesktop.org/xorg/lib/libxt/-/issues/ +``` + +其中,test/test-suite.log显示为: + +``` +====================================== + libXt 1.3.0: test/test-suite.log +====================================== + +# TOTAL: 3 +# PASS: 2 +# SKIP: 0 +# XFAIL: 0 +# FAIL: 1 +# XPASS: 0 +# ERROR: 0 + +.. contents:: :depth: 2 + +FAIL: Alloc +=========== + +TAP version 13 +# random seed: R02S8d0db6758044940514b2e6e038c63bd3 +1..18 +# Start of Alloc tests +# Start of XtAsprintf tests +ok 1 /Alloc/XtAsprintf/short +ok 2 /Alloc/XtAsprintf/long +# End of XtAsprintf tests +# Start of XtMalloc tests +ok 3 /Alloc/XtMalloc/normal +ok 4 /Alloc/XtMalloc/zero +Warning: This program is an suid-root program or is being run by the root user. +The full text of the error or warning message cannot be safely formatted +in this environment. You may get a more descriptive message by running the +program as a non-root user or by removing the suid bit on the executable. +Caught Error: Cannot perform %s +ok 5 /Alloc/XtMalloc/oversize +ok 6 /Alloc/XtMalloc/overflow # SKIP overflow not possible in this config +# End of XtMalloc tests +# Start of XtCalloc tests +ok 7 /Alloc/XtCalloc/normal +ok 8 /Alloc/XtCalloc/zero +Warning: This program is an suid-root program or is being run by the root user. +The full text of the error or warning message cannot be safely formatted +in this environment. You may get a more descriptive message by running the +program as a non-root user or by removing the suid bit on the executable. +Caught Error: Cannot perform %s +ok 9 /Alloc/XtCalloc/oversize +ok 10 /Alloc/XtCalloc/overflow # SKIP overflow not possible in this config +# End of XtCalloc tests +# Start of XtRealloc tests +ok 11 /Alloc/XtRealloc/normal +Warning: This program is an suid-root program or is being run by the root user. +The full text of the error or warning message cannot be safely formatted +in this environment. You may get a more descriptive message by running the +program as a non-root user or by removing the suid bit on the executable. +Caught Error: Cannot perform %s +ok 12 /Alloc/XtRealloc/zero +ok 13 /Alloc/XtRealloc/overflow # SKIP overflow not possible in this config +free(): double free detected in tcache 2 +FAIL Alloc (exit status: 134) +``` + +#### 相关PR + +- 上游社区PR:https://gitlab.freedesktop.org/xorg/util/macros/-/merge_requests/8 +- openEuler仓库pr:https://gitee.com/src-openeuler/libXt/pulls/31 + +### 修复过程 + +- 上游社区没有相关issue。问题的根源是软件包中的文件都使用了-O2的编译优化,当使用clang构建时,-O1及以上的优化水平会导致clang将malloc优化掉,从而在`configure`脚本中的这一段: + + ``` + # Check whether --enable-malloc0returnsnull was given. + if test ${enable_malloc0returnsnull+y} + then : + enableval=$enable_malloc0returnsnull; MALLOC_ZERO_RETURNS_NULL=$enableval + else $as_nop + MALLOC_ZERO_RETURNS_NULL=auto + fi + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether malloc(0) returns NULL" >&5 + printf %s "checking whether malloc(0) returns NULL... " >&6; } + if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then + if test ${xorg_cv_malloc0_returns_null+y} + then : + printf %s "(cached) " >&6 + else $as_nop + if test "$cross_compiling" = yes + then : + printf %s "(cached) " >&6 + else $as_nop + if test "$cross_compiling" = yes + then : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + as_fn_error $? "cannot run test program while cross compiling + See \`config.log' for more details" "$LINENO" 5; } + else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + + #include + + int + main (void) + { + + char *m0, *r0, *c0, *p; + m0 = malloc(0); + p = malloc(10); + r0 = realloc(p,0); + c0 = calloc(0,10); + exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1); + + ; + return 0; + } + _ACEOF + if ac_fn_c_try_run "$LINENO" + then : + xorg_cv_malloc0_returns_null=yes + else $as_nop + xorg_cv_malloc0_returns_null=no + fi + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext + fi + + fi + + MALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MALLOC_ZERO_RETURNS_NULL" >&5 + printf "%s\n" "$MALLOC_ZERO_RETURNS_NULL" >&6; } + + if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then + MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL" + XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS + XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC" + else + MALLOC_ZERO_CFLAGS="" + XMALLOC_ZERO_CFLAGS="" + XTMALLOC_ZERO_CFLAGS="" + fi + ``` + + 当中的conftest获得了与gcc不同的结果(若编译时采用-O0,clang的脚本执行结果与gcc相同),从而本应执行的`MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"`变为了`MALLOC_ZERO_CFLAGS=""`,从而导致在`src/Alloc.c`中以下函数执行时, + + ``` + char * + XtRealloc(char *ptr, unsigned size) + { + if (ptr == NULL) { + #ifdef MALLOC_0_RETURNS_NULL + if (!size) + size = 1; + #endif + return (XtMalloc(size)); + } + else if ((ptr = Xrealloc(ptr, size)) == NULL + #ifdef MALLOC_0_RETURNS_NULL + && size + #endif + ) + _XtAllocError("realloc"); + + return (ptr); + } + ``` + + 由于没有定义`MALLOC_0_RETURNS_NULL`所以不会判断`&& size`,做出错误的行为。但是`configure`脚本通过`configure.ac`生成,而`configure.ac`中使用的是`xorg-macros`([xorg-macros.m4.in · master · xorg / util / macros · GitLab](https://gitee.com/link?target=https%3A%2F%2Fgitlab.freedesktop.org%2Fxorg%2Futil%2Fmacros%2F-%2Fblob%2Fmaster%2Fxorg-macros.m4.in%3Fref_type%3Dheads))的`XORG_CHECK_MALLOC_ZERO`来产生上文提到的片段: + + ``` + # Require X.Org macros 1.16 or later for XORG_MEMORY_CHECK_FLAGS + m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])]) + XORG_MACROS_VERSION(1.16) + XORG_DEFAULT_OPTIONS + XORG_CHECK_MALLOC_ZERO + XORG_ENABLE_SPECS + XORG_WITH_XMLTO(0.0.20) + XORG_WITH_FOP + XORG_WITH_XSLTPROC + XORG_CHECK_SGML_DOCTOOLS(1.01) + XORG_PROG_RAWCPP + ``` + +- 修复方式:目前采用的是直接修改spec文件,当使用clang构建时传入`--enable-malloc0returnsnull`的configure参数的办法来强制指定的简单方案。在xorg-macros无法提pr,提的issue得到了回复,问题在https://gitlab.freedesktop.org/xorg/util/macros/-/merge_requests/8得到了解决,但可能需要等待更新。