summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-04-12 14:52:08 -0700
committerKhem Raj <raj.khem@gmail.com>2022-04-13 19:21:41 -0700
commit6f5d694d9c328a9d8e0bd927d569714cd75597b7 (patch)
tree789da2373824a997ff2f2617fd2465b5bdac105c
parent66fdbc25c138daf5b7190ee1a14a58f93686f9da (diff)
downloadmeta-openembedded-6f5d694d9c328a9d8e0bd927d569714cd75597b7.tar.gz
ot-br-posix: Disable Wsign-compare for clang
Specify is via CXXFLAGS instead of pragma dance. Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch131
-rw-r--r--meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb3
2 files changed, 2 insertions, 132 deletions
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch b/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch
deleted file mode 100644
index df84550be..000000000
--- a/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch
+++ /dev/null
@@ -1,131 +0,0 @@
1From: Stefan Schmidt <stefan.schmidt@huawei.com>
2Subject: Turn off sign compare for musl libc
3
4When building with musl and clang the usage of CMSG_NXTHDR results in
5sign-compare error. Disable the check only in this specific part of the
6code with a #pragma.
7
8| /home/stefan/huawei/yocto-upstream/yoe/workspace/sources/ot-br-posix/third_party/openthread/repo/src/posix/platform/udp.cpp:147:28: fatal error: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]
9| cmsg = CMSG_NXTHDR(&msg, cmsg);
10| ^~~~~~~~~~~~~~~~~~~~~~~
11| /home/stefan/huawei/yocto-upstream/yoe/build/tmp/work/cortexa57-yoe-linux-musl/ot-br-posix/0.3.0+git999-r0/recipe-sysroot/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
12| __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
13| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14| 1 error generated.
15
16Idea and fix taken from
17recipes-devtools/breakpad/breakpad/0001-Turn-off-sign-compare-for-musl-libc.patch
18by Khem Raj.
19
20Upstream-Status: Inappropriate [OE specific]
21
22Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
23
24diff --git a/src/backbone_router/nd_proxy.cpp b/src/backbone_router/nd_proxy.cpp
25index 7136878c3d..8a223c95c7 100644
26--- a/src/backbone_router/nd_proxy.cpp
27+++ b/src/backbone_router/nd_proxy.cpp
28@@ -185,9 +185,18 @@ void NdProxyManager::ProcessMulticastNeighborSolicition()
29 VerifyOrExit(icmp6header->icmp6_type == ND_NEIGHBOR_SOLICIT, error = OTBR_ERROR_PARSE);
30
31 otbrLogDebug("NdProxyManager: Received ND-NS from %s", src.ToString().c_str());
32-
33+#ifndef __GLIBC__
34+ // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes
35+ // clang to throw sign-compare warning. This is to suppress the warning
36+ // inline.
37+ #pragma clang diagnostic push
38+ #pragma clang diagnostic ignored "-Wsign-compare"
39+#endif
40 for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr; cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr))
41- {
42+#ifndef __GLIBC__
43+ #pragma clang diagnostic pop
44+#endif
45+ {
46 if (cmsghdr->cmsg_level != IPPROTO_IPV6)
47 {
48 continue;
49Submodule third_party/openthread/repo contains modified content
50diff --git a/third_party/openthread/repo/src/posix/platform/infra_if.cpp b/third_party/openthread/repo/src/posix/platform/infra_if.cpp
51index 9f93d2b1c..1ed40fe50 100644
52--- a/third_party/openthread/repo/src/posix/platform/infra_if.cpp
53+++ b/third_party/openthread/repo/src/posix/platform/infra_if.cpp
54@@ -228,7 +228,17 @@ otError InfraNetif::SendIcmp6Nd(uint32_t aInfraIfIndex,
55 packetInfo->ipi6_ifindex = mInfraIfIndex;
56
57 // Per section 6.1.2 of RFC 4861, we need to send the ICMPv6 message with IP Hop Limit 255.
58+#ifndef __GLIBC__
59+ // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes
60+ // clang to throw sign-compare warning. This is to suppress the warning
61+ // inline.
62+ #pragma clang diagnostic push
63+ #pragma clang diagnostic ignored "-Wsign-compare"
64+#endif
65 cmsgPointer = CMSG_NXTHDR(&msgHeader, cmsgPointer);
66+#ifndef __GLIBC__
67+ #pragma clang diagnostic pop
68+#endif
69 cmsgPointer->cmsg_level = IPPROTO_IPV6;
70 cmsgPointer->cmsg_type = IPV6_HOPLIMIT;
71 cmsgPointer->cmsg_len = CMSG_LEN(sizeof(hopLimit));
72@@ -481,7 +491,17 @@ void InfraNetif::ReceiveIcmp6Message(void)
73
74 bufferLength = static_cast<uint16_t>(rval);
75
76+#ifndef __GLIBC__
77+ // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes
78+ // clang to throw sign-compare warning. This is to suppress the warning
79+ // inline.
80+ #pragma clang diagnostic push
81+ #pragma clang diagnostic ignored "-Wsign-compare"
82+#endif
83 for (cmh = CMSG_FIRSTHDR(&msg); cmh; cmh = CMSG_NXTHDR(&msg, cmh))
84+#ifndef __GLIBC__
85+ #pragma clang diagnostic pop
86+#endif
87 {
88 if (cmh->cmsg_level == IPPROTO_IPV6 && cmh->cmsg_type == IPV6_PKTINFO &&
89 cmh->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo)))
90diff --git a/third_party/openthread/repo/src/posix/platform/udp.cpp b/third_party/openthread/repo/src/posix/platform/udp.cpp
91index b7aacc5fa..a814fea70 100644
92--- a/third_party/openthread/repo/src/posix/platform/udp.cpp
93+++ b/third_party/openthread/repo/src/posix/platform/udp.cpp
94@@ -144,8 +144,18 @@ otError transmitPacket(int aFd, uint8_t *aPayload, uint16_t aLength, const otMes
95 {
96 struct in6_pktinfo pktinfo;
97
98+#ifndef __GLIBC__
99+ // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes
100+ // clang to throw sign-compare warning. This is to suppress the warning
101+ // inline.
102+ #pragma clang diagnostic push
103+ #pragma clang diagnostic ignored "-Wsign-compare"
104+#endif
105 cmsg = CMSG_NXTHDR(&msg, cmsg);
106- cmsg->cmsg_level = IPPROTO_IPV6;
107+#ifndef __GLIBC__
108+ #pragma clang diagnostic pop
109+#endif
110+ cmsg->cmsg_level = IPPROTO_IPV6;
111 cmsg->cmsg_type = IPV6_PKTINFO;
112 cmsg->cmsg_len = CMSG_LEN(sizeof(pktinfo));
113
114@@ -200,7 +210,17 @@ otError receivePacket(int aFd, uint8_t *aPayload, uint16_t &aLength, otMessageIn
115 VerifyOrExit(rval > 0, perror("recvmsg"));
116 aLength = static_cast<uint16_t>(rval);
117
118+#ifndef __GLIBC__
119+ // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes
120+ // clang to throw sign-compare warning. This is to suppress the warning
121+ // inline.
122+ #pragma clang diagnostic push
123+ #pragma clang diagnostic ignored "-Wsign-compare"
124+#endif
125 for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg))
126+#ifndef __GLIBC__
127+ #pragma clang diagnostic pop
128+#endif
129 {
130 if (cmsg->cmsg_level == IPPROTO_IPV6)
131 {
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
index d9f558d79..c1af38862 100644
--- a/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
+++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
@@ -16,7 +16,6 @@ PV = "0.3.0+git${SRCPV}"
16 16
17SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=main \ 17SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=main \
18 file://0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch \ 18 file://0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch \
19 file://Turn-off-sign-compare-for-musl-libc.patch \
20 " 19 "
21 20
22S = "${WORKDIR}/git" 21S = "${WORKDIR}/git"
@@ -24,6 +23,8 @@ SYSTEMD_SERVICE:${PN} = "otbr-agent.service"
24 23
25inherit pkgconfig cmake systemd 24inherit pkgconfig cmake systemd
26 25
26CXXFLAGS:append:libc-musl:toolchain-clang = " -Wno-error=sign-compare"
27
27EXTRA_OECMAKE = "-DBUILD_TESTING=OFF \ 28EXTRA_OECMAKE = "-DBUILD_TESTING=OFF \
28 -DOTBR_DBUS=ON \ 29 -DOTBR_DBUS=ON \
29 -DOTBR_REST=ON \ 30 -DOTBR_REST=ON \