All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3] package/attr: fix build failure on Microblaze architecture
@ 2024-02-18  8:20 Giulio Benetti
  2024-02-18 20:12 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Giulio Benetti @ 2024-02-18  8:20 UTC (permalink / raw)
  To: buildroot; +Cc: Giulio Benetti, Thomas Petazzoni

On Microblaze architecture __has_attribute(__symver__) support is broken
and always return true even if symver is not supported so let's add an
upstream patch to detect if symver is supported during autoreconf. Let's
also add ATTR_AUTORECONF = YES to let patch to affect building.

Fixes:
http://autobuild.buildroot.org/results/29c76e02becedf922bd7dc0533338c078bf77d2a

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
V1->V2:
* written commit log as suggested by Thomas(there was no commit log at all
  since this patch has been pointed during Buildroot Dev Days in IRC to me)
* re-sent local patch to the correct maililng list and updated Upstream:
  URL
V2->V3:
* since patch has been upstreamed after a little rework, use it and point
  upstream commit URL
---
 ...dd-detection-of-symver-gcc-attribute.patch | 75 +++++++++++++++++++
 package/attr/attr.mk                          |  3 +
 2 files changed, 78 insertions(+)
 create mode 100644 package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch

diff --git a/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch
new file mode 100644
index 0000000000..ee029e9735
--- /dev/null
+++ b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch
@@ -0,0 +1,75 @@
+From 365426c28f8bf73d34d77cc06b7d5ffeae17f13a Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Tue, 6 Feb 2024 15:33:15 +0100
+Subject: [PATCH] configure.ac: add detection of symver gcc attribute
+
+On non-ELF platforms, such as microblaze, builds will fail when trying
+to add symver information because  __attribute__((symver ..)) is not
+supported even though __has_attribute(__symver__) returns true.
+
+Support for symver needs to be detected via a compile test since
+__has_attribute can report false positives [0].
+
+Add a configure compile check for __attribute__((symver ..)) to ensure
+it is supported and define a variable to advertise support.
+
+[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766#c1
+
+Upstream: https://git.savannah.nongnu.org/cgit/attr.git/commit/?id=943c776089dbb24ebbfb7432ba9841f1845bf95a
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+[Giulio: rework local patch for #if nesting]
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ configure.ac       | 15 +++++++++++++++
+ libattr/syscalls.c |  8 ++++----
+ 2 files changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 7e362e9..98477b5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -57,6 +57,21 @@ AS_CASE([$host_os],
+ 	[linux*], [os_linux=yes])
+ AM_CONDITIONAL([OS_LINUX], [test "x$os_linux" = "xyes"])
+ 
++AC_CACHE_CHECK(whether __attribute__((__symver__())) is supported,
++	gcc_cv_symver_attribute,
++	[cat > conftest.c <<EOF
++void foo (void) {}
++__typeof(foo) foo __attribute__ ((__symver__("foo@foo")));
++EOF
++	gcc_cv_symver_attribute=no
++	if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then \
++	    gcc_cv_symver_attribute=yes
++	fi
++	rm -f conftest.[cs]
++])
++AS_IF([test $gcc_cv_symver_attribute = yes],
++      [AC_DEFINE(HAVE_SYMVER_ATTRIBUTE, [], [GCC supports symver attribute])])
++
+ AC_CONFIG_COMMANDS([include/attr],
+ 	[dnl
+ 	rm -rf include/attr
+diff --git a/libattr/syscalls.c b/libattr/syscalls.c
+index 907560a..7ee6d39 100644
+--- a/libattr/syscalls.c
++++ b/libattr/syscalls.c
+@@ -31,10 +31,10 @@
+  * prefer symver attribute if available (since gcc 10),
+  * fall back to traditional .symver asm directive otherwise.
+  */
+-#ifdef __has_attribute
+-# if __has_attribute(__symver__)
+-#  define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn)))
+-# elif __has_attribute(__no_reorder__)
++#if defined(HAVE_SYMVER_ATTRIBUTE)
++# define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn)))
++#elif defined(__has_attribute)
++# if __has_attribute(__no_reorder__)
+    /*
+     * Avoid wrong partitioning with older gcc and LTO. May not work reliably
+     * with all versions; use -flto-partition=none if you encounter problems.
+-- 
+2.34.1
+
diff --git a/package/attr/attr.mk b/package/attr/attr.mk
index d1397921ff..1d24144f46 100644
--- a/package/attr/attr.mk
+++ b/package/attr/attr.mk
@@ -11,6 +11,9 @@ ATTR_LICENSE = GPL-2.0+ (programs), LGPL-2.1+ (libraries)
 ATTR_LICENSE_FILES = doc/COPYING doc/COPYING.LGPL
 ATTR_CPE_ID_VALID = YES
 
+# Flag added for patch dealing with symver in configure.ac
+ATTR_AUTORECONF = YES
+
 ATTR_INSTALL_STAGING = YES
 
 ATTR_CONF_OPTS = --disable-nls
-- 
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 v3] package/attr: fix build failure on Microblaze architecture
  2024-02-18  8:20 [Buildroot] [PATCH v3] package/attr: fix build failure on Microblaze architecture Giulio Benetti
@ 2024-02-18 20:12 ` Yann E. MORIN
  0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2024-02-18 20:12 UTC (permalink / raw)
  To: Giulio Benetti; +Cc: Thomas Petazzoni, buildroot

giulio, all,

On 2024-02-18 09:20 +0100, Giulio Benetti spake thusly:
> On Microblaze architecture __has_attribute(__symver__) support is broken
> and always return true even if symver is not supported so let's add an
> upstream patch to detect if symver is supported during autoreconf. Let's
> also add ATTR_AUTORECONF = YES to let patch to affect building.
> 
> Fixes:
> http://autobuild.buildroot.org/results/29c76e02becedf922bd7dc0533338c078bf77d2a
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
> V1->V2:
> * written commit log as suggested by Thomas(there was no commit log at all
>   since this patch has been pointed during Buildroot Dev Days in IRC to me)
> * re-sent local patch to the correct maililng list and updated Upstream:
>   URL
> V2->V3:
> * since patch has been upstreamed after a little rework, use it and point
>   upstream commit URL
> ---
>  ...dd-detection-of-symver-gcc-attribute.patch | 75 +++++++++++++++++++
>  package/attr/attr.mk                          |  3 +
>  2 files changed, 78 insertions(+)
>  create mode 100644 package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch
> 
> diff --git a/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch
> new file mode 100644
> index 0000000000..ee029e9735
> --- /dev/null
> +++ b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch
> @@ -0,0 +1,75 @@
> +From 365426c28f8bf73d34d77cc06b7d5ffeae17f13a Mon Sep 17 00:00:00 2001
> +From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> +Date: Tue, 6 Feb 2024 15:33:15 +0100
> +Subject: [PATCH] configure.ac: add detection of symver gcc attribute
> +
> +On non-ELF platforms, such as microblaze, builds will fail when trying
> +to add symver information because  __attribute__((symver ..)) is not
> +supported even though __has_attribute(__symver__) returns true.
> +
> +Support for symver needs to be detected via a compile test since
> +__has_attribute can report false positives [0].
> +
> +Add a configure compile check for __attribute__((symver ..)) to ensure
> +it is supported and define a variable to advertise support.
> +
> +[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766#c1
> +
> +Upstream: https://git.savannah.nongnu.org/cgit/attr.git/commit/?id=943c776089dbb24ebbfb7432ba9841f1845bf95a
> +
> +Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> +[Giulio: rework local patch for #if nesting]
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + configure.ac       | 15 +++++++++++++++
> + libattr/syscalls.c |  8 ++++----
> + 2 files changed, 19 insertions(+), 4 deletions(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index 7e362e9..98477b5 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -57,6 +57,21 @@ AS_CASE([$host_os],
> + 	[linux*], [os_linux=yes])
> + AM_CONDITIONAL([OS_LINUX], [test "x$os_linux" = "xyes"])
> + 
> ++AC_CACHE_CHECK(whether __attribute__((__symver__())) is supported,
> ++	gcc_cv_symver_attribute,
> ++	[cat > conftest.c <<EOF
> ++void foo (void) {}
> ++__typeof(foo) foo __attribute__ ((__symver__("foo@foo")));
> ++EOF
> ++	gcc_cv_symver_attribute=no
> ++	if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then \
> ++	    gcc_cv_symver_attribute=yes
> ++	fi
> ++	rm -f conftest.[cs]
> ++])
> ++AS_IF([test $gcc_cv_symver_attribute = yes],
> ++      [AC_DEFINE(HAVE_SYMVER_ATTRIBUTE, [], [GCC supports symver attribute])])
> ++
> + AC_CONFIG_COMMANDS([include/attr],
> + 	[dnl
> + 	rm -rf include/attr
> +diff --git a/libattr/syscalls.c b/libattr/syscalls.c
> +index 907560a..7ee6d39 100644
> +--- a/libattr/syscalls.c
> ++++ b/libattr/syscalls.c
> +@@ -31,10 +31,10 @@
> +  * prefer symver attribute if available (since gcc 10),
> +  * fall back to traditional .symver asm directive otherwise.
> +  */
> +-#ifdef __has_attribute
> +-# if __has_attribute(__symver__)
> +-#  define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn)))
> +-# elif __has_attribute(__no_reorder__)
> ++#if defined(HAVE_SYMVER_ATTRIBUTE)
> ++# define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn)))
> ++#elif defined(__has_attribute)
> ++# if __has_attribute(__no_reorder__)
> +    /*
> +     * Avoid wrong partitioning with older gcc and LTO. May not work reliably
> +     * with all versions; use -flto-partition=none if you encounter problems.
> +-- 
> +2.34.1
> +
> diff --git a/package/attr/attr.mk b/package/attr/attr.mk
> index d1397921ff..1d24144f46 100644
> --- a/package/attr/attr.mk
> +++ b/package/attr/attr.mk
> @@ -11,6 +11,9 @@ ATTR_LICENSE = GPL-2.0+ (programs), LGPL-2.1+ (libraries)
>  ATTR_LICENSE_FILES = doc/COPYING doc/COPYING.LGPL
>  ATTR_CPE_ID_VALID = YES
>  
> +# Flag added for patch dealing with symver in configure.ac
> +ATTR_AUTORECONF = YES
> +
>  ATTR_INSTALL_STAGING = YES
>  
>  ATTR_CONF_OPTS = --disable-nls
> -- 
> 2.34.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
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:[~2024-02-18 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18  8:20 [Buildroot] [PATCH v3] package/attr: fix build failure on Microblaze architecture Giulio Benetti
2024-02-18 20:12 ` Yann E. MORIN

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.