#5 Use symvmer attribute, not asms for symbol versioning. Re-enable LTO
Merged 3 years ago by plautrba. Opened 3 years ago by law.
rpms/ law/lksctp-tools fix_symver_and_reenable_lto  into  master

@@ -0,0 +1,85 @@ 

+ diff --git a/configure.ac b/configure.ac

+ index 5de5c76..d3e31c3 100644

+ --- a/configure.ac

+ +++ b/configure.ac

+ @@ -130,4 +130,12 @@ AC_ARG_ENABLE(tests,

+  	[enable_tests=yes])

+  AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])

+  

+ +# GCC tries to be "helpful" and only issue a warning for unrecognized

+ +# attributes.  So we compile the test with Werror, so that if the

+ +# attribute is not recognized the compilation fails

+ +AC_LANG(C)

+ +AC_LANG_WERROR

+ +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[__attribute__ ((symver ("foo@foo_1"))) void frob (void) { }]])],

+ +                  [AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], [1], [Checking for symver attribute])], [])

+ +

+  AC_OUTPUT

+ diff --git a/src/lib/connectx.c b/src/lib/connectx.c

+ index 5f4552b..2a21e3a 100644

+ --- a/src/lib/connectx.c

+ +++ b/src/lib/connectx.c

+ @@ -26,6 +26,18 @@

+  #include <stdlib.h>

+  #include <string.h>

+  #include <fcntl.h>

+ +#include "config.h"

+ +

+ +#define __SYMPFX(pfx, sym) #pfx sym

+ +#define _SYMPFX(pfx, sym) __SYMPFX(pfx, sym)

+ +#define SYMPFX(sym) _SYMPFX(__USER_LABEL_PREFIX__, #sym)

+ +

+ +#if HAVE_ATTRIBUTE_SYMVER

+ +#define SYMVER(name, name2) __attribute__ ((symver (SYMPFX(name2))))

+ +#else

+ +#define SYMVER(name, name2) __asm__(".symver " SYMPFX(name) "," SYMPFX(name2));

+ +#endif

+ +

+  

