Skip to contentSkip to conversation

libwebsockets fixup

PATCH New aduskett at gmail.com 4 participants 10 messages Jul 26, 2020 – Aug 13, 2020

lore
Share & tools
lore
#0 lore raw

cover libwebsockets fixup

From: Adam Duskett <[email protected]>

As I was picking through the packages under my name in the developers' file, I checked libwebsockets and found that it was quite out of date!

I started to dig around and found two issues I wanted to fix before updating libwebsockets:

1) libwebsockets compiles just fine without fork() and has had vfork() support for at * least * 5 years (I couldn't find anything further back, but it might have been there even longer.)

2) zlib hasn't been a requirement since 2013 and is only necessary if LWS_WITHOUT_EXTENSIONS is "ON," which is the default behavior.

As such, the first two patches deal directly with those issues. The first removes "depends on BR2_USE_MMU," the second explicitly sets LWS_WITHOUT_EXTENSIONS to "OFF." (See the patch for more details and size comparisons.)

The 4.0 series of libwebsockets also has several new features and options which we may want to enable in a separate patch series, but for this patch series, I just wanted to include a check for libglib2 and libmount.

The other options we may want to enable in the future are:
- LWS_ROLE_MQTT
- LWS_WITH_SYS_ASYNC_DNS
- LWS_WITH_SYS_NTPCLIENT
- LWS_WITH_SYS_DHCP_CLIENT
- LWS_WITH_SECURE_STREAMS
- LWS_WITH_STRUCT_JSON
- LWS_WITH_SPAWN
- LWS_WITH_SQLITE3/LWS_WITH_STRUCT_SQLITE3

Feel free to check out the CMakeLists.txt and the changelog file to see what those options do, some of them are quite neat! If we do decide to impliment those options, a Config.in entry would be needed for all of them except for SQLITE.

Also, mbedtls and wolfssl are supported and have been for quite a while, but nobody cares about adding support for those libraries. I sure as heck don't!

I tested the changes on Fedora 32 and CentOS7 with "./utils/test-pkg -c ./defconfig -p libwebsockets" and got "6 builds, 0 skipped, 0 build failed, 0 legal-info failed" as a result.

Thanks for taking a look at the series!

Adam Duskett (5):
package/libwebsockets: remove dependency on mmu package/libwebsockets: add support for extensions package/libwebsockets: bump version to 4.0.20 package/libwebsockets: add libglib2 support package/libwebsockets: add fsmount support

 ...ts-txt-fix-static-build-with-openssl.patch | 34 -------------------
 package/libwebsockets/Config.in               |  1 -
 package/libwebsockets/libwebsockets.hash      |  4 +--
 package/libwebsockets/libwebsockets.mk        | 21 ++++++++++--
 4 files changed, 20 insertions(+), 40 deletions(-)
 delete mode 100644 package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/5 package/libwebsockets: remove dependency on mmu

From: Adam Duskett <[email protected]>

Six years ago, commit b6b5bb518d28850e024b90db1129b7f86e9d416c added the MMU dependency for the libwebsockets package. However, according to the git history of the CMakeLists.txt file, libwebsockets has supported the vfork function for at least the last five years.

After testing with the qemu_arm_versatile_nommu_defconfig and the br-arm-cortex-m4-full.config file, no errors occurred when building libwebsockets without MMU support.

Remove the dependency; it is no longer necessary.

---
 package/libwebsockets/Config.in | 1 -
 1 file changed, 1 deletion(-)
package/libwebsockets/Config.in +0 -1
index 2b350bf389..1d927bb4ea 100644
@@ -1,6 +1,5 @@
 config BR2_PACKAGE_LIBWEBSOCKETS
 	bool "libwebsockets"
-	depends on BR2_USE_MMU # fork()
 	select BR2_PACKAGE_ZLIB
 	help
 	  Libwebsockets is a lightweight pure C library built to use
Signature · 1 line
2.26.2
#2 lore raw

PATCH 1/5 package/libwebsockets: remove dependency on mmu

Quoted 11 lines · On Sat, 25 Jul 2020 19:28:57 -0700 aduskett at gmail.com wrote:

