diff mbox series

package/libcurl: fix build when !BR2_TOOLCHAIN_HAS_SYNC_1

Message ID a91e52dc20742c251ac5fdc6ada81c499dfc1705.1658419808.git.baruch@tkos.co.il
State Accepted
Headers show
Series package/libcurl: fix build when !BR2_TOOLCHAIN_HAS_SYNC_1 | expand

Commit Message

Baruch Siach July 21, 2022, 4:10 p.m. UTC
On platform that do not provide __atomic_exchange_1(), and when
libatomic is not available (e.g., threads support disabled) link of
libcurl.so fails. To solve this use an indirect way to make HAVE_ATOMIC
undefined. Add an upstream patch for checking the stdatomic.h header,
and seed the 'no' answer.

Fixes:
http://autobuild.buildroot.net/results/8f695d4dbb91cfde8e93ab38e837b0a0042b986b/
http://autobuild.buildroot.net/results/3b4712b0ace52da1650e88cdaafb6a20be135464/

Cc: Matt Weber <matthew.weber@collins.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 ...for-the-stdatomic.h-header-in-config.patch | 70 +++++++++++++++++++
 package/libcurl/libcurl.mk                    |  6 ++
 2 files changed, 76 insertions(+)
 create mode 100644 package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch

Comments

Arnout Vandecappelle July 23, 2022, 11:49 a.m. UTC | #1
On 21/07/2022 18:10, Baruch Siach via buildroot wrote:
> On platform that do not provide __atomic_exchange_1(), and when
> libatomic is not available (e.g., threads support disabled) link of
> libcurl.so fails. To solve this use an indirect way to make HAVE_ATOMIC
> undefined. Add an upstream patch for checking the stdatomic.h header,
> and seed the 'no' answer.
> 
> Fixes:
> http://autobuild.buildroot.net/results/8f695d4dbb91cfde8e93ab38e837b0a0042b986b/
> http://autobuild.buildroot.net/results/3b4712b0ace52da1650e88cdaafb6a20be135464/
> 
> Cc: Matt Weber <matthew.weber@collins.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   ...for-the-stdatomic.h-header-in-config.patch | 70 +++++++++++++++++++
>   package/libcurl/libcurl.mk                    |  6 ++
>   2 files changed, 76 insertions(+)
>   create mode 100644 package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch
> 
> diff --git a/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch b/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch
> new file mode 100644
> index 000000000000..083238819b1b
> --- /dev/null
> +++ b/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch
> @@ -0,0 +1,70 @@
> +From a68074b5db2a1fb637853b808e5b263c2ce9cbdd Mon Sep 17 00:00:00 2001
> +From: Daniel Stenberg <daniel@haxx.se>
> +Date: Tue, 28 Jun 2022 08:37:22 +0200
> +Subject: [PATCH] configure: check for the stdatomic.h header in configure
> +
> +... and only set HAVE_ATOMIC if that header exists since we use
> +typedefes set in it.
> +
> +Reported-by: Ryan Schmidt
> +Fixes #9059
> +Closes #9060
> +
> +Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> +---
> +Upstream status: commit a68074b5db2a1fb637853b808e5b263c2ce9cbdd
> +
> + m4/curl-functions.m4 | 36 +++++++++++++++++++-----------------
> + 1 file changed, 19 insertions(+), 17 deletions(-)
> +
> +diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
> +index ec406f56aed8..f3e12a53a9fd 100644
> +--- a/m4/curl-functions.m4
> ++++ b/m4/curl-functions.m4
> +@@ -6570,24 +6570,26 @@ AC_DEFUN([CURL_COVERAGE],[
> + ])
> +
> + dnl CURL_ATOMIC
> +-dnl --------------------------------------------------
> +-dnl Check if _Atomic works
> ++dnl -------------------------------------------------------------
> ++dnl Check if _Atomic works. But only check if stdatomic.h exists.
> + dnl
> + AC_DEFUN([CURL_ATOMIC],[
> +-  AC_MSG_CHECKING([if _Atomic is available])
> +-  AC_COMPILE_IFELSE([
> +-    AC_LANG_PROGRAM([[
> +-      $curl_includes_unistd
> +-    ]],[[
> +-      _Atomic int i = 0;
> +-    ]])
> +-  ],[
> +-    AC_MSG_RESULT([yes])
> +-    AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
> +-      [Define to 1 if you have _Atomic support.])
> +-    tst_atomic="yes"
> +-  ],[
> +-    AC_MSG_RESULT([no])
> +-    tst_atomic="no"
> ++  AC_CHECK_HEADERS(stdatomic.h, [
> ++    AC_MSG_CHECKING([if _Atomic is available])
> ++    AC_COMPILE_IFELSE([
> ++      AC_LANG_PROGRAM([[
> ++        $curl_includes_unistd
> ++      ]],[[
> ++        _Atomic int i = 0;
> ++      ]])
> ++    ],[
> ++      AC_MSG_RESULT([yes])
> ++      AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
> ++        [Define to 1 if you have _Atomic support.])
> ++      tst_atomic="yes"
> ++    ],[
> ++      AC_MSG_RESULT([no])
> ++      tst_atomic="no"
> ++    ])
> +   ])
> + ])
> +--
> +2.35.1
> +
> diff --git a/package/libcurl/libcurl.mk b/package/libcurl/libcurl.mk
> index 5dc4eebefa49..ab2fd75276b2 100644
> --- a/package/libcurl/libcurl.mk
> +++ b/package/libcurl/libcurl.mk
> @@ -15,6 +15,8 @@ LIBCURL_LICENSE_FILES = COPYING
>   LIBCURL_CPE_ID_VENDOR = haxx
>   LIBCURL_CPE_ID_PRODUCT = libcurl
>   LIBCURL_INSTALL_STAGING = YES
> +# We are patching configure.ac
> +LIBCURL_AUTORECONF = YES
>   
>   # We disable NTLM support because it uses fork(), which doesn't work
>   # on non-MMU platforms. Moreover, this authentication method is
> @@ -36,6 +38,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
>   LIBCURL_CONF_OPTS += LIBS=-latomic
>   endif
>   
> +ifeq ($(BR2_TOOLCHAIN_HAS_SYNC_1),)
> +LIBCURL_CONF_ENV += ac_cv_header_stdatomic_h=no

  I've added a comment to explain why this is needed, and applied to master, thanks.

  Regards,
  Arnout

