* [Buildroot] [PATCH] package/libwebsockets: fix OpenSSL detection without libatomic
@ 2026-10-27 8:16 Yegor Yefremov
2026-10-27 16:09 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: Yegor Yefremov @ 2026-10-27 8:16 UTC (permalink / raw)
To: buildroot; +Cc: Danomi Manchego
Since version 4.5.3, libwebsockets adds -latomic to the libraries used
by its OpenSSL API probes whenever 64-bit atomics don't work out of the
box, without checking that libatomic is available. Buildroot toolchains
without thread support don't provide libatomic, so on a CPU without
native 64-bit atomics (e.g. ARMv5) all probes fail to link:
ld: cannot find -latomic: No such file or directory
libwebsockets then assumes a pre-1.1 OpenSSL and fails to build:
-- Performing Test HAVE_WORKING_ATOMIC_64 - Failed
[...]
-- Looking for HMAC_CTX_new - not found
[...]
include/libwebsockets/lws-genhash.h:93:18: error: field 'ctx' has incomplete type
93 | HMAC_CTX ctx;
| ^~~
Add a patch, sent upstream, to only use libatomic if linking against it
makes the 64-bit atomics test pass.
This issue has been present since commit 20c3eb6eb684
("package/libwebsockets: bump version to 4.5.7"), which bumped
libwebsockets from 4.4.1 to 4.5.7, the atomic check having been added
in 4.5.3. It therefore affects 2026.05 and later.
Fixes:
https://autobuild.buildroot.org/results/863c30265623973e15a25c2d38c0e1631a39b7e8
Fixes: 20c3eb6eb68432c37d5db69963be266b7f2d23f7 ("package/libwebsockets: bump version to 4.5.7")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
...ly-link-libatomic-if-it-is-available.patch | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 package/libwebsockets/0001-cmake-openssl-only-link-libatomic-if-it-is-available.patch
diff --git a/package/libwebsockets/0001-cmake-openssl-only-link-libatomic-if-it-is-available.patch b/package/libwebsockets/0001-cmake-openssl-only-link-libatomic-if-it-is-available.patch
new file mode 100644
index 0000000000..84724f9c50
--- /dev/null
+++ b/package/libwebsockets/0001-cmake-openssl-only-link-libatomic-if-it-is-available.patch
@@ -0,0 +1,61 @@
+From e0480a47e95a0d74c826926ae6bfef14fc8d988f Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Tue, 27 Oct 2026 08:47:29 +0100
+Subject: [PATCH] cmake: openssl: only link libatomic if it is available
+
+Commit 09aade8c9 ("cmake: openssl: Added check for atomic library")
+adds -latomic to CMAKE_REQUIRED_LIBRARIES whenever 64-bit atomics
+don't work out of the box, without checking that libatomic exists.
+
+Some toolchains don't provide libatomic at all, e.g. GCC toolchains
+built without thread support, as libatomic relies on pthreads. On such
+a toolchain for a CPU without native 64-bit atomics (e.g. ARMv5), every
+OpenSSL API probe then fails to link:
+
+ ld: cannot find -latomic: No such file or directory
+
+so lws believes it deals with a pre-1.1 OpenSSL and the build fails:
+
+ include/libwebsockets/lws-genhash.h:93:18: error: field 'ctx' has incomplete type
+ 93 | HMAC_CTX ctx;
+ | ^~~
+
+Only use libatomic if linking against it makes the 64-bit atomics
+test pass.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: sent to Andy Green <andy@warmcat.com> on 2026-10-27
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+---
+ lib/tls/CMakeLists.txt | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/lib/tls/CMakeLists.txt b/lib/tls/CMakeLists.txt
+index d91c3dab6..9060d32fe 100644
+--- a/lib/tls/CMakeLists.txt
++++ b/lib/tls/CMakeLists.txt
+@@ -564,10 +564,17 @@ if (DEFINED LIB_LIST)
+ endif()
+ if(UNIX AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
+ check_c_source_compiles("int main() { long long x = 0; __atomic_fetch_add(&x, 1, __ATOMIC_SEQ_CST); return 0; }" HAVE_WORKING_ATOMIC_64)
+- if(HAVE_WORKING_ATOMIC_64)
+- set(LWS_ATOMIC_LIB "")
+- else()
+- set(LWS_ATOMIC_LIB atomic)
++ set(LWS_ATOMIC_LIB "")
++ if(NOT HAVE_WORKING_ATOMIC_64)
++ # libatomic is not always available (eg, toolchains without threads),
++ # only use it if it actually provides the 64-bit atomics
++ set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
++ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} atomic)
++ check_c_source_compiles("int main() { long long x = 0; __atomic_fetch_add(&x, 1, __ATOMIC_SEQ_CST); return 0; }" HAVE_WORKING_ATOMIC_64_WITH_LIBATOMIC)
++ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
++ if(HAVE_WORKING_ATOMIC_64_WITH_LIBATOMIC)
++ set(LWS_ATOMIC_LIB atomic)
++ endif()
+ endif()
+ endif()
+ if (UNIX AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "QNX"))
+--
+2.34.1
+
--
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Buildroot] [PATCH] package/libwebsockets: fix OpenSSL detection without libatomic
2026-10-27 8:16 [Buildroot] [PATCH] package/libwebsockets: fix OpenSSL detection without libatomic Yegor Yefremov
@ 2026-10-27 16:09 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-27 16:09 UTC (permalink / raw)
To: Yegor Yefremov; +Cc: buildroot, Danomi Manchego
On Tue, Oct 27, 2026 at 09:16:59AM +0100, Yegor Yefremov wrote:
> Since version 4.5.3, libwebsockets adds -latomic to the libraries used
> by its OpenSSL API probes whenever 64-bit atomics don't work out of the
> box, without checking that libatomic is available. Buildroot toolchains
> without thread support don't provide libatomic, so on a CPU without
> native 64-bit atomics (e.g. ARMv5) all probes fail to link:
>
> ld: cannot find -latomic: No such file or directory
>
> libwebsockets then assumes a pre-1.1 OpenSSL and fails to build:
>
> -- Performing Test HAVE_WORKING_ATOMIC_64 - Failed
> [...]
> -- Looking for HMAC_CTX_new - not found
> [...]
> include/libwebsockets/lws-genhash.h:93:18: error: field 'ctx' has incomplete type
> 93 | HMAC_CTX ctx;
> | ^~~
>
> Add a patch, sent upstream, to only use libatomic if linking against it
> makes the 64-bit atomics test pass.
>
> This issue has been present since commit 20c3eb6eb684
> ("package/libwebsockets: bump version to 4.5.7"), which bumped
> libwebsockets from 4.4.1 to 4.5.7, the atomic check having been added
> in 4.5.3. It therefore affects 2026.05 and later.
>
> Fixes:
> https://autobuild.buildroot.org/results/863c30265623973e15a25c2d38c0e1631a39b7e8
>
> Fixes: 20c3eb6eb68432c37d5db69963be266b7f2d23f7 ("package/libwebsockets: bump version to 4.5.7")
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Applied to master, thanks!
Best regards,
Thomas Petazzoni
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 8:16 [Buildroot] [PATCH] package/libwebsockets: fix OpenSSL detection without libatomic Yegor Yefremov
2026-10-27 16:09 ` Thomas Petazzoni via buildroot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.