Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] gnutls: fix build on sparc
@ 2019-01-17 19:02 Fabrice Fontaine
  2019-01-18 19:29 ` Matthew Weber
  2019-01-28 15:55 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Fabrice Fontaine @ 2019-01-17 19:02 UTC (permalink / raw)
  To: buildroot

gnutls source code uses the C++11 <atomic> functionality since
https://github.com/gnutls/gnutls/commit/7978a733460f92b31033affd0e487c86d66c643d,
which internally is implemented using the __atomic_*() gcc built-ins

On certain architectures, the __atomic_*() built-ins are implemented in
the libatomic library that comes with the rest of the gcc runtime. Due
to this, code using <atomic> might need to link against libatomic,
otherwise one hits build issues such as:

../lib/.libs/libgnutls.so: undefined reference to `__atomic_fetch_sub_4'

on an architecture like SPARC.

To solve this, a configure.ac check is added to know if we need to
link against libatomic or not. The library is also added to gnutls.pc.

Fixes:
 - http://autobuild.buildroot.org/results/6c749bd592ceffeacadd2ab570d127936cce64b2
 - http://autobuild.buildroot.org/results/30aa83d3cf3482af8a59250c196c85f4a278d343

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...configure.ac-check-if-libatomic-is-needed.patch | 60 ++++++++++++++++++++++
 package/gnutls/gnutls.mk                           |  2 +
 2 files changed, 62 insertions(+)
 create mode 100644 package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch

diff --git a/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch b/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch
new file mode 100644
index 0000000000..15c1893b01
--- /dev/null
+++ b/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch
@@ -0,0 +1,60 @@
+From cce372f10a755d59ccf09fb7dc6e87b416f63a6f Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Thu, 17 Jan 2019 10:50:00 +0100
+Subject: [PATCH] configure.ac: check if libatomic is needed
+
+gnutls source code uses the C++11 <atomic> functionality since
+https://github.com/gnutls/gnutls/commit/7978a733460f92b31033affd0e487c86d66c643d,
+which internally is implemented using the __atomic_*() gcc built-ins
+
+On certain architectures, the __atomic_*() built-ins are implemented in
+the libatomic library that comes with the rest of the gcc runtime. Due
+to this, code using <atomic> might need to link against libatomic,
+otherwise one hits build issues such as:
+
+../lib/.libs/libgnutls.so: undefined reference to `__atomic_fetch_sub_4'
+
+on an architecture like SPARC.
+
+To solve this, a configure.ac check is added to know if we need to
+link against libatomic or not. The library is also added to gnutls.pc.
+
+Fixes:
+ - http://autobuild.buildroot.org/results/6c749bd592ceffeacadd2ab570d127936cce64b2
+ - http://autobuild.buildroot.org/results/30aa83d3cf3482af8a59250c196c85f4a278d343
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://gitlab.com/gnutls/gnutls/merge_requests/878]
+---
+ configure.ac     | 2 ++
+ lib/gnutls.pc.in | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index e81ff8970..b2c0c2b3d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -207,6 +207,8 @@ dnl Need netinet/tcp.h for TCP_FASTOPEN
+ AC_CHECK_HEADERS([netinet/tcp.h])
+ AC_CHECK_HEADERS([stdatomic.h])
+ 
++AC_SEARCH_LIBS([__atomic_load_4], [atomic], [AC_SUBST([LIBATOMIC_LIBS], [-latomic])])
++
+ dnl We use its presence to detect C11 threads
+ AC_CHECK_HEADERS([threads.h])
+ 
+diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
+index 9f26852cc..68be2d110 100644
+--- a/lib/gnutls.pc.in
++++ b/lib/gnutls.pc.in
+@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
+ URL: http://www.gnutls.org/
+ Version: @VERSION@
+ Libs: -L${libdir} -lgnutls
+-Libs.private: @LIBINTL@ @LIBSOCKET@ @LIBNSL@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBIDN2_LIBS@
++Libs.private: @LIBINTL@ @LIBSOCKET@ @LIBNSL@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBIDN2_LIBS@ @LIBATOMIC_LIBS@
+ @GNUTLS_REQUIRES_PRIVATE@
+ Cflags: -I${includedir}
+-- 
+2.14.1
+
diff --git a/package/gnutls/gnutls.mk b/package/gnutls/gnutls.mk
index e6ddc3dbec..d9befa1612 100644
--- a/package/gnutls/gnutls.mk
+++ b/package/gnutls/gnutls.mk
@@ -27,6 +27,8 @@ GNUTLS_CONF_ENV = gl_cv_socket_ipv6=yes \
 	gt_cv_c_wint_t=$(if $(BR2_USE_WCHAR),yes,no) \
 	gl_cv_func_gettimeofday_clobber=no
 GNUTLS_INSTALL_STAGING = YES
+# We're patching configure.ac
+GNUTLS_AUTORECONF = YES
 
 # libpthread autodetection poison the linkpath
 GNUTLS_CONF_OPTS += $(if $(BR2_TOOLCHAIN_HAS_THREADS),--with-libpthread-prefix=$(STAGING_DIR)/usr)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] gnutls: fix build on sparc
  2019-01-17 19:02 [Buildroot] [PATCH 1/1] gnutls: fix build on sparc Fabrice Fontaine
@ 2019-01-18 19:29 ` Matthew Weber
  2019-01-28 15:55 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Weber @ 2019-01-18 19:29 UTC (permalink / raw)
  To: buildroot

