frr: fix host build error on macOS
authorGeorgi Valkov <gvalkov@gmail.com>
Tue, 30 Apr 2024 14:37:11 +0000 (17:37 +0300)
committerRobert Marko <robimarko@gmail.com>
Tue, 30 Apr 2024 20:54:10 +0000 (22:54 +0200)
Fixes:
lib/command_graph.c:16:1: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens"); ^
./lib/memory.h:139:2: note: expanded from macro 'DEFINE_MTYPE_STATIC'
        DEFINE_MTYPE_ATTR(group, name, static, desc)                           \
        ^
./lib/memory.h:109:26: note: expanded from macro 'DEFINE_MTYPE_ATTR'
                __attribute__((section(".data.mtypes"))) = { {                 \

[1] https://github.com/FRRouting/frr/pull/6032
[2] https://github.com/FRRouting/frr/pull/15890

Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
net/frr/Makefile
net/frr/patches/998-lib-fix-error-on-MacOS.patch [new file with mode: 0644]

index b889c8a4c710aca5ba63ed4a325c17274558cebe..6c68364bb69b6ea776d751d3374613531b74bd2d 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 PKG_NAME:=frr
 PKG_VERSION:=9.0.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_SOURCE_DATE:=2023-08-12
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_DATE).tar.gz
diff --git a/net/frr/patches/998-lib-fix-error-on-MacOS.patch b/net/frr/patches/998-lib-fix-error-on-MacOS.patch
new file mode 100644 (file)
index 0000000..6ee727b
--- /dev/null
@@ -0,0 +1,85 @@
+From ad26e0926d1fa20bfdd9b5f63cec4db9837f880a Mon Sep 17 00:00:00 2001
+From: Ruben Kerkhof <ruben@rubenkerkhof.com>
+Date: Wed, 18 Mar 2020 15:40:39 +0100
+Subject: [PATCH] lib: fix error on MacOS
+
+Sections use a different syntax for Mach-O executables.
+
+Fixes:
+
+lib/bfd.c:35:1: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a
+      comma
+DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info")
+^
+./lib/memory.h:140:2: note: expanded from macro 'DEFINE_MTYPE_STATIC'
+        DEFINE_MTYPE_ATTR(group, name, static, desc)                           \
+        ^
+./lib/memory.h:110:26: note: expanded from macro 'DEFINE_MTYPE_ATTR'
+                __attribute__((section(".data.mtypes"))) = { {                 \
+                                       ^
+1 error generated.
+
+Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
+Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
+---
+ lib/memory.h | 43 +++++++++++++++++++++++++++----------------
+ 1 file changed, 27 insertions(+), 16 deletions(-)
+
+--- a/lib/compiler.h
++++ b/lib/compiler.h
+@@ -447,6 +447,12 @@ _Static_assert(sizeof(_uint64_t) == 8 &&
+ #define unlikely(_x) !!(_x)
+ #endif
++#ifdef __MACH__
++#define _DATA_SECTION(name) __attribute__((section("__DATA," name)))
++#else
++#define _DATA_SECTION(name) __attribute__((section(".data." name)))
++#endif
++
+ #ifdef __cplusplus
+ }
+ #endif
+--- a/lib/memory.h
++++ b/lib/memory.h
+@@ -69,14 +69,12 @@ struct memgroup {
+ #define DECLARE_MGROUP(name) extern struct memgroup _mg_##name
+ #define _DEFINE_MGROUP(mname, desc, ...)                                       \
+-      struct memgroup _mg_##mname                                            \
+-              __attribute__((section(".data.mgroups"))) = {                  \
+-                      .name = desc,                                          \
+-                      .types = NULL,                                         \
+-                      .next = NULL,                                          \
+-                      .insert = NULL,                                        \
+-                      .ref = NULL,                                           \
+-                      __VA_ARGS__                                            \
++      struct memgroup _mg_##mname _DATA_SECTION("mgroups") = {               \
++              .name = desc,                                                  \
++              .types = NULL,                                                 \
++              .next = NULL,                                                  \
++              .insert = NULL,                                                \
++              .ref = NULL,                                                   \
+       };                                                                     \
+       static void _mginit_##mname(void) __attribute__((_CONSTRUCTOR(1000))); \
+       static void _mginit_##mname(void)                                      \
+@@ -105,13 +103,12 @@ struct memgroup {
+       /* end */
+ #define DEFINE_MTYPE_ATTR(group, mname, attr, desc)                            \
+-      attr struct memtype MTYPE_##mname[1]                                   \
+-              __attribute__((section(".data.mtypes"))) = { {                 \
+-                      .name = desc,                                          \
+-                      .next = NULL,                                          \
+-                      .n_alloc = 0,                                          \
+-                      .size = 0,                                             \
+-                      .ref = NULL,                                           \
++      attr struct memtype MTYPE_##mname[1] _DATA_SECTION("mtypes") = { {     \
++              .name = desc,                                                  \
++              .next = NULL,                                                  \
++              .n_alloc = 0,                                                  \
++              .size = 0,                                                     \
++              .ref = NULL,                                                   \
+       } };                                                                   \
+       static void _mtinit_##mname(void) __attribute__((_CONSTRUCTOR(1001))); \
+       static void _mtinit_##mname(void)                                      \