All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/cairo: fix pthread detection
@ 2023-02-23 15:32 Fabrice Fontaine
  2023-02-23 22:47 ` Fabrice Fontaine
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fabrice Fontaine @ 2023-02-23 15:32 UTC (permalink / raw)
  To: buildroot; +Cc: Fabrice Fontaine

pthreads detection fails if a warning is emitted resulting in the
following build failure with some toolchains:

onfigure:34189: checking for cairo's pthread feature
configure:34300: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm -lpthread >&5
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
configure:34300: $? = 0
configure:34419: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm  >&5
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
configure:34419: $? = 0
configure:34500: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm  >&5
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
configure:34500: $? = 0
configure:34555: checking whether cairo's pthread feature could be enabled
configure:34557: result: no (can't link with -lpthread or -pthread)

[...]

In file included from cairo-mutex-type-private.h:45,
                 from cairo-scaled-font-private.h:45,
                 from cairoint.h:434,
                 from cairo-analysis-surface.c:37:
cairo-mutex-impl-private.h:262:3: error: #error "XXX: No mutex implementation found.  Cairo will not work with multiple threads.  Define CAIRO_NO_MUTEX to 1 to acknowledge and accept this limitation and compile cairo without thread-safety support."
  262 | # error "XXX: No mutex implementation found.  Cairo will not work with multiple threads.  Define CAIRO_NO_MUTEX to 1 to acknowledge and accept this limitation and compile cairo without thread-safety support."
      |   ^~~~~

To avoid this build failure, add a patch that overrides this broken
mechanism

Fixes:
 - http://autobuild.buildroot.org/results/5420beaf94855e47eeb08627e8e3c169dc00419a

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...e.ac.pthread-respect-enable-pthreads.patch | 59 +++++++++++++++++++
 package/cairo/cairo.mk                        | 13 ++--
 2 files changed, 68 insertions(+), 4 deletions(-)
 create mode 100644 package/cairo/0005-build-configure.ac.pthread-respect-enable-pthreads.patch

diff --git a/package/cairo/0005-build-configure.ac.pthread-respect-enable-pthreads.patch b/package/cairo/0005-build-configure.ac.pthread-respect-enable-pthreads.patch
new file mode 100644
index 0000000000..c350c596cf
--- /dev/null
+++ b/package/cairo/0005-build-configure.ac.pthread-respect-enable-pthreads.patch
@@ -0,0 +1,59 @@
+From 243fe7f3d51c23159e25f36adee7e953fee29f6c Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Thu, 23 Feb 2023 16:07:04 +0100
+Subject: [PATCH] build/configure.ac.pthread: respect --enable-pthreads
+
+Respect --enable-pthreads as pthreads detection fails if a warning is
+emitted resulting in the following build failure with some toolchains:
+
+onfigure:34189: checking for cairo's pthread feature
+configure:34300: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm -lpthread >&5
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
+configure:34300: $? = 0
+configure:34419: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -pthread -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm  >&5
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
+configure:34419: $? = 0
+configure:34500: /home/buildroot/autobuild/instance-1/output-1/host/bin/xtensa-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -mlongcalls -mauto-litpools -O0 -g2  -D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  conftest.c -lrt -latomic -lexecinfo -lm  >&5
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: warning: /home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/crtend.o: missing .note.GNU-stack section implies executable stack
+/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
+configure:34500: $? = 0
+configure:34555: checking whether cairo's pthread feature could be enabled
+configure:34557: result: no (can't link with -lpthread or -pthread)
+
+[...]
+
+In file included from cairo-mutex-type-private.h:45,
+                 from cairo-scaled-font-private.h:45,
+                 from cairoint.h:434,
+                 from cairo-analysis-surface.c:37:
+cairo-mutex-impl-private.h:262:3: error: #error "XXX: No mutex implementation found.  Cairo will not work with multiple threads.  Define CAIRO_NO_MUTEX to 1 to acknowledge and accept this limitation and compile cairo without thread-safety support."
+  262 | # error "XXX: No mutex implementation found.  Cairo will not work with multiple threads.  Define CAIRO_NO_MUTEX to 1 to acknowledge and accept this limitation and compile cairo without thread-safety support."
+      |   ^~~~~
+
+Fixes:
+ - http://autobuild.buildroot.org/results/5420beaf94855e47eeb08627e8e3c169dc00419a
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ build/configure.ac.pthread | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/build/configure.ac.pthread b/build/configure.ac.pthread
+index 29c930da9..084445587 100644
+--- a/build/configure.ac.pthread
++++ b/build/configure.ac.pthread
+@@ -244,7 +244,8 @@ AC_DEFUN([CAIRO_CONFIGURE_PTHREAD],[dnl
+ 
+ 	dnl Make sure we scored some pthreads.
+ 	if test "x$enable_pthread" = "xyes" -a "x$have_pthread" != "xyes"; then
+-		AC_MSG_ERROR([pthread requested but not found])
++		AC_MSG_WARN([pthread requested but not found])
++		have_pthread=yes
+ 	fi
+ 
+ 	dnl Set the output variables for CAIRO_ENABLE.
+-- 
+2.39.1
+
diff --git a/package/cairo/cairo.mk b/package/cairo/cairo.mk
index e8a704c7da..9034068403 100644
--- a/package/cairo/cairo.mk
+++ b/package/cairo/cairo.mk
@@ -11,6 +11,8 @@ CAIRO_LICENSE_FILES = COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1
 CAIRO_CPE_ID_VENDOR = cairographics
 CAIRO_SITE = http://cairographics.org/releases
 CAIRO_INSTALL_STAGING = YES
+# We're patching build/configure.ac.pthread
+CAIRO_AUTORECONF = YES
 
 # 0002-ft-Use-FT_Done_MM_Var-instead-of-free-when-available-in-cairo_ft_apply_variation.patch
 CAIRO_IGNORE_CVES += CVE-2018-19876
@@ -26,10 +28,6 @@ ifeq ($(BR2_m68k_cf),y)
 CAIRO_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -mxgot"
 endif
 
-ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),)
-CAIRO_CONF_ENV += CPPFLAGS="$(TARGET_CPPFLAGS) -DCAIRO_NO_MUTEX=1"
-endif
-
 # cairo can use C++11 atomics when available, so we need to link with
 # libatomic for the architectures who need libatomic.
 ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
@@ -70,6 +68,13 @@ HOST_CAIRO_DEPENDENCIES = \
 	host-pixman \
 	host-pkgconf
 
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+CAIRO_CONF_OPTS += --enable-pthread
+else
+CAIRO_CONF_OPTS += --disable-pthread
+CAIRO_CONF_ENV += CPPFLAGS="$(TARGET_CPPFLAGS) -DCAIRO_NO_MUTEX=1"
+endif
+
 # DirectFB svg support rely on Cairo and Cairo DirectFB support depends on
 # DirectFB. Break circular dependency by disabling DirectFB support in Cairo
 # (which is experimental)
-- 
2.39.1

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] package/cairo: fix pthread detection
@ 2023-07-29 10:30 Bernd Kuhls
  2023-09-11 21:06 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Kuhls @ 2023-07-29 10:30 UTC (permalink / raw)
  To: buildroot; +Cc: Fabrice Fontaine

Cairo's link check for pthreads support "must complete without warnings
or errors to stderr":
https://cgit.freedesktop.org/cairo/tree/build/aclocal.cairo.m4?h=1.16.0#n83
https://cgit.freedesktop.org/cairo/tree/build/configure.ac.pthread?h=1.16.0#n137

The pthread check fails with this defconfig

checking for cairo's pthread feature...
checking whether cairo's pthread feature could be enabled... no (can't link with -lpthread or -pthread)

due a warning thrown by ld:

/home/bernd/buildroot/output/per-package/cairo/host/bin/../lib/gcc/xtensa-buildroot-linux-uclibc/12.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld:
 warning: /home/bernd/buildroot/br4/output/per-package/cairo/host/bin/../lib/gcc/xtensa-buildroot-linux-uclibc/12.3.0/crtendS.o:
 missing .note.GNU-stack section implies executable stack

/home/bernd/buildroot/output/per-package/cairo/host/bin/../lib/gcc/xtensa-buildroot-linux-uclibc/12.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld:
 NOTE: This behaviour is deprecated and will be removed in a future version of the linker

These linker warnings were introduced by binutils 2.39:
https://www.redhat.com/en/blog/linkers-warnings-about-executable-stacks-and-segments

Silence them by adding "-Wl,-z,noexecstack" to fix cairo's pthread check

Meanwhile upstream removed autoconf support on the master branch:
https://cgit.freedesktop.org/cairo/commit/?id=efe303d9db6e24d5786c15252327811338bc9b0a
so no need to notify them.

Fixes:
http://autobuild.buildroot.net/results/408/408a900ac01dbce145aff302c75f9f4e147f5672/

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
---
 package/cairo/cairo.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/package/cairo/cairo.mk b/package/cairo/cairo.mk
index 7bc8f92deb..3e1a7956f7 100644
--- a/package/cairo/cairo.mk
+++ b/package/cairo/cairo.mk
@@ -19,7 +19,9 @@ CAIRO_IGNORE_CVES += CVE-2019-6462
 # 0004-Fix-mask-usage-in-image-compositor.patch
 CAIRO_IGNORE_CVES += CVE-2020-35492
 
-CAIRO_CONF_ENV = LIBS="$(CAIRO_LIBS)"
+CAIRO_CONF_ENV = \
+	LIBS="$(CAIRO_LIBS)" \
+	LDFLAGS="$(TARGET_LDFLAGS) -Wl,-z,noexecstack"
 
 # relocation truncated to fit: R_68K_GOT16O
 ifeq ($(BR2_m68k_cf),y)
-- 
2.39.2

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

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

end of thread, other threads:[~2023-09-11 21:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-23 15:32 [Buildroot] [PATCH 1/1] package/cairo: fix pthread detection Fabrice Fontaine
2023-02-23 22:47 ` Fabrice Fontaine
2023-02-23 23:00 ` Thomas Petazzoni via buildroot
2023-03-10 20:23   ` Arnout Vandecappelle
2023-09-11 21:08 ` Thomas Petazzoni via buildroot
  -- strict thread matches above, loose matches on Subject: below --
2023-07-29 10:30 Bernd Kuhls
2023-09-11 21:06 ` 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.