+  /* Support the sctp_connectx() interface.

+   *

+ @@ -64,6 +76,7 @@ static int __connectx_addrsize(const struct sockaddr *addrs,

+  }

+  			

+  

+ +SYMVER(__sctp_connectx, sctp_connectx@)

+  int __sctp_connectx(int fd, struct sockaddr *addrs, int addrcnt)

+  {

+  	int addrs_size = __connectx_addrsize(addrs, addrcnt);

+ @@ -75,6 +88,7 @@ int __sctp_connectx(int fd, struct sockaddr *addrs, int addrcnt)

+  			    addrs_size);

+  }

+  

+ +SYMVER(sctp_connectx_orig, sctp_connectx@VERS_1)

+  extern int sctp_connectx_orig (int)

+  	__attribute ((alias ("__sctp_connectx")));

+  

+ @@ -114,6 +128,7 @@ static int __connectx(int fd, struct sockaddr *addrs, socklen_t addrs_size,

+  			  addrs, addrs_size);

+  }

+  

+ +SYMVER(sctp_connectx2, sctp_connectx@VERS_2)

+  int sctp_connectx2(int fd, struct sockaddr *addrs, int addrcnt,

+  		      sctp_assoc_t *id)

+  {

+ @@ -125,6 +140,7 @@ int sctp_connectx2(int fd, struct sockaddr *addrs, int addrcnt,

+  	return __connectx(fd, addrs, addrs_size, id);

+  }

+  

+ +SYMVER(sctp_connectx3, sctp_connectx@@VERS_3)

+  int sctp_connectx3(int fd, struct sockaddr *addrs, int addrcnt,

+  		      sctp_assoc_t *id)

+  {

+ @@ -179,12 +195,3 @@ int sctp_connectx3(int fd, struct sockaddr *addrs, int addrcnt,

+  	return __connectx(fd, addrs, addrs_size, id);

+  }

+  

+ -#define __SYMPFX(pfx, sym) #pfx sym

+ -#define _SYMPFX(pfx, sym) __SYMPFX(pfx, sym)

+ -#define SYMPFX(sym) _SYMPFX(__USER_LABEL_PREFIX__, #sym)

+ -#define SYMVER(name, name2) __asm__(".symver " SYMPFX(name) "," SYMPFX(name2))

+ -

+ -SYMVER(__sctp_connectx, sctp_connectx@);

+ -SYMVER(sctp_connectx_orig, sctp_connectx@VERS_1);

+ -SYMVER(sctp_connectx2, sctp_connectx@VERS_2);

+ -SYMVER(sctp_connectx3, sctp_connectx@@VERS_3);

file modified
+6 -9
@@ -1,7 +1,7 @@ 

  Name:    lksctp-tools

  Summary: User-space access to Linux Kernel SCTP

  Version: 1.0.18

- Release: 7%{?dist}

+ Release: 8%{?dist}

  # src/apps/bindx_test.C is GPLv2, I've asked upstream for clarification

  License: GPLv2 and GPLv2+ and LGPLv2 and MIT

  Group:   System Environment/Libraries
@@ -15,6 +15,7 @@ 

  Patch4: lksctp-tools-1.0.18-build-remove-v4.12-secondary-defines-in-favor-of-HAV.patch

  Patch5: lksctp-tools-1.0.18-build-fix-probing-for-HAVE_SCTP_SENDV.patch

  Patch6: lksctp-tools-1.0.18-build-0b0dce7a36fb-actually-belongs-to-v4.19.patch

+ Patch7: lksctp-tools-symver.patch

  BuildRequires: libtool, automake, autoconf

  

  %description
@@ -56,16 +57,9 @@ 

  %patch4 -p1

  %patch5 -p1

  %patch6 -p1

+ %patch7 -p1

  

  %build

- # This package uses top level ASM constructs which are incompatible with LTO.

- # Top level ASMs are often used to implement symbol versioning.  gcc-10

- # introduces a new mechanism for symbol versioning which works with LTO.

- # Converting packages to use that mechanism instead of toplevel ASMs is

- # recommended.

- # Disable LTO

- %define _lto_cflags %{nil}

- 

  [ ! -x ./configure ] && sh bootstrap

  %configure --disable-static

  # remove rpath from libtool
@@ -100,6 +94,9 @@ 

  %doc doc/*.txt

  

  %changelog

+ * Wed Sep 09 2020 Jeff Law <law@redhat.com> - 1.0.18-8

+ - Use symver attribute for symbol versioning.  Re-enable LTO

+ 

  * Wed Aug 19 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 1.0.18-7

  - Drop useless ldconfig scriptlets

  

This package is currently opted out of LTO because it uses ASMs to implement symbol versioning. ASMs like this are fundamentally incompatible with LTO because GCC does not look inside the ASM string to find symbol references. Starting with gcc-10 there is a new symbol attribute for implementing symbol versioning. This patch changes lksctp-tools to use that symbol attribute and re-enables LTO. Note the patch includes a fallback to the old way of implementing symbol versioning via asms, so in theory it should work with clang as well as gcc-9 and earlier. I haven't fully tested the fallback path.

I have about 200 packages I'm working through, so I can't reasonably engage every upstream project. I'd like to merge this PR into Fedora so that LTO gets enabled for the lksctp-tools package and let the package maintainers engage the appropriate upstream community so that we don't have to carry a Fedora specific patch forever.

Pull-Request has been merged by plautrba

3 years ago

Thank you for the PR.

I've looked at the upstream GitLab repository and they no longer accept PRs there. Hence I need to look up, how to send them patch properly and do that later.

See http://lksctp.sourceforge.net/

The lksctp-tools project is always looking for community members interested in contributing. For versioning control, we use Git. The patch submission process is similar to the one of the Linux kernel. So please respect the kernel's coding guidelines and patch submission procedure.

Send your lksctp-tools patches to the linux-sctp@vger.kernel.org mailing list with ``[PATCH lksctp-tools]'' as a subject prefix for further review and inclusion.

But I've already sent it, waiting when it appears at https://www.spinics.net/lists/netdev/

And this the patch I've sent https://github.com/bachradsusi/lksctp-tools/commit/d7d41b01204adeea574c52620d4b7d21754380c9

But I'm not sure if one has to be subscribed in order to sent a path to the list