From: Adam Duskett <[email protected]>

Six years ago, commit b6b5bb518d28850e024b90db1129b7f86e9d416c added the MMU dependency for the libwebsockets package. However, according to the git history of the CMakeLists.txt file, libwebsockets has supported the vfork function for at least the last five years.

After testing with the qemu_arm_versatile_nommu_defconfig and the br-arm-cortex-m4-full.config file, no errors occurred when building libwebsockets without MMU support.

Quoted 6 lines

Remove the dependency; it is no longer necessary.

---
 package/libwebsockets/Config.in | 1 -
 1 file changed, 1 deletion(-)

You forgot to have a look at the reverse dependencies of libwebsockets, so I did that and updated the places where BR2_USE_MMU could be dropped, in ttyd and janus-gateway.

Applied with those changes. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 1/5 package/libwebsockets: remove dependency on mmu

In reply to aduskett at gmail.com
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"aduskett" == aduskett <[email protected]> writes:

From: Adam Duskett <[email protected]>
Six years ago, commit b6b5bb518d28850e024b90db1129b7f86e9d416c added the MMU dependency for the libwebsockets package. However, according to the git history of the CMakeLists.txt file, libwebsockets has supported the vfork function for at least the last five years.

Quoted 7 lines

After testing with the qemu_arm_versatile_nommu_defconfig and the br-arm-cortex-m4-full.config file, no errors occurred when building libwebsockets without MMU support.

Remove the dependency; it is no longer necessary.

Committed to 2020.02.x and 2020.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 2/5 package/libwebsockets: add support for extensions

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

libwebsockets currently depends on zlib, however, as of commit 13ba5bbc633ea962d46d9f2bfb2e87c9f7e83b62 (from 2013!) zlib is not actually a requirement if extensions are not enabled.

By default, libwebsockets sets the "LWS_WITHOUT_EXTENSIONS" option to "ON," which removes the need for zlib as a dependency. Because of this default setting, there are two options:

1) Remove the dependency on zlib, create a new option under Config.in to allow a user to enable extensions, add zlib as a dependency, and set LWS_WITHOUT_EXTENSIONS to "OFF" if that option is selected.

2) Keep the dependency and explicitly set LWS_WITHOUT_EXTENSIONS to "OFF."

Below are the size differences in bytes:
- Without zlib and extensions: 44636
- With zlib and without extensions: 44720
- With zlib and with extensions: 44732

Considering the size difference between all 3 is an incredible 96 bytes, and the difference between what we have now, and enabling extensions is an insurmountable 12 bytes, it is safe to keep the dependency on zlib and always enable extensions.

---
 package/libwebsockets/libwebsockets.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/libwebsockets/libwebsockets.mk +2 -1
index 3af34a61ab..6716d52796 100644
@@ -13,7 +13,8 @@ LIBWEBSOCKETS_INSTALL_STAGING = YES
 LIBWEBSOCKETS_CONF_OPTS = \
 	-DLWS_WITHOUT_TESTAPPS=ON \
 	-DLWS_IPV6=ON \
-	-DLWS_UNIX_SOCK=ON
+	-DLWS_UNIX_SOCK=ON \
+	-DLWS_WITHOUT_EXTENSIONS=OFF
 
 # If LWS_MAX_SMP=1, then there is no code related to pthreads compiled
 # in the library. If unset, LWS_MAX_SMP defaults to 32 and a small
Signature · 1 line
2.26.2
#5 lore raw

PATCH 3/5 package/libwebsockets: bump version to 4.0.20

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

Other changes:
- Remove upstream patch.
- Change license type to MIT.
- Update license shasum due to the above change.

---
 ...ts-txt-fix-static-build-with-openssl.patch | 34 -------------------
 package/libwebsockets/libwebsockets.hash      |  4 +--
 package/libwebsockets/libwebsockets.mk        |  4 +--
 3 files changed, 4 insertions(+), 38 deletions(-)
 delete mode 100644 package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch
package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch deleted +0 -34
deleted file mode 100644
index 868685d397..0000000000
@@ -1,34 +0,0 @@
-From 5f8134cfe5e7b90a8ce07d27ae737dcc54b523b3 Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <[email protected]>
-Date: Wed, 16 Oct 2019 20:09:13 +0200
-Subject: [PATCH] CMakeLists.txt: fix static build with openssl
-
-openssl can depends on -latomic so use pkg-config (if available) to
-retrieve these static dependencies otherwise build will fail because
-HMAC_CTX_new test will return a wrong result
-
-Fixes:
- - http://autobuild.buildroot.org/results/65d0528b208c0a470264f7e2433be89425971dd7
-
-Signed-off-by: Fabrice Fontaine <[email protected]>
-[Retrieved (and backported) from:
-https://github.com/warmcat/libwebsockets/commit/5f8134cfe5e7b90a8ce07d27ae737dcc54b523b3]
----
- CMakeLists.txt | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 2693ac56a..888f65e83 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -1803,7 +1803,10 @@ if (LWS_WITH_SSL)
- 		if (NOT OPENSSL_FOUND AND NOT LWS_WITH_BORINGSSL)
- 			# TODO: Add support for STATIC also.
- 		if (NOT LWS_WITH_ESP32)
-+			find_package(PkgConfig QUIET)
-+			pkg_check_modules(PC_OPENSSL openssl QUIET)
- 			find_package(OpenSSL REQUIRED)
-+			list(APPEND OPENSSL_LIBRARIES ${PC_OPENSSL_LIBRARIES})
- 		endif()
- 			set(OPENSSL_INCLUDE_DIRS "${OPENSSL_INCLUDE_DIR}")
- 		endif()
package/libwebsockets/libwebsockets.hash +2 -2
index ca0c1db2d5..3963370710 100644
@@ -1,3 +1,3 @@
 # Locally computed:
-sha256	166d6e17cab64bfc10c2a71799c298284540a1fa63f6ea3de5caccb34502243c  libwebsockets-3.2.2.tar.gz
-sha256  4d092cd5e062c5ab0cf6408963d74619b5baf1571344410be6aa5bcef512eb70  LICENSE
+sha256  a26d243f2642a9b810e7d91f1e66b149d1da978decdca58ce1c9218c454f397e  libwebsockets-4.0.20.tar.gz
+sha256  5756db345eb9c21cb06dd7cb69c38ec234657a233f9a186b4f5fa453681bd394  LICENSE
package/libwebsockets/libwebsockets.mk +2 -2
index 6716d52796..6c2667b867 100644
@@ -4,9 +4,9 @@
 #
 ################################################################################
 
-LIBWEBSOCKETS_VERSION = 3.2.2
+LIBWEBSOCKETS_VERSION = 4.0.20
 LIBWEBSOCKETS_SITE = $(call github,warmcat,libwebsockets,v$(LIBWEBSOCKETS_VERSION))
-LIBWEBSOCKETS_LICENSE = LGPL-2.1 with exceptions
+LIBWEBSOCKETS_LICENSE = MIT with exceptions
 LIBWEBSOCKETS_LICENSE_FILES = LICENSE
 LIBWEBSOCKETS_DEPENDENCIES = zlib
 LIBWEBSOCKETS_INSTALL_STAGING = YES
Signature · 1 line
2.26.2
#6 lore raw

PATCH 3/5 package/libwebsockets: bump version to 4.0.20

Adam, All,

On 2020-07-25 19:28 -0700, aduskett at gmail.com spake thusly:

Quoted 6 lines

From: Adam Duskett <[email protected]>

Other changes:
- Remove upstream patch.
- Change license type to MIT.
- Update license shasum due to the above change.

Patch applied to master, thanks.

However, I did explicitly disable the two new features you are introducing in the next two patches. But as I did not see the cover letter, I did not account for the new ones...

Regards,
Yann E. MORIN.

Quoted 81 lines
---
 ...ts-txt-fix-static-build-with-openssl.patch | 34 -------------------
 package/libwebsockets/libwebsockets.hash      |  4 +--
 package/libwebsockets/libwebsockets.mk        |  4 +--
 3 files changed, 4 insertions(+), 38 deletions(-)
 delete mode 100644 package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch
package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch deleted +0 -34
deleted file mode 100644
index 868685d397..0000000000
@@ -1,34 +0,0 @@
-From 5f8134cfe5e7b90a8ce07d27ae737dcc54b523b3 Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <[email protected]>
-Date: Wed, 16 Oct 2019 20:09:13 +0200
-Subject: [PATCH] CMakeLists.txt: fix static build with openssl
-
-openssl can depends on -latomic so use pkg-config (if available) to
-retrieve these static dependencies otherwise build will fail because
-HMAC_CTX_new test will return a wrong result
-
-Fixes:
- - http://autobuild.buildroot.org/results/65d0528b208c0a470264f7e2433be89425971dd7
-
-Signed-off-by: Fabrice Fontaine <[email protected]>
-[Retrieved (and backported) from:
-https://github.com/warmcat/libwebsockets/commit/5f8134cfe5e7b90a8ce07d27ae737dcc54b523b3]
----
- CMakeLists.txt | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 2693ac56a..888f65e83 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -1803,7 +1803,10 @@ if (LWS_WITH_SSL)
- 		if (NOT OPENSSL_FOUND AND NOT LWS_WITH_BORINGSSL)
- 			# TODO: Add support for STATIC also.
- 		if (NOT LWS_WITH_ESP32)
-+			find_package(PkgConfig QUIET)
-+			pkg_check_modules(PC_OPENSSL openssl QUIET)
- 			find_package(OpenSSL REQUIRED)
-+			list(APPEND OPENSSL_LIBRARIES ${PC_OPENSSL_LIBRARIES})
- 		endif()
- 			set(OPENSSL_INCLUDE_DIRS "${OPENSSL_INCLUDE_DIR}")
- 		endif()
package/libwebsockets/libwebsockets.hash +2 -2
index ca0c1db2d5..3963370710 100644
@@ -1,3 +1,3 @@
 # Locally computed:
-sha256	166d6e17cab64bfc10c2a71799c298284540a1fa63f6ea3de5caccb34502243c  libwebsockets-3.2.2.tar.gz
-sha256  4d092cd5e062c5ab0cf6408963d74619b5baf1571344410be6aa5bcef512eb70  LICENSE
+sha256  a26d243f2642a9b810e7d91f1e66b149d1da978decdca58ce1c9218c454f397e  libwebsockets-4.0.20.tar.gz
+sha256  5756db345eb9c21cb06dd7cb69c38ec234657a233f9a186b4f5fa453681bd394  LICENSE
package/libwebsockets/libwebsockets.mk +2 -2
index 6716d52796..6c2667b867 100644
@@ -4,9 +4,9 @@
 #
 ################################################################################
 
-LIBWEBSOCKETS_VERSION = 3.2.2
+LIBWEBSOCKETS_VERSION = 4.0.20
 LIBWEBSOCKETS_SITE = $(call github,warmcat,libwebsockets,v$(LIBWEBSOCKETS_VERSION))
-LIBWEBSOCKETS_LICENSE = LGPL-2.1 with exceptions
+LIBWEBSOCKETS_LICENSE = MIT with exceptions
 LIBWEBSOCKETS_LICENSE_FILES = LICENSE
 LIBWEBSOCKETS_DEPENDENCIES = zlib
 LIBWEBSOCKETS_INSTALL_STAGING = YES
Signature · 6 lines
2.26.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH 4/5 package/libwebsockets: add libglib2 support

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

---
 package/libwebsockets/libwebsockets.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/libwebsockets/libwebsockets.mk +7 -0
index 6c2667b867..3fbbb5d554 100644
@@ -48,6 +48,13 @@ LIBWEBSOCKETS_CONF_OPTS += \
 	-DLWS_WITH_LIBEVENT=OFF
 endif
 
+ifeq ($(BR2_PACKAGE_LIBGLIB2),y)
+LIBWEBSOCKETS_DEPENDENCIES += libglib2
+LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_GLIB=ON
+else
+LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_GLIB=OFF
+endif
+
 ifeq ($(BR2_PACKAGE_LIBUV),y)
 LIBWEBSOCKETS_DEPENDENCIES += libuv
 LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_LIBUV=ON
Signature · 1 line
2.26.2
#8 lore raw

PATCH 5/5 package/libwebsockets: add fsmount support

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

---
 package/libwebsockets/libwebsockets.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/libwebsockets/libwebsockets.mk +7 -0
index 3fbbb5d554..8e6d02205a 100644
@@ -55,6 +55,13 @@ else
 LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_GLIB=OFF
 endif
 
+ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBMOUNT),y)
+LIBWEBSOCKETS_DEPENDENCIES += util-linux
+LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_FSMOUNT=ON
+else
+LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_FSMOUNT=OFF
+endif
+
 ifeq ($(BR2_PACKAGE_LIBUV),y)
 LIBWEBSOCKETS_DEPENDENCIES += libuv
 LIBWEBSOCKETS_CONF_OPTS += -DLWS_WITH_LIBUV=ON
