1From b34d0665b790016165b4a9b565f462712057b2b5 Mon Sep 17 00:00:00 2001
2From: "deepan.shivap" <deepan.shivap@lge.com>
3Date: Wed, 13 Nov 2024 21:30:38 +0900
4Subject: [PATCH] fix build on GCC 14 for yocto
5
6GCC 14 compiler uses -fvisibility-inlines-hidden by default and
7it creates visibility conflicts.
8
9Compilation error:
10
11error: 'ot::BorderRouter::RoutingManager::RxRaTracker' declared with
12greater visibility than the type of its field 'ot::BorderRouter::
13RoutingManager::RxRaTracker::mSignalTask' [-Werror=attributes]
14| 814 | class RxRaTracker : public InstanceLocator
15| | ^~~~~~~~~~~
16| compilation terminated due to -Wfatal-errors.
17| cc1: all warnings being treated as errors
18
19In addition, for below error I have added changes refering -
20https://github.com/openwrt/openwrt/blob/main/package/libs/mbedtls/patches/100-fix-gcc14-build.patch
21
22error: array subscript 48 is outside array bounds of 'unsigned char[48]' [-Werror=array-bounds=]
23| 235 | r[i] = a[i] ^ b[i];
24| | ~^~~
25| compilation terminated due to -Wfatal-errors.
26| cc1: all warnings being treated as errors
27
28---
29Upstream-Status: Denied [Reason -  https://github.com/openthread/openthread/pull/10925]
30Signed-off-by: deepan.shivap <deepan.shivap@lge.com>
31
32 src/core/border_router/routing_manager.cpp | 58 ++++++++++++++++++++++
33 src/core/border_router/routing_manager.hpp | 18 +++----
34 src/core/mac/data_poll_sender.cpp          |  5 ++
35 src/core/mac/data_poll_sender.hpp          |  2 +-
36 src/core/net/srp_client.cpp                |  2 +
37 src/core/net/srp_client.hpp                |  2 +-
38 src/core/thread/mle.cpp                    | 10 ++++
39 src/core/thread/mle.hpp                    |  4 +-
40 third_party/mbedtls/repo/library/common.h  |  2 +-
41 9 files changed, 89 insertions(+), 14 deletions(-)
42
43diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp
44index 5f7916ba4..664963757 100644
45--- a/src/core/border_router/routing_manager.cpp
46+++ b/src/core/border_router/routing_manager.cpp
47@@ -806,6 +806,64 @@ bool RoutingManager::NetworkDataContainsUlaRoute(void) const
48     return contains;
49 }
50
51+void RoutingManager::HandleRxRaTrackerSignalTask(void)
52+{
53+    mRxRaTracker.HandleSignalTask();
54+}
55+
56+void RoutingManager::HandleRxRaTrackerExpirationTimer(void)
57+{
58+    mRxRaTracker.HandleExpirationTimer();
59+}
60+
61+void RoutingManager::HandleRxRaTrackerStaleTimer(void)
62+{
63+    mRxRaTracker.HandleStaleTimer();
64+}
65+
66+void RoutingManager::HandleRxRaTrackerRouterTimer(void)
67+{
68+    mRxRaTracker.HandleRouterTimer();
69+}
70+
71+void RoutingManager::HandleOnLinkPrefixManagerTimer(void)
72+{
73+    mOnLinkPrefixManager.HandleTimer();
74+}
75+
76+void RoutingManager::HandleRioAdvertiserimer(void)
77+{
78+    mRioAdvertiser.HandleTimer();
79+}
80+
81+#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
82+
83+void RoutingManager::HandleNat64PrefixManagerTimer(void)
84+{
85+    mNat64PrefixManager.HandleTimer();
86+}
87+
88+#endif // OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
89+
90+void RoutingManager::HandleRoutePublisherTimer(void)
91+{
92+    mRoutePublisher.HandleTimer();
93+}
94+
95+void RoutingManager::HandleRsSenderTimer(void)
96+{
97+    mRsSender.HandleTimer();
98+}
99+
100+#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE
101+
102+void HandlePdPrefixManagerTimer(void)
103+{
104+    mPdPrefixManager.HandleTimer();
105+}
106+
107+#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE
108+
109 #if OPENTHREAD_CONFIG_BORDER_ROUTING_REACHABILITY_CHECK_ICMP6_ERROR_ENABLE
110
111 void RoutingManager::CheckReachabilityToSendIcmpError(const Message &aMessage, const Ip6::Header &aIp6Header)
112diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp
113index bfc138957..cc866e308 100644
114--- a/src/core/border_router/routing_manager.hpp
115+++ b/src/core/border_router/routing_manager.hpp
116@@ -804,10 +804,10 @@ private:
117
118     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119
120-    void HandleRxRaTrackerSignalTask(void) { mRxRaTracker.HandleSignalTask(); }
121-    void HandleRxRaTrackerExpirationTimer(void) { mRxRaTracker.HandleExpirationTimer(); }
122-    void HandleRxRaTrackerStaleTimer(void) { mRxRaTracker.HandleStaleTimer(); }
123-    void HandleRxRaTrackerRouterTimer(void) { mRxRaTracker.HandleRouterTimer(); }
124+    void HandleRxRaTrackerSignalTask(void);
125+    void HandleRxRaTrackerExpirationTimer(void);
126+    void HandleRxRaTrackerStaleTimer(void);
127+    void HandleRxRaTrackerRouterTimer(void);
128
129     class RxRaTracker : public InstanceLocator
130     {
131@@ -1144,7 +1144,7 @@ private:
132
133     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134
135-    void HandleOnLinkPrefixManagerTimer(void) { mOnLinkPrefixManager.HandleTimer(); }
136+    void HandleOnLinkPrefixManagerTimer(void);
137
138     class OnLinkPrefixManager : public InstanceLocator
139     {
140@@ -1215,7 +1215,7 @@ private:
141
142     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143
144-    void HandleRioAdvertiserimer(void) { mRioAdvertiser.HandleTimer(); }
145+    void HandleRioAdvertiserimer(void);
146
147     class RioAdvertiser : public InstanceLocator
148     {
149@@ -1278,7 +1278,7 @@ private:
150
151 #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
152
153-    void HandleNat64PrefixManagerTimer(void) { mNat64PrefixManager.HandleTimer(); }
154+    void HandleNat64PrefixManagerTimer(void);
155
156     class Nat64PrefixManager : public InstanceLocator
157     {
158@@ -1326,7 +1326,7 @@ private:
159
160     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
161
162-    void HandleRoutePublisherTimer(void) { mRoutePublisher.HandleTimer(); }
163+    void HandleRoutePublisherTimer(void);
164
165     class RoutePublisher : public InstanceLocator // Manages the routes that are published in net data
166     {
167@@ -1411,7 +1411,7 @@ private:
168
169     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
170
171-    void HandleRsSenderTimer(void) { mRsSender.HandleTimer(); }
172+    void HandleRsSenderTimer(void);
173
174     class RsSender : public InstanceLocator
175     {
176diff --git a/src/core/mac/data_poll_sender.cpp b/src/core/mac/data_poll_sender.cpp
177index c21bbacfe..6b974e164 100644
178--- a/src/core/mac/data_poll_sender.cpp
179+++ b/src/core/mac/data_poll_sender.cpp
180@@ -517,6 +517,11 @@ uint32_t DataPollSender::CalculatePollPeriod(void) const
181     return period;
182 }
183
184+void DataPollSender::HandlePollTimer(void)
185+{
186+    IgnoreError(SendDataPoll());
187+}
188+
189 uint32_t DataPollSender::GetDefaultPollPeriod(void) const
190 {
191     uint32_t pollAhead = static_cast<uint32_t>(kRetxPollPeriod) * kMaxPollRetxAttempts;
192diff --git a/src/core/mac/data_poll_sender.hpp b/src/core/mac/data_poll_sender.hpp
193index 1c532ab51..4db8e5923 100644
194--- a/src/core/mac/data_poll_sender.hpp
195+++ b/src/core/mac/data_poll_sender.hpp
196@@ -257,7 +257,7 @@ private:
197     void            ScheduleNextPoll(PollPeriodSelector aPollPeriodSelector);
198     uint32_t        CalculatePollPeriod(void) const;
199     const Neighbor &GetParent(void) const;
200-    void            HandlePollTimer(void) { IgnoreError(SendDataPoll()); }
201+    void            HandlePollTimer(void);
202 #if OPENTHREAD_CONFIG_MULTI_RADIO
203     Error GetPollDestinationAddress(Mac::Address &aDest, Mac::RadioType &aRadioType) const;
204 #else
205diff --git a/src/core/net/srp_client.cpp b/src/core/net/srp_client.cpp
206index b7150ff7f..12b8f0b4f 100644
207--- a/src/core/net/srp_client.cpp
208+++ b/src/core/net/srp_client.cpp
209@@ -2444,6 +2444,8 @@ exit:
210     return error;
211 }
212
213+void Client::HandleGuardTimer(void){}
214+
215 #if OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE
216 void Client::SelectNextServer(bool aDisallowSwitchOnRegisteredHost)
217 {
218diff --git a/src/core/net/srp_client.hpp b/src/core/net/srp_client.hpp
219index 8f5891bd0..367b1d280 100644
220--- a/src/core/net/srp_client.hpp
221+++ b/src/core/net/srp_client.hpp
222@@ -1052,7 +1052,7 @@ private:
223     void  ApplyAutoStartGuardOnAttach(void);
224     void  ProcessAutoStart(void);
225     Error SelectUnicastEntry(DnsSrpUnicastType aType, DnsSrpUnicastInfo &aInfo) const;
226-    void  HandleGuardTimer(void) {}
227+    void  HandleGuardTimer(void);
228 #if OPENTHREAD_CONFIG_SRP_CLIENT_SWITCH_SERVER_ON_FAILURE
229     void SelectNextServer(bool aDisallowSwitchOnRegisteredHost);
230 #endif
231diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp
232index 4de4705be..2e07222fc 100644
233--- a/src/core/thread/mle.cpp
234+++ b/src/core/thread/mle.cpp
235@@ -3853,6 +3853,11 @@ exit:
236
237 #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
238
239+void Mle::HandleParentSearchTimer(void)
240+{
241+    mParentSearch.HandleTimer();
242+}
243+
244 void Mle::ParentSearch::SetEnabled(bool aEnabled)
245 {
246     VerifyOrExit(mEnabled != aEnabled);
247@@ -4423,6 +4428,11 @@ void Mle::TlvList::AddElementsFrom(const TlvList &aTlvList)
248 //---------------------------------------------------------------------------------------------------------------------
249 // DelayedSender
250
251+void Mle::HandleDelayedSenderTimer(void)
252+{
253+    mDelayedSender.HandleTimer();
254+}
255+
256 Mle::DelayedSender::DelayedSender(Instance &aInstance)
257     : InstanceLocator(aInstance)
258     , mTimer(aInstance)
259diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp
260index 58dcea1e7..613334896 100644
261--- a/src/core/thread/mle.hpp
262+++ b/src/core/thread/mle.hpp
263@@ -1087,7 +1087,7 @@ private:
264
265     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
266
267-    void HandleDelayedSenderTimer(void) { mDelayedSender.HandleTimer(); }
268+    void HandleDelayedSenderTimer(void);
269
270     class DelayedSender : public InstanceLocator
271     {
272@@ -1210,7 +1210,7 @@ private:
273     //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
274
275 #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
276-    void HandleParentSearchTimer(void) { mParentSearch.HandleTimer(); }
277+    void HandleParentSearchTimer(void);
278
279     class ParentSearch : public InstanceLocator
280     {
281diff --git a/third_party/mbedtls/repo/library/common.h b/third_party/mbedtls/repo/library/common.h
282index 3936ffdfe..ce4dc1130 100644
283--- a/third_party/mbedtls/repo/library/common.h
284+++ b/third_party/mbedtls/repo/library/common.h
285@@ -199,7 +199,7 @@ static inline void mbedtls_xor(unsigned char *r,
286         uint8x16_t x = veorq_u8(v1, v2);
287         vst1q_u8(r + i, x);
288     }
289-#if defined(__IAR_SYSTEMS_ICC__)
290+#if defined(__IAR_SYSTEMS_ICC__) || (defined(MBEDTLS_COMPILER_IS_GCC) && MBEDTLS_GCC_VERSION >= 140100)
291     /* This if statement helps some compilers (e.g., IAR) optimise out the byte-by-byte tail case
292      * where n is a constant multiple of 16.
293      * For other compilers (e.g. recent gcc and clang) it makes no difference if n is a compile-time
294