forked from pool/libbpf
Accepting request 920620 from devel:libraries:c_c++
OBS-URL: https://build.opensuse.org/request/show/920620 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libbpf?expand=0&rev=6
This commit is contained in:
commit
b6c7ae907e
98
libbpf-Fix-build-with-latest-gcc-binutils-with-LTO.patch
Normal file
98
libbpf-Fix-build-with-latest-gcc-binutils-with-LTO.patch
Normal file
@ -0,0 +1,98 @@
|
||||
From acc7f8895899a7a1281d27983ce807e3f7b831ce Mon Sep 17 00:00:00 2001
|
||||
From: Patrick McCarty <patrick.mccarty@intel.com>
|
||||
Date: Sun, 3 Jan 2021 06:35:18 +0000
|
||||
Subject: [PATCH] Fix build with latest gcc/binutils with LTO
|
||||
|
||||
After updating to binutils 2.35, the build began to fail with an
|
||||
assembler error. A bug was opened on the Red Hat Bugzilla a few days
|
||||
later for the same issue.
|
||||
|
||||
Work around the problem by using the new `symver` attribute (introduced
|
||||
in GCC 10) as needed, instead of the `COMPAT_VERSION` and
|
||||
`DEFAULT_VERSION` macros, which expand to assembler directives.
|
||||
|
||||
Fixes: https://github.com/libbpf/libbpf/issues/338
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1863059
|
||||
Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1188749
|
||||
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
|
||||
Make the change conditional on GCC version
|
||||
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
|
||||
---
|
||||
src/libbpf_internal.h | 23 +++++++++++++++++------
|
||||
src/xsk.c | 4 ++--
|
||||
2 files changed, 19 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/libbpf_internal.h b/src/libbpf_internal.h
|
||||
index f7b691d..fc7c8c6 100644
|
||||
--- a/src/libbpf_internal.h
|
||||
+++ b/src/libbpf_internal.h
|
||||
@@ -87,20 +87,31 @@
|
||||
(offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD))
|
||||
#endif
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+# if __GNUC__ >= 10
|
||||
+# define DEFAULT_VERSION(internal_name, api_name, version) \
|
||||
+__attribute__((__symver__(#api_name "@@" #version)))
|
||||
+# define COMPAT_VERSION(internal_name, api_name, version) \
|
||||
+__attribute__((__symver__(#api_name "@" #version)))
|
||||
+# endif
|
||||
+#endif
|
||||
+
|
||||
+#if ! defined(COMPAT_VERSION) || ! defined(DEFAULT_VERSION)
|
||||
/* Symbol versioning is different between static and shared library.
|
||||
* Properly versioned symbols are needed for shared library, but
|
||||
* only the symbol of the new version is needed for static library.
|
||||
*/
|
||||
-#ifdef SHARED
|
||||
-# define COMPAT_VERSION(internal_name, api_name, version) \
|
||||
+# ifdef SHARED
|
||||
+# define COMPAT_VERSION(internal_name, api_name, version) \
|
||||
asm(".symver " #internal_name "," #api_name "@" #version);
|
||||
-# define DEFAULT_VERSION(internal_name, api_name, version) \
|
||||
+# define DEFAULT_VERSION(internal_name, api_name, version) \
|
||||
asm(".symver " #internal_name "," #api_name "@@" #version);
|
||||
-#else
|
||||
-# define COMPAT_VERSION(internal_name, api_name, version)
|
||||
-# define DEFAULT_VERSION(internal_name, api_name, version) \
|
||||
+# else
|
||||
+# define COMPAT_VERSION(internal_name, api_name, version)
|
||||
+# define DEFAULT_VERSION(internal_name, api_name, version) \
|
||||
extern typeof(internal_name) api_name \
|
||||
__attribute__((alias(#internal_name)));
|
||||
+# endif
|
||||
#endif
|
||||
|
||||
extern void libbpf_print(enum libbpf_print_level level,
|
||||
diff --git a/src/xsk.c b/src/xsk.c
|
||||
index e9b619a..a211169 100644
|
||||
--- a/src/xsk.c
|
||||
+++ b/src/xsk.c
|
||||
@@ -281,6 +281,7 @@ out_mmap:
|
||||
return err;
|
||||
}
|
||||
|
||||
+DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4)
|
||||
int xsk_umem__create_v0_0_4(struct xsk_umem **umem_ptr, void *umem_area,
|
||||
__u64 size, struct xsk_ring_prod *fill,
|
||||
struct xsk_ring_cons *comp,
|
||||
@@ -345,6 +346,7 @@ struct xsk_umem_config_v1 {
|
||||
__u32 frame_headroom;
|
||||
};
|
||||
|
||||
+COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2)
|
||||
int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area,
|
||||
__u64 size, struct xsk_ring_prod *fill,
|
||||
struct xsk_ring_cons *comp,
|
||||
@@ -358,8 +360,6 @@ int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area,
|
||||
return xsk_umem__create_v0_0_4(umem_ptr, umem_area, size, fill, comp,
|
||||
&config);
|
||||
}
|
||||
-COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2)
|
||||
-DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4)
|
||||
|
||||
static enum xsk_prog get_xsk_prog(void)
|
||||
{
|
||||
--
|
||||
2.32.0
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Aug 27 06:20:53 UTC 2021 - Michal Suchanek <msuchanek@suse.com>
|
||||
|
||||
- Fix LTO build (bsc#1188749).
|
||||
+ libbpf-Fix-build-with-latest-gcc-binutils-with-LTO.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Aug 20 08:47:47 UTC 2021 - Michal Suchanek <msuchanek@suse.com>
|
||||
|
||||
|
@ -28,6 +28,8 @@ Source: https://github.com/libbpf/libbpf/archive/v%{version}.tar.gz#/%{n
|
||||
Source99: baselibs.conf
|
||||
# PATCH-FIX-UPSTREAM https://github.com/libbpf/libbpf/issues/337
|
||||
Patch: libdir.patch
|
||||
# PATCH-FIX-UPSTREAM https://github.com/libbpf/libbpf/pull/373
|
||||
Patch1: libbpf-Fix-build-with-latest-gcc-binutils-with-LTO.patch
|
||||
BuildRequires: libelf-devel
|
||||
BuildRequires: linux-glibc-devel >= 4.5
|
||||
BuildRequires: python3
|
||||
@ -51,14 +53,15 @@ libbpf is a C library which provides API for managing eBPF programs and maps.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%autopatch -p1
|
||||
|
||||
%build
|
||||
cd src
|
||||
%make_build V=1 CFLAGS="%{optflags} -fno-lto"
|
||||
%make_build V=1 CFLAGS="%{optflags}"
|
||||
|
||||
%install
|
||||
cd src
|
||||
%make_install V=1 LIBDIR=%{_libdir}
|
||||
%make_install V=1
|
||||
rm -f %{buildroot}%{_libdir}/%{name}.a
|
||||
|
||||
%post -n %{libname} -p /sbin/ldconfig
|
||||
|
Loading…
Reference in New Issue
Block a user