Signature · 1 line
2.26.2
#9 lore raw

cover libwebsockets fixup

In reply to aduskett at gmail.com

Adam, All,

On 2020-07-25 19:28 -0700, aduskett at gmail.com spake thusly:

Quoted 24 lines

From: Adam Duskett <[email protected]>

As I was picking through the packages under my name in the developers' file, I checked libwebsockets and found that it was quite out of date!

I started to dig around and found two issues I wanted to fix before updating libwebsockets:

1) libwebsockets compiles just fine without fork() and has had vfork() support for at * least * 5 years (I couldn't find anything further back, but it might have been there even longer.)

2) zlib hasn't been a requirement since 2013 and is only necessary if LWS_WITHOUT_EXTENSIONS is "ON," which is the default behavior.

As such, the first two patches deal directly with those issues. The first removes "depends on BR2_USE_MMU," the second explicitly sets LWS_WITHOUT_EXTENSIONS to "OFF." (See the patch for more details and size comparisons.)

The 4.0 series of libwebsockets also has several new features and options which we may want to enable in a separate patch series, but for this patch series, I just wanted to include a check for libglib2 and libmount.

Quoted 9 lines

The other options we may want to enable in the future are:
- LWS_ROLE_MQTT
- LWS_WITH_SYS_ASYNC_DNS
- LWS_WITH_SYS_NTPCLIENT
- LWS_WITH_SYS_DHCP_CLIENT
- LWS_WITH_SECURE_STREAMS
- LWS_WITH_STRUCT_JSON
- LWS_WITH_SPAWN
- LWS_WITH_SQLITE3/LWS_WITH_STRUCT_SQLITE3

Ah... Too bad I hadn't seen the cover letter before pushing.. When there are new features coming with a version bump, either we handle them with proper dependencies, or we forcefully and explicitly disable them, so that they are not randomly enabled/disabled depending on the build order... See my reply to patch 3...

Would you be so kind as to send a patch that explicitly disable those bnew features, please?

Otherwise, series applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 35 lines

Feel free to check out the CMakeLists.txt and the changelog file to see what those options do, some of them are quite neat! If we do decide to impliment those options, a Config.in entry would be needed for all of them except for SQLITE.

Also, mbedtls and wolfssl are supported and have been for quite a while, but nobody cares about adding support for those libraries. I sure as heck don't!

I tested the changes on Fedora 32 and CentOS7 with "./utils/test-pkg -c ./defconfig -p libwebsockets" and got "6 builds, 0 skipped, 0 build failed, 0 legal-info failed" as a result.

Thanks for taking a look at the series!

Adam Duskett (5):
package/libwebsockets: remove dependency on mmu package/libwebsockets: add support for extensions package/libwebsockets: bump version to 4.0.20 package/libwebsockets: add libglib2 support package/libwebsockets: add fsmount support

 ...ts-txt-fix-static-build-with-openssl.patch | 34 -------------------
 package/libwebsockets/Config.in               |  1 -
 package/libwebsockets/libwebsockets.hash      |  4 +--
 package/libwebsockets/libwebsockets.mk        | 21 ++++++++++--
 4 files changed, 20 insertions(+), 40 deletions(-)
 delete mode 100644 package/libwebsockets/0001-CMakeLists-txt-fix-static-build-with-openssl.patch
Signature · 6 lines
2.26.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'