> +endif
> +
>   ifeq ($(BR2_PACKAGE_LIBCURL_VERBOSE),y)
>   LIBCURL_CONF_OPTS += --enable-verbose
>   else
Peter Korsgaard Aug. 12, 2022, 3:11 p.m. UTC | #2
>>>>> "Baruch" == Baruch Siach via buildroot <buildroot@buildroot.org> writes:

 > On platform that do not provide __atomic_exchange_1(), and when
 > libatomic is not available (e.g., threads support disabled) link of
 > libcurl.so fails. To solve this use an indirect way to make HAVE_ATOMIC
 > undefined. Add an upstream patch for checking the stdatomic.h header,
 > and seed the 'no' answer.

 > Fixes:
 > http://autobuild.buildroot.net/results/8f695d4dbb91cfde8e93ab38e837b0a0042b986b/
 > http://autobuild.buildroot.net/results/3b4712b0ace52da1650e88cdaafb6a20be135464/

 > Cc: Matt Weber <matthew.weber@collins.com>
 > Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Committed to 2022.05.x and 2022.02.x, thanks.
diff mbox series

Patch

diff --git a/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch b/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch
new file mode 100644
index 000000000000..083238819b1b
--- /dev/null
+++ b/package/libcurl/0002-configure-check-for-the-stdatomic.h-header-in-config.patch
@@ -0,0 +1,70 @@ 
+From a68074b5db2a1fb637853b808e5b263c2ce9cbdd Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 28 Jun 2022 08:37:22 +0200
+Subject: [PATCH] configure: check for the stdatomic.h header in configure
+
+... and only set HAVE_ATOMIC if that header exists since we use
+typedefes set in it.
+
+Reported-by: Ryan Schmidt
+Fixes #9059
+Closes #9060
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+---
+Upstream status: commit a68074b5db2a1fb637853b808e5b263c2ce9cbdd
+
+ m4/curl-functions.m4 | 36 +++++++++++++++++++-----------------
+ 1 file changed, 19 insertions(+), 17 deletions(-)
+
+diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
+index ec406f56aed8..f3e12a53a9fd 100644
+--- a/m4/curl-functions.m4
++++ b/m4/curl-functions.m4
+@@ -6570,24 +6570,26 @@ AC_DEFUN([CURL_COVERAGE],[
+ ])
+ 
+ dnl CURL_ATOMIC
+-dnl --------------------------------------------------
+-dnl Check if _Atomic works
++dnl -------------------------------------------------------------
++dnl Check if _Atomic works. But only check if stdatomic.h exists.
+ dnl
+ AC_DEFUN([CURL_ATOMIC],[
+-  AC_MSG_CHECKING([if _Atomic is available])
+-  AC_COMPILE_IFELSE([
+-    AC_LANG_PROGRAM([[
+-      $curl_includes_unistd
+-    ]],[[
+-      _Atomic int i = 0;
+-    ]])
+-  ],[
+-    AC_MSG_RESULT([yes])
+-    AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
+-      [Define to 1 if you have _Atomic support.])
+-    tst_atomic="yes"
+-  ],[
+-    AC_MSG_RESULT([no])
+-    tst_atomic="no"
++  AC_CHECK_HEADERS(stdatomic.h, [
++    AC_MSG_CHECKING([if _Atomic is available])
++    AC_COMPILE_IFELSE([
++      AC_LANG_PROGRAM([[
++        $curl_includes_unistd
++      ]],[[
++        _Atomic int i = 0;
++      ]])
++    ],[
++      AC_MSG_RESULT([yes])
++      AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
++        [Define to 1 if you have _Atomic support.])
++      tst_atomic="yes"
++    ],[
++      AC_MSG_RESULT([no])
++      tst_atomic="no"
++    ])
+   ])
+ ])
+-- 
+2.35.1
+
diff --git a/package/libcurl/libcurl.mk b/package/libcurl/libcurl.mk
index 5dc4eebefa49..ab2fd75276b2 100644
--- a/package/libcurl/libcurl.mk
+++ b/package/libcurl/libcurl.mk
@@ -15,6 +15,8 @@  LIBCURL_LICENSE_FILES = COPYING
 LIBCURL_CPE_ID_VENDOR = haxx
 LIBCURL_CPE_ID_PRODUCT = libcurl
 LIBCURL_INSTALL_STAGING = YES
+# We are patching configure.ac
+LIBCURL_AUTORECONF = YES
 
 # We disable NTLM support because it uses fork(), which doesn't work
 # on non-MMU platforms. Moreover, this authentication method is
@@ -36,6 +38,10 @@  ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
 LIBCURL_CONF_OPTS += LIBS=-latomic
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_SYNC_1),)
+LIBCURL_CONF_ENV += ac_cv_header_stdatomic_h=no
+endif
+
 ifeq ($(BR2_PACKAGE_LIBCURL_VERBOSE),y)
 LIBCURL_CONF_OPTS += --enable-verbose
 else