Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/libtevent: add libtevent package
@ 2024-10-21 11:46 Ayrton Leyssens
  2024-10-23 20:30 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 5+ messages in thread
From: Ayrton Leyssens @ 2024-10-21 11:46 UTC (permalink / raw)
  To: buildroot@buildroot.org


[-- Attachment #1.1: Type: text/plain, Size: 11613 bytes --]

This patch adds support for libtevent as a standolane library.
Libtevent is part of samba, but one might need it for other packages without the need for the whole samba eg. Certmonger.

Signed-off-by: Ayrton aleyssens@idtech.be<mailto:aleyssens@idtech.be>
---
package/Config.in                             |   1 +
...mba-add-disable-stack-protector-opti.patch | 116 ++++++++++++++++++
package/libtevent/Config.in                   |  16 +++
package/libtevent/libtevent.hash              |   2 +
package/libtevent/libtevent.mk                |  58 +++++++++
5 files changed, 193 insertions(+)
create mode 100644 package/libtevent/0001-buildtools-wafsamba-add-disable-stack-protector-opti.patch
create mode 100644 package/libtevent/Config.in
create mode 100644 package/libtevent/libtevent.hash
create mode 100644 package/libtevent/libtevent.mk

diff --git a/package/Config.in b/package/Config.in
index e1ceb81dc0..d4cc03dcdb 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2245,6 +2245,7 @@ menu "Other"
           source "package/libsolv/Config.in"
           source "package/libspatialindex/Config.in"
           source "package/libtalloc/Config.in"
+          source "package/libtevent/Config.in"
           source "package/libtasn1/Config.in"
           source "package/libtommath/Config.in"
           source "package/libtpl/Config.in"
diff --git a/package/libtevent/0001-buildtools-wafsamba-add-disable-stack-protector-opti.patch b/package/libtevent/0001-buildtools-wafsamba-add-disable-stack-protector-opti.patch
new file mode 100644
index 0000000000..839479a3fa
--- /dev/null
+++ b/package/libtevent/0001-buildtools-wafsamba-add-disable-stack-protector-opti.patch
@@ -0,0 +1,116 @@
+From 5885ed8e6db7648e6842d9811aace7edc4e8aba7 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine fontaine.fabrice@gmail.com<mailto:fontaine.fabrice@gmail.com>
+Date: Wed, 20 Apr 2022 11:16:52 +0200
+Subject: [PATCH] buildtools/wafsamba: add --disable-stack-protector option
+
+Allow the user to disable stack-protector through
+--disable-stack-protector to avoid the following build failure with
+libtalloc on embedded toolchains which don't support stack-protector:
+
+/home/autobuild/autobuild/instance-5/output-1/host/lib/gcc/i686-buildroot-linux-musl/9.4.0/../../../../i686-buildroot-linux-musl/bin/ld: talloc.c.5.o: in function `_vasprintf_tc':
+talloc.c:(.text+0x427d): undefined reference to `__stack_chk_fail_local'
+
+This build failure is raised since
+https://gitlab.com/ffontaine/samba/-/commit/38e97f8b52e85bdfcf2d74a4fb3c848fa46ba371
+because stack-protector is enabled on libtalloc despite the fact that
+libssp is not available:
+
+Checking if compiler accepts -fstack-protector-strong                                           : yes
+
+Fixes:
+ - http://autobuild.buildroot.org/results/e221bde25c7622db99761d0adcd56663296beb15
+
+Signed-off-by: Fabrice Fontaine fontaine.fabrice@gmail.com<mailto:fontaine.fabrice@gmail.com>
+[Upstream status:
+https://gitlab.com/samba-team/samba/-/merge_requests/2493]
+---
+ buildtools/wafsamba/samba_autoconf.py | 49 ++++++++++++++-------------
+ buildtools/wafsamba/wscript           |  3 ++
+ 2 files changed, 28 insertions(+), 24 deletions(-)
+
+diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
+index 78927d85193..23a995e1c34 100644
+--- a/buildtools/wafsamba/samba_autoconf.py
++++ b/buildtools/wafsamba/samba_autoconf.py
+@@ -703,9 +703,28 @@ def SAMBA_CONFIG_H(conf, path=None):
+     if not IN_LAUNCH_DIR(conf):
+         return
+
+-    # we need to build real code that can't be optimized away to test
+-    stack_protect_list = ['-fstack-protector-strong', '-fstack-protector']
+-    for stack_protect_flag in stack_protect_list:
++    if not Options.options.disable_stack_protector:
++        # we need to build real code that can't be optimized away to test
++        stack_protect_list = ['-fstack-protector-strong', '-fstack-protector']
++        for stack_protect_flag in stack_protect_list:
++            flag_supported = conf.check(fragment='''
++                                        #include <stdio.h>
++
++                                        int main(void)
++                                        {
++                                            char t[100000];
++                                            while (fgets(t, sizeof(t), stdin));
++                                            return 0;
++                                        }
++                                        ''',
++                                        execute=0,
++                                        cflags=[ '-Werror', '-Wp,-D_FORTIFY_SOURCE=2', stack_protect_flag],
++                                        mandatory=False,
++                                        msg='Checking if compiler accepts %s' % (stack_protect_flag))
++            if flag_supported:
++                conf.ADD_CFLAGS('%s' % (stack_protect_flag))
++                break
++
+         flag_supported = conf.check(fragment='''
+                                     #include <stdio.h>
+
+@@ -717,29 +736,11 @@ def SAMBA_CONFIG_H(conf, path=None):
+                                     }
+                                     ''',
+                                     execute=0,
+-                                    cflags=[ '-Werror', '-Wp,-D_FORTIFY_SOURCE=2', stack_protect_flag],
++                                    cflags=[ '-Werror', '-fstack-clash-protection'],
+                                     mandatory=False,
+-                                    msg='Checking if compiler accepts %s' % (stack_protect_flag))
++                                    msg='Checking if compiler accepts -fstack-clash-protection')
+         if flag_supported:
+-            conf.ADD_CFLAGS('%s' % (stack_protect_flag))
+-            break
+-
+-    flag_supported = conf.check(fragment='''
+-                                #include <stdio.h>
+-
+-                                int main(void)
+-                                {
+-                                    char t[100000];
+-                                    while (fgets(t, sizeof(t), stdin));
+-                                    return 0;
+-                                }
+-                                ''',
+-                                execute=0,
+-                                cflags=[ '-Werror', '-fstack-clash-protection'],
+-                                mandatory=False,
+-                                msg='Checking if compiler accepts -fstack-clash-protection')
+-    if flag_supported:
+-        conf.ADD_CFLAGS('-fstack-clash-protection')
++            conf.ADD_CFLAGS('-fstack-clash-protection')
+
+     if Options.options.debug:
+         conf.ADD_CFLAGS('-g', testflags=True)
+diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
+index 8729b0829da..d75bb3b1c0c 100644
+--- a/buildtools/wafsamba/wscript
++++ b/buildtools/wafsamba/wscript
+@@ -165,6 +165,9 @@ Currently the only tested value is 'smbtorture,smbd/smbd' for Samba'''),
+     gr.add_option('--disable-warnings-as-errors',
+                    help=("Do not treat all warnings as errors (disable -Werror)"),
+                    action="store_true", dest='disable_warnings_as_errors', default=False)
++    gr.add_option('--disable-stack-protector',
++                   help=("Disable stack-protector"),
++                   action="store_true", dest='disable_stack_protector', default=False)
+     opt.add_option('--enable-coverage',
+                    help=("enable options necessary for code coverage "
+                          "reporting on selftest (default=no)"),
+--
+2.35.1
+
diff --git a/package/libtevent/Config.in b/package/libtevent/Config.in
new file mode 100644
index 0000000000..9b556725e6
--- /dev/null
+++ b/package/libtevent/Config.in
@@ -0,0 +1,16 @@
+config BR2_PACKAGE_LIBTEVENT
+          bool "libtevent"
+          depends on BR2_USE_MMU
+          depends on !BR2_STATIC_LIBS
+          help
+            Tevent is an event system based on the talloc memory management library.
+            Tevent has support for many event types, including timers, signals, and
+            the classic file descriptor events.
+            Tevent also provide helpers to deal with asynchronous code providing the
+            tevent_req (Tevent Request) functions.
+
+            https://tevent.samba.org/talloc/doc/html/index.html
+
+comment "libtevent needs a toolchain w/ dynamic library"
+          depends on BR2_USE_MMU
+          depends on BR2_STATIC_LIBS
diff --git a/package/libtevent/libtevent.hash b/package/libtevent/libtevent.hash
new file mode 100644
index 0000000000..990998e6d1
--- /dev/null
+++ b/package/libtevent/libtevent.hash
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256  362971e0f32dc1905f6fe4736319c4b8348c22dc85aa6c3f690a28efe548029e  tevent-0.16.1.tar.gz
diff --git a/package/libtevent/libtevent.mk b/package/libtevent/libtevent.mk
new file mode 100644
index 0000000000..636a6abbe2
--- /dev/null
+++ b/package/libtevent/libtevent.mk
@@ -0,0 +1,58 @@
+################################################################################
+#
+# libtevent
+#
+################################################################################
+
+LIBTEVENT_VERSION = 0.16.1
+LIBTEVENT_SOURCE = tevent-$(LIBTEVENT_VERSION).tar.gz
+LIBTEVENT_SITE = https://www.samba.org/ftp/tevent
+LIBTEVENT_LICENSE = LGPL-3.0+
+LIBTEVENT_LICENSE_FILES = tevent.h
+LIBTEVENT_INSTALL_STAGING = YES
+
+# libtevent is extracted from the samba source tree, and that has a workaround
+# that requires PYTHONHASHSEED to be set, and to be set to 1.
+# See https://gitlab.com/samba-team/samba/-/commit/420bbb1d92fd2a28725b53f425ba3d214831b660
+LIBTEVENT_CONF_ENV = PYTHONHASHSEED=1
+LIBTEVENT_MAKE_ENV = PYTHONHASHSEED=1
+
+# --with-libiconv= is unconditionally passed, even if libiconv is not
+# present. Indeed, waf will search for libiconv by default in
+# /usr/local. Because of a bug in some waf python script, /usr/local
+# is then used in many subsequent and unrelated checks, which
+# ultimately causes a failure when BR2_COMPILER_PARANOID_UNSAFE_PATH
+# is set.  However no need to set libiconv as a dependency of
+# libtevent since it's optional.
+LIBTEVENT_CONF_OPTS += --cross-compile \
+                      --cross-answers=$(@D)/cache.txt \
+                      --disable-stack-protector \
+                      --hostcc=gcc \
+                      --with-libiconv=$(STAGING_DIR)/usr
+
+ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
+LIBTEVENT_DEPENDENCIES += libtirpc host-pkgconf
+endif
+
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+LIBTEVENT_DEPENDENCIES += host-python3 python3
+LIBTEVENT_CONF_ENV += \
+          PYTHON="$(HOST_DIR)/bin/python3" \
+          PYTHON_CONFIG="$(STAGING_DIR)/usr/bin/python3-config"
+# There isn't any --enable-python configuration option
+else
+LIBTEVENT_CONF_OPTS += --disable-python
+endif
+
+LIBTEVENT_WAF = ./buildtools/bin/waf
+
+# like samba4, libtevent uses the waf build system which requires a
+# proper answers file to configure package before build
+define LIBTEVENT_POPULATE_WAF_CACHE
+          $(INSTALL) -m 0644 package/idtech/libtevent/libtevent-cache.txt $(@D)/cache.txt
+          echo 'Checking uname machine type: $(BR2_ARCH)' >> $(@D)/cache.txt
+endef
+
+LIBTEVENT_PRE_CONFIGURE_HOOKS += LIBTEVENT_POPULATE_WAF_CACHE
+
+$(eval $(waf-package))
--
2.43.0

[-- Attachment #1.2: Type: text/html, Size: 64595 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2024-10-24 14:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 11:46 [Buildroot] [PATCH 1/1] package/libtevent: add libtevent package Ayrton Leyssens
2024-10-23 20:30 ` Thomas Petazzoni via buildroot
2024-10-24  9:04   ` Ayrton Leyssens
2024-10-24 14:13     ` Thomas Petazzoni via buildroot
2024-10-24 14:27       ` Ayrton Leyssens

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