Fabrice,


On Thu, Jan 17, 2019 at 1:03 PM Fabrice Fontaine
<fontaine.fabrice@gmail.com> wrote:
>
> gnutls source code uses the C++11 <atomic> functionality since
> https://github.com/gnutls/gnutls/commit/7978a733460f92b31033affd0e487c86d66c643d,
> which internally is implemented using the __atomic_*() gcc built-ins
>
> On certain architectures, the __atomic_*() built-ins are implemented in
> the libatomic library that comes with the rest of the gcc runtime. Due
> to this, code using <atomic> might need to link against libatomic,
> otherwise one hits build issues such as:
>
> ../lib/.libs/libgnutls.so: undefined reference to `__atomic_fetch_sub_4'
>
> on an architecture like SPARC.
>
> To solve this, a configure.ac check is added to know if we need to
> link against libatomic or not. The library is also added to gnutls.pc.
>
> Fixes:
>  - http://autobuild.buildroot.org/results/6c749bd592ceffeacadd2ab570d127936cce64b2
>  - http://autobuild.buildroot.org/results/30aa83d3cf3482af8a59250c196c85f4a278d343
>
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Thanks for sending the fix.

Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>

> ---
>  ...configure.ac-check-if-libatomic-is-needed.patch | 60 ++++++++++++++++++++++
>  package/gnutls/gnutls.mk                           |  2 +
>  2 files changed, 62 insertions(+)
>  create mode 100644 package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch
>
> diff --git a/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch b/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch
> new file mode 100644
> index 0000000000..15c1893b01
> --- /dev/null
> +++ b/package/gnutls/0001-configure.ac-check-if-libatomic-is-needed.patch
> @@ -0,0 +1,60 @@
> +From cce372f10a755d59ccf09fb7dc6e87b416f63a6f Mon Sep 17 00:00:00 2001
> +From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +Date: Thu, 17 Jan 2019 10:50:00 +0100
> +Subject: [PATCH] configure.ac: check if libatomic is needed
> +
> +gnutls source code uses the C++11 <atomic> functionality since
> +https://github.com/gnutls/gnutls/commit/7978a733460f92b31033affd0e487c86d66c643d,
> +which internally is implemented using the __atomic_*() gcc built-ins
> +
> +On certain architectures, the __atomic_*() built-ins are implemented in
> +the libatomic library that comes with the rest of the gcc runtime. Due
> +to this, code using <atomic> might need to link against libatomic,
> +otherwise one hits build issues such as:
> +
> +../lib/.libs/libgnutls.so: undefined reference to `__atomic_fetch_sub_4'
> +
> +on an architecture like SPARC.
> +
> +To solve this, a configure.ac check is added to know if we need to
> +link against libatomic or not. The library is also added to gnutls.pc.
> +
> +Fixes:
> + - http://autobuild.buildroot.org/results/6c749bd592ceffeacadd2ab570d127936cce64b2
> + - http://autobuild.buildroot.org/results/30aa83d3cf3482af8a59250c196c85f4a278d343
> +
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +[Upstream status: https://gitlab.com/gnutls/gnutls/merge_requests/878]
> +---
> + configure.ac     | 2 ++
> + lib/gnutls.pc.in | 2 +-
> + 2 files changed, 3 insertions(+), 1 deletion(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index e81ff8970..b2c0c2b3d 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -207,6 +207,8 @@ dnl Need netinet/tcp.h for TCP_FASTOPEN
> + AC_CHECK_HEADERS([netinet/tcp.h])
> + AC_CHECK_HEADERS([stdatomic.h])
> +
> ++AC_SEARCH_LIBS([__atomic_load_4], [atomic], [AC_SUBST([LIBATOMIC_LIBS], [-latomic])])
> ++
> + dnl We use its presence to detect C11 threads
> + AC_CHECK_HEADERS([threads.h])
> +
> +diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
> +index 9f26852cc..68be2d110 100644
> +--- a/lib/gnutls.pc.in
> ++++ b/lib/gnutls.pc.in
> +@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
> + URL: http://www.gnutls.org/
> + Version: @VERSION@
> + Libs: -L${libdir} -lgnutls
> +-Libs.private: @LIBINTL@ @LIBSOCKET@ @LIBNSL@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBIDN2_LIBS@
> ++Libs.private: @LIBINTL@ @LIBSOCKET@ @LIBNSL@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBIDN2_LIBS@ @LIBATOMIC_LIBS@
> + @GNUTLS_REQUIRES_PRIVATE@
> + Cflags: -I${includedir}
> +--
> +2.14.1
> +
> diff --git a/package/gnutls/gnutls.mk b/package/gnutls/gnutls.mk
> index e6ddc3dbec..d9befa1612 100644
> --- a/package/gnutls/gnutls.mk
> +++ b/package/gnutls/gnutls.mk
> @@ -27,6 +27,8 @@ GNUTLS_CONF_ENV = gl_cv_socket_ipv6=yes \
>         gt_cv_c_wint_t=$(if $(BR2_USE_WCHAR),yes,no) \
>         gl_cv_func_gettimeofday_clobber=no
>  GNUTLS_INSTALL_STAGING = YES
> +# We're patching configure.ac
> +GNUTLS_AUTORECONF = YES
>

Another option would have been to conditionally add "-latomic" to the
LIBS variable passed in GNUTLS_CONF_ENV  if
$(BR2_TOOLCHAIN_HAS_LIBATOMIC) is yes.  Probably better to fix the
configure check like you did.

Matt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] gnutls: fix build on sparc
  2019-01-17 19:02 [Buildroot] [PATCH 1/1] gnutls: fix build on sparc Fabrice Fontaine
  2019-01-18 19:29 ` Matthew Weber
@ 2019-01-28 15:55 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2019-01-28 15:55 UTC (permalink / raw)
  To: buildroot

>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:

 > gnutls source code uses the C++11 <atomic> functionality since
 > https://github.com/gnutls/gnutls/commit/7978a733460f92b31033affd0e487c86d66c643d,
 > which internally is implemented using the __atomic_*() gcc built-ins

 > On certain architectures, the __atomic_*() built-ins are implemented in
 > the libatomic library that comes with the rest of the gcc runtime. Due
 > to this, code using <atomic> might need to link against libatomic,
 > otherwise one hits build issues such as:

 > ../lib/.libs/libgnutls.so: undefined reference to `__atomic_fetch_sub_4'

 > on an architecture like SPARC.

 > To solve this, a configure.ac check is added to know if we need to
 > link against libatomic or not. The library is also added to gnutls.pc.

 > Fixes:
 >  - http://autobuild.buildroot.org/results/6c749bd592ceffeacadd2ab570d127936cce64b2
 >  - http://autobuild.buildroot.org/results/30aa83d3cf3482af8a59250c196c85f4a278d343

 > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-28 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-17 19:02 [Buildroot] [PATCH 1/1] gnutls: fix build on sparc Fabrice Fontaine
2019-01-18 19:29 ` Matthew Weber
2019-01-28 15:55 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox