All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix strace & gdb build on aarch64/musl
@ 2019-05-08 11:58 paul
  2019-05-08 11:58 ` [PATCH 1/2] gdb: Fix aarch64 build with musl paul
  2019-05-08 11:58 ` [PATCH 2/2] strace: " paul
  0 siblings, 2 replies; 12+ messages in thread
From: paul @ 2019-05-08 11:58 UTC (permalink / raw)
  To: openembedded-core

From: Paul Barker <paul@betafive.co.uk>

These patches should also apply cleanly to warrior after the commit
"gdb: fix CVE-2017-9778" is backported.

Paul Barker (2):
  gdb: Fix aarch64 build with musl
  strace: Fix aarch64 build with musl

 meta/recipes-devtools/gdb/gdb-8.2.1.inc       |  1 +
 ...h64-Fix-the-gdb-build-with-musl-libc.patch | 52 +++++++++++++++++++
 .../strace/strace/musl-fixes-armv8.patch      | 29 +++++++++++
 meta/recipes-devtools/strace/strace_4.26.bb   |  1 +
 4 files changed, 83 insertions(+)
 create mode 100644 meta/recipes-devtools/gdb/gdb/0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch
 create mode 100644 meta/recipes-devtools/strace/strace/musl-fixes-armv8.patch

-- 
2.17.1



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

* [PATCH 1/2] gdb: Fix aarch64 build with musl
  2019-05-08 11:58 [PATCH 0/2] Fix strace & gdb build on aarch64/musl paul
@ 2019-05-08 11:58 ` paul
  2019-05-08 11:58 ` [PATCH 2/2] strace: " paul
  1 sibling, 0 replies; 12+ messages in thread
From: paul @ 2019-05-08 11:58 UTC (permalink / raw)
  To: openembedded-core

From: Paul Barker <paul@betafive.co.uk>

Signed-off-by: Paul Barker <paul@betafive.co.uk>
---
 meta/recipes-devtools/gdb/gdb-8.2.1.inc       |  1 +
 ...h64-Fix-the-gdb-build-with-musl-libc.patch | 52 +++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 meta/recipes-devtools/gdb/gdb/0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch

diff --git a/meta/recipes-devtools/gdb/gdb-8.2.1.inc b/meta/recipes-devtools/gdb/gdb-8.2.1.inc
index cb8d189f2a..f28b57439c 100644
--- a/meta/recipes-devtools/gdb/gdb-8.2.1.inc
+++ b/meta/recipes-devtools/gdb/gdb-8.2.1.inc
@@ -18,6 +18,7 @@ SRC_URI = "http://ftp.gnu.org/gnu/gdb/gdb-${PV}.tar.xz \
            file://gdbserver-ctrl-c-handling.patch \
            file://0001-Fix-build-with-latest-GCC-9.0-tree.patch \
            file://CVE-2017-9778.patch \
+           file://0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch \
 "
 SRC_URI[md5sum] = "f8b2562e830a4098dd5b5ea9e9296c70"
 SRC_URI[sha256sum] = "0a6a432907a03c5c8eaad3c3cffd50c00a40c3a5e3c4039440624bae703f2202"
diff --git a/meta/recipes-devtools/gdb/gdb/0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch b/meta/recipes-devtools/gdb/gdb/0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch
new file mode 100644
index 0000000000..cafc4a871c
--- /dev/null
+++ b/meta/recipes-devtools/gdb/gdb/0012-AArch64-Fix-the-gdb-build-with-musl-libc.patch
@@ -0,0 +1,52 @@
+From cbbf1a8ba7f037ba3b83f090829edcbab542c285 Mon Sep 17 00:00:00 2001
+From: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Date: Thu, 13 Dec 2018 17:47:17 +0000
+Subject: [PATCH] AArch64: Fix the gdb build with musl libc
+
+Including asm/sigcontext.h together with libc headers is not valid. In
+general linux headers may not work with libc headers, so mixing them
+should be avoided, especially when the linux header defines types that
+are also exposed in libc headers.
+
+In case of asm/sigcontext.h glibc happens to work because glibc signal.h
+directly includes it, but e.g. in musl libc signal.h replicates the
+sigcontext.h definitions in an abi compatible way which are in conflict
+with the linux definitions when both headers are included.
+
+Since old linux headers or old libc headers may not have the necessary
+definitions, gdb has to replicate the definitions it relies on anyway.
+Which is fine since all definitions must be ABI stable. For linux apis
+that are not available via libc headers, replicating the definitions in
+gdb is the most reliable way to use them.
+
+Note: asm/ptrace.h includes asm/sigcontext.h in some versions of linux
+headers, which is just as problematic and should be fixed in linux.
+
+gdb/ChangeLog:
+
+	* nat/aarch64-sve-linux-ptrace.h: Include signal.h instead of
+	asm/sigcontext.h.
+
+[ChangeLog entry stripped so that patch applies cleanly]
+Upstream-status: Backport
+Signed-off-by: Paul Barker <paul@betafive.co.uk>
+---
+ gdb/nat/aarch64-sve-linux-ptrace.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gdb/nat/aarch64-sve-linux-ptrace.h b/gdb/nat/aarch64-sve-linux-ptrace.h
+index 029e753ffe..172ae39432 100644
+--- a/gdb/nat/aarch64-sve-linux-ptrace.h
++++ b/gdb/nat/aarch64-sve-linux-ptrace.h
+@@ -20,7 +20,7 @@
+ #ifndef AARCH64_SVE_LINUX_PTRACE_H
+ #define AARCH64_SVE_LINUX_PTRACE_H
+ 
+-#include <asm/sigcontext.h>
++#include <signal.h>
+ #include <sys/utsname.h>
+ #include <sys/ptrace.h>
+ #include <asm/ptrace.h>
+-- 
+2.17.1
+
-- 
2.17.1



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

* [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-08 11:58 [PATCH 0/2] Fix strace & gdb build on aarch64/musl paul
  2019-05-08 11:58 ` [PATCH 1/2] gdb: Fix aarch64 build with musl paul
@ 2019-05-08 11:58 ` paul
  2019-05-08 13:02   ` Adrian Bunk
  1 sibling, 1 reply; 12+ messages in thread
From: paul @ 2019-05-08 11:58 UTC (permalink / raw)
  To: openembedded-core

From: Paul Barker <paul@betafive.co.uk>

Signed-off-by: Paul Barker <paul@betafive.co.uk>
---
 .../strace/strace/musl-fixes-armv8.patch      | 29 +++++++++++++++++++
 meta/recipes-devtools/strace/strace_4.26.bb   |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 meta/recipes-devtools/strace/strace/musl-fixes-armv8.patch

diff --git a/meta/recipes-devtools/strace/strace/musl-fixes-armv8.patch b/meta/recipes-devtools/strace/strace/musl-fixes-armv8.patch
new file mode 100644
index 0000000000..185d1bef56
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/musl-fixes-armv8.patch
@@ -0,0 +1,29 @@
+Fixes on musl + armv8:
+
+error: redefinition of 'struct prctl_mm_map'
+ struct prctl_mm_map {
+        ^~~~~~~~~~~~
+In file included from work/aarch64-lmp-linux-musl/strace/4.26-r0/recipe-sysroot/usr/include/asm/ptrace.h:67,
+                 from work/aarch64-lmp-linux-musl/strace/4.26-r0/recipe-sysroot/usr/include/linux/ptrace.h:107,
+                 from ../strace-4.26/ptrace.h:36,
+                 from ../strace-4.26/strace.c:16:
+work/aarch64-lmp-linux-musl/strace/4.26-r0/recipe-sysroot/usr/include/linux/prctl.h:134:8: note: originally defined here
+ struct prctl_mm_map {
+        ^~~~~~~~~~~~
+
+[From: https://github.com/foundriesio/meta-lmp, thanks to Ricardo Salveti]
+Upstream-status: Pending
+Signed-off-by: Paul Barker <paul@betafive.co.uk>
+
+Index: strace-4.26/strace.c
+===================================================================
+--- strace-4.26.orig/strace.c
++++ strace-4.26/strace.c
+@@ -26,7 +26,7 @@
+ #include <locale.h>
+ #include <sys/utsname.h>
+ #ifdef HAVE_PRCTL
+-# include <sys/prctl.h>
++# include <linux/prctl.h>
+ #endif
+ #include <asm/unistd.h>
diff --git a/meta/recipes-devtools/strace/strace_4.26.bb b/meta/recipes-devtools/strace/strace_4.26.bb
index 24f92c99e5..b71122babf 100644
--- a/meta/recipes-devtools/strace/strace_4.26.bb
+++ b/meta/recipes-devtools/strace/strace_4.26.bb
@@ -15,6 +15,7 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
            file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
            file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \
            file://0001-mips-o32-fix-build.patch \
+           file://musl-fixes-armv8.patch \
            "
 SRC_URI[md5sum] = "daa51acc0c7c696221ec03cf0b30a7af"
 SRC_URI[sha256sum] = "7c4d2ffeef4f7d1cdc71062ca78d1130eb52f947c2fca82f59f6a1183bfa1e1c"
-- 
2.17.1



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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-08 11:58 ` [PATCH 2/2] strace: " paul
@ 2019-05-08 13:02   ` Adrian Bunk
  2019-05-09 10:13     ` Paul Barker
  0 siblings, 1 reply; 12+ messages in thread
From: Adrian Bunk @ 2019-05-08 13:02 UTC (permalink / raw)
  To: paul; +Cc: openembedded-core

On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk wrote:
>...
> +--- strace-4.26.orig/strace.c
> ++++ strace-4.26/strace.c
> +@@ -26,7 +26,7 @@
> + #include <locale.h>
> + #include <sys/utsname.h>
> + #ifdef HAVE_PRCTL
> +-# include <sys/prctl.h>
> ++# include <linux/prctl.h>
> + #endif
> + #include <asm/unistd.h>
> diff --git a/meta/recipes-devtools/strace/strace_4.26.bb b/meta/recipes-devtools/strace/strace_4.26.bb
> index 24f92c99e5..b71122babf 100644
> --- a/meta/recipes-devtools/strace/strace_4.26.bb
> +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> @@ -15,6 +15,7 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
>             file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
>             file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \
>             file://0001-mips-o32-fix-build.patch \
> +           file://musl-fixes-armv8.patch \
>             "
>...

#include <sys/prctl.h> is the documented way for getting the prototype 
of prctl(), which cannot be in linux/prctl.h for obvious reasons.

This patch creates the following problem:

../strace-4.26/strace.c: In function 'startup_child':
../strace-4.26/strace.c:1355:3: warning: implicit declaration of function 'prctl' [-Wimplicit-function-declaration]
   prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
   ^~~~~


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-08 13:02   ` Adrian Bunk
@ 2019-05-09 10:13     ` Paul Barker
  2019-05-09 12:08       ` Paul Barker
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Barker @ 2019-05-09 10:13 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: OE Core

On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk wrote:
> >...
> > +--- strace-4.26.orig/strace.c
> > ++++ strace-4.26/strace.c
> > +@@ -26,7 +26,7 @@
> > + #include <locale.h>
> > + #include <sys/utsname.h>
> > + #ifdef HAVE_PRCTL
> > +-# include <sys/prctl.h>
> > ++# include <linux/prctl.h>
> > + #endif
> > + #include <asm/unistd.h>
> > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb b/meta/recipes-devtools/strace/strace_4.26.bb
> > index 24f92c99e5..b71122babf 100644
> > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> > @@ -15,6 +15,7 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
> >             file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> >             file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \
> >             file://0001-mips-o32-fix-build.patch \
> > +           file://musl-fixes-armv8.patch \
> >             "
> >...
> 
> #include <sys/prctl.h> is the documented way for getting the prototype 
> of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> 
> This patch creates the following problem:
> 
> ../strace-4.26/strace.c: In function 'startup_child':
> ../strace-4.26/strace.c:1355:3: warning: implicit declaration of 
> function 'prctl' [-Wimplicit-function-declaration]
>    prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
>    ^~~~~
> 

Ah that's definitely not a solution then. I'll have to look into this further and see if I can come up with a v2 patch that doesn't cause this warning.

-- 
Paul Barker
Managing Director & Principal Engineer
Beta Five Ltd


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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 10:13     ` Paul Barker
@ 2019-05-09 12:08       ` Paul Barker
  2019-05-09 13:43         ` Richard Purdie
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Barker @ 2019-05-09 12:08 UTC (permalink / raw)
  To: OE Core

On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk wrote:
> > >...
> > > +--- strace-4.26.orig/strace.c
> > > ++++ strace-4.26/strace.c
> > > +@@ -26,7 +26,7 @@
> > > + #include <locale.h>
> > > + #include <sys/utsname.h>
> > > + #ifdef HAVE_PRCTL
> > > +-# include <sys/prctl.h>
> > > ++# include <linux/prctl.h>
> > > + #endif
> > > + #include <asm/unistd.h>
> > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb b/meta/recipes-devtools/strace/strace_4.26.bb
> > > index 24f92c99e5..b71122babf 100644
> > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> > > @@ -15,6 +15,7 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
> > >             file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> > >             file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \
> > >             file://0001-mips-o32-fix-build.patch \
> > > +           file://musl-fixes-armv8.patch \
> > >             "
> > >...
> > 
> > #include <sys/prctl.h> is the documented way for getting the prototype 
> > of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> > 
> > This patch creates the following problem:
> > 
> > ../strace-4.26/strace.c: In function 'startup_child':
> > ../strace-4.26/strace.c:1355:3: warning: implicit declaration of 
> > function 'prctl' [-Wimplicit-function-declaration]
> >    prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> >    ^~~~~
> > 
> 
> Ah that's definitely not a solution then. I'll have to look into this 
> further and see if I can come up with a v2 patch that doesn't cause 
> this warning.
> 

So alpine fixes this by patching the linux headers: https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch

I think that should be acceptable here if we just do it when building with musl libc.

Any thoughts on that before I work up a v2 patch?

Thanks,

-- 
Paul Barker
Managing Director & Principal Engineer
Beta Five Ltd


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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 12:08       ` Paul Barker
@ 2019-05-09 13:43         ` Richard Purdie
  2019-05-09 13:48           ` Bruce Ashfield
  2019-05-09 14:31           ` Adrian Bunk
  0 siblings, 2 replies; 12+ messages in thread
From: Richard Purdie @ 2019-05-09 13:43 UTC (permalink / raw)
  To: Paul Barker, OE Core

On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
> On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> > On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> > > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk
> > > wrote:
> > > > ...
> > > > +--- strace-4.26.orig/strace.c
> > > > ++++ strace-4.26/strace.c
> > > > +@@ -26,7 +26,7 @@
> > > > + #include <locale.h>
> > > > + #include <sys/utsname.h>
> > > > + #ifdef HAVE_PRCTL
> > > > +-# include <sys/prctl.h>
> > > > ++# include <linux/prctl.h>
> > > > + #endif
> > > > + #include <asm/unistd.h>
> > > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb
> > > > b/meta/recipes-devtools/strace/strace_4.26.bb
> > > > index 24f92c99e5..b71122babf 100644
> > > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> > > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> > > > @@ -15,6 +15,7 @@ SRC_URI = "
> > > > https://strace.io/files/${PV}/strace-${PV}.tar.xz \
> > > >             file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> > > >             file://0001-tests-sigaction-Check-for-mips-and-
> > > > alpha-before-usin.patch \
> > > >             file://0001-mips-o32-fix-build.patch \
> > > > +           file://musl-fixes-armv8.patch \
> > > >             "
> > > > ...
> > > 
> > > #include <sys/prctl.h> is the documented way for getting the
> > > prototype 
> > > of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> > > 
> > > This patch creates the following problem:
> > > 
> > > ../strace-4.26/strace.c: In function 'startup_child':
> > > ../strace-4.26/strace.c:1355:3: warning: implicit declaration of 
> > > function 'prctl' [-Wimplicit-function-declaration]
> > >    prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> > >    ^~~~~
> > > 
> > 
> > Ah that's definitely not a solution then. I'll have to look into
> > this 
> > further and see if I can come up with a v2 patch that doesn't
> > cause 
> > this warning.
> > 
> 
> So alpine fixes this by patching the linux headers: 
> https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> 
> I think that should be acceptable here if we just do it when building
> with musl libc.
> 
> Any thoughts on that before I work up a v2 patch?

This really needs to get fixed upstream. I don't mind a patch but only
if its gone upstream, we don't want to be carrying patches to libc-
headers.

Cheers,

Richard



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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 13:43         ` Richard Purdie
@ 2019-05-09 13:48           ` Bruce Ashfield
  2019-05-09 14:00             ` Paul Barker
  2019-05-09 14:31           ` Adrian Bunk
  1 sibling, 1 reply; 12+ messages in thread
From: Bruce Ashfield @ 2019-05-09 13:48 UTC (permalink / raw)
  To: Richard Purdie; +Cc: OE Core

[-- Attachment #1: Type: text/plain, Size: 3384 bytes --]

On Thu, May 9, 2019 at 9:43 AM Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
> > On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> > > On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> > > > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk
> > > > wrote:
> > > > > ...
> > > > > +--- strace-4.26.orig/strace.c
> > > > > ++++ strace-4.26/strace.c
> > > > > +@@ -26,7 +26,7 @@
> > > > > + #include <locale.h>
> > > > > + #include <sys/utsname.h>
> > > > > + #ifdef HAVE_PRCTL
> > > > > +-# include <sys/prctl.h>
> > > > > ++# include <linux/prctl.h>
> > > > > + #endif
> > > > > + #include <asm/unistd.h>
> > > > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb
> > > > > b/meta/recipes-devtools/strace/strace_4.26.bb
> > > > > index 24f92c99e5..b71122babf 100644
> > > > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> > > > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> > > > > @@ -15,6 +15,7 @@ SRC_URI = "
> > > > > https://strace.io/files/${PV}/strace-${PV}.tar.xz \
> > > > >             file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> > > > >             file://0001-tests-sigaction-Check-for-mips-and-
> > > > > alpha-before-usin.patch \
> > > > >             file://0001-mips-o32-fix-build.patch \
> > > > > +           file://musl-fixes-armv8.patch \
> > > > >             "
> > > > > ...
> > > >
> > > > #include <sys/prctl.h> is the documented way for getting the
> > > > prototype
> > > > of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> > > >
> > > > This patch creates the following problem:
> > > >
> > > > ../strace-4.26/strace.c: In function 'startup_child':
> > > > ../strace-4.26/strace.c:1355:3: warning: implicit declaration of
> > > > function 'prctl' [-Wimplicit-function-declaration]
> > > >    prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> > > >    ^~~~~
> > > >
> > >
> > > Ah that's definitely not a solution then. I'll have to look into
> > > this
> > > further and see if I can come up with a v2 patch that doesn't
> > > cause
> > > this warning.
> > >
> >
> > So alpine fixes this by patching the linux headers:
> >
> https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> >
> > I think that should be acceptable here if we just do it when building
> > with musl libc.
> >
> > Any thoughts on that before I work up a v2 patch?
>
> This really needs to get fixed upstream. I don't mind a patch but only
> if its gone upstream, we don't want to be carrying patches to libc-
> headers.
>

I can live with that as well, we have carried them just for musl in the
past, but yes, we should at least know that someone is trying to upstream
it. I can't get the alpine linux git to come in right now, so I can't check
the referenced change to see how it looks.

I'm going to do new libc-headers when I get the -dev kernel up and running
with the 5.2-rc kernels, so I can watch to see that it continues to apply.
I can also do some extra build testing here, if you want the headers change
to come through my next pull request.

Bruce



>
> Cheers,
>
> Richard
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

[-- Attachment #2: Type: text/html, Size: 5693 bytes --]

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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 13:48           ` Bruce Ashfield
@ 2019-05-09 14:00             ` Paul Barker
  2019-05-09 14:07               ` Bruce Ashfield
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Barker @ 2019-05-09 14:00 UTC (permalink / raw)
  To: Bruce Ashfield, Richard Purdie; +Cc: OE Core

On Thu, 9 May 2019, at 14:48, Bruce Ashfield wrote:
> 
> 
> On Thu, May 9, 2019 at 9:43 AM Richard Purdie 
> <richard.purdie@linuxfoundation.org> wrote:
> > On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
> >  > On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> >  > > On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> >  > > > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk
> >  > > > wrote:
> >  > > > > ...
> >  > > > > +--- strace-4.26.orig/strace.c
> >  > > > > ++++ strace-4.26/strace.c
> >  > > > > +@@ -26,7 +26,7 @@
> >  > > > > + #include <locale.h>
> >  > > > > + #include <sys/utsname.h>
> >  > > > > + #ifdef HAVE_PRCTL
> >  > > > > +-# include <sys/prctl.h>
> >  > > > > ++# include <linux/prctl.h>
> >  > > > > + #endif
> >  > > > > + #include <asm/unistd.h>
> >  > > > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > b/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > index 24f92c99e5..b71122babf 100644
> >  > > > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > @@ -15,6 +15,7 @@ SRC_URI = "
> >  > > > > https://strace.io/files/${PV}/strace-${PV}.tar.xz <https://strace.io/files/$%7BPV%7D/strace-$%7BPV%7D.tar.xz> \
> >  > > > > file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> >  > > > > file://0001-tests-sigaction-Check-for-mips-and-
> >  > > > > alpha-before-usin.patch \
> >  > > > > file://0001-mips-o32-fix-build.patch \
> >  > > > > + file://musl-fixes-armv8.patch \
> >  > > > > "
> >  > > > > ...
> >  > > > 
> >  > > > #include <sys/prctl.h> is the documented way for getting the
> >  > > > prototype 
> >  > > > of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> >  > > > 
> >  > > > This patch creates the following problem:
> >  > > > 
> >  > > > ../strace-4.26/strace.c: In function 'startup_child':
> >  > > > ../strace-4.26/strace.c:1355:3: warning: implicit declaration of 
> >  > > > function 'prctl' [-Wimplicit-function-declaration]
> >  > > > prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> >  > > > ^~~~~
> >  > > > 
> >  > > 
> >  > > Ah that's definitely not a solution then. I'll have to look into
> >  > > this 
> >  > > further and see if I can come up with a v2 patch that doesn't
> >  > > cause 
> >  > > this warning.
> >  > > 
> >  > 
> >  > So alpine fixes this by patching the linux headers: 
> >  > https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> >  > 
> >  > I think that should be acceptable here if we just do it when building
> >  > with musl libc.
> >  > 
> >  > Any thoughts on that before I work up a v2 patch?
> > 
> >  This really needs to get fixed upstream. I don't mind a patch but only
> >  if its gone upstream, we don't want to be carrying patches to libc-
> >  headers.
> 
> I can live with that as well, we have carried them just for musl in the 
> past, but yes, we should at least know that someone is trying to 
> upstream it. I can't get the alpine linux git to come in right now, so 
> I can't check the referenced change to see how it looks.
> 
> I'm going to do new libc-headers when I get the -dev kernel up and 
> running with the 5.2-rc kernels, so I can watch to see that it 
> continues to apply. I can also do some extra build testing here, if you 
> want the headers change to come through my next pull request.
> 

There's a lot of redefinition between musl and the kernel headers that hasn't been reconciled yet (see https://www.spinics.net/lists/y2038/msg03836.html for some discussion) so I think there's much more to be done upstream than just fixing this one instance.

I'm now dropping the `#include <linux/prctl.h>` line in arch/arm64/include/uapi/asm/ptrace.h (https://github.com/torvalds/linux/blob/v5.1/arch/arm64/include/uapi/asm/ptrace.h#L68) in linux-libc-headers and that's giving working builds for me but I'm not sure how universally it can be applied. I'm happy to carry that as a bbappend in our distro layer for now but that will leave strace broke on aarch64 when using musl for others.

Thanks,

-- 
Paul Barker
Managing Director & Principal Engineer
Beta Five Ltd


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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 14:00             ` Paul Barker
@ 2019-05-09 14:07               ` Bruce Ashfield
  2019-05-09 14:10                 ` Paul Barker
  0 siblings, 1 reply; 12+ messages in thread
From: Bruce Ashfield @ 2019-05-09 14:07 UTC (permalink / raw)
  To: Paul Barker; +Cc: OE Core

[-- Attachment #1: Type: text/plain, Size: 5245 bytes --]

On Thu, May 9, 2019 at 10:00 AM Paul Barker <paul@betafive.co.uk> wrote:

> On Thu, 9 May 2019, at 14:48, Bruce Ashfield wrote:
> >
> >
> > On Thu, May 9, 2019 at 9:43 AM Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > > On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
> > >  > On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> > >  > > On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> > >  > > > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk
> > >  > > > wrote:
> > >  > > > > ...
> > >  > > > > +--- strace-4.26.orig/strace.c
> > >  > > > > ++++ strace-4.26/strace.c
> > >  > > > > +@@ -26,7 +26,7 @@
> > >  > > > > + #include <locale.h>
> > >  > > > > + #include <sys/utsname.h>
> > >  > > > > + #ifdef HAVE_PRCTL
> > >  > > > > +-# include <sys/prctl.h>
> > >  > > > > ++# include <linux/prctl.h>
> > >  > > > > + #endif
> > >  > > > > + #include <asm/unistd.h>
> > >  > > > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb
> > >  > > > > b/meta/recipes-devtools/strace/strace_4.26.bb
> > >  > > > > index 24f92c99e5..b71122babf 100644
> > >  > > > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> > >  > > > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> > >  > > > > @@ -15,6 +15,7 @@ SRC_URI = "
> > >  > > > > https://strace.io/files/${PV}/strace-${PV}.tar.xz <
> https://strace.io/files/$%7BPV%7D/strace-$%7BPV%7D.tar.xz> \
> > >  > > > > file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> > >  > > > > file://0001-tests-sigaction-Check-for-mips-and-
> > >  > > > > alpha-before-usin.patch \
> > >  > > > > file://0001-mips-o32-fix-build.patch \
> > >  > > > > + file://musl-fixes-armv8.patch \
> > >  > > > > "
> > >  > > > > ...
> > >  > > >
> > >  > > > #include <sys/prctl.h> is the documented way for getting the
> > >  > > > prototype
> > >  > > > of prctl(), which cannot be in linux/prctl.h for obvious
> reasons.
> > >  > > >
> > >  > > > This patch creates the following problem:
> > >  > > >
> > >  > > > ../strace-4.26/strace.c: In function 'startup_child':
> > >  > > > ../strace-4.26/strace.c:1355:3: warning: implicit declaration
> of
> > >  > > > function 'prctl' [-Wimplicit-function-declaration]
> > >  > > > prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> > >  > > > ^~~~~
> > >  > > >
> > >  > >
> > >  > > Ah that's definitely not a solution then. I'll have to look into
> > >  > > this
> > >  > > further and see if I can come up with a v2 patch that doesn't
> > >  > > cause
> > >  > > this warning.
> > >  > >
> > >  >
> > >  > So alpine fixes this by patching the linux headers:
> > >  >
> https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> > >  >
> > >  > I think that should be acceptable here if we just do it when
> building
> > >  > with musl libc.
> > >  >
> > >  > Any thoughts on that before I work up a v2 patch?
> > >
> > >  This really needs to get fixed upstream. I don't mind a patch but only
> > >  if its gone upstream, we don't want to be carrying patches to libc-
> > >  headers.
> >
> > I can live with that as well, we have carried them just for musl in the
> > past, but yes, we should at least know that someone is trying to
> > upstream it. I can't get the alpine linux git to come in right now, so
> > I can't check the referenced change to see how it looks.
> >
> > I'm going to do new libc-headers when I get the -dev kernel up and
> > running with the 5.2-rc kernels, so I can watch to see that it
> > continues to apply. I can also do some extra build testing here, if you
> > want the headers change to come through my next pull request.
> >
>
> There's a lot of redefinition between musl and the kernel headers that
> hasn't been reconciled yet (see
> https://www.spinics.net/lists/y2038/msg03836.html for some discussion) so
> I think there's much more to be done upstream than just fixing this one
> instance.
>

Agreed. There's a long, bikeshedding, philosophical debate about musl and
headers that is always ongoing (not this discussion, that is not my
comment). But if this one instance is a small change, I think it is worth
carrying, the amount of musl patches to libc-headers has fluctuated over
time, so this is no different. We can only deal with the problems we are
seeing in our builds (I state the obvious).



>
> I'm now dropping the `#include <linux/prctl.h>` line in
> arch/arm64/include/uapi/asm/ptrace.h (
> https://github.com/torvalds/linux/blob/v5.1/arch/arm64/include/uapi/asm/ptrace.h#L68)
> in linux-libc-headers and that's giving working builds for me but I'm not
> sure how universally it can be applied. I'm happy to carry that as a
> bbappend in our distro layer for now but that will leave strace broke on
> aarch64 when using musl for others.
>
>
I'm still ok with patching it out of the headers, build tests would shake
any issues out, but I can't see there being too many.

Bruce



> Thanks,
>
> --
> Paul Barker
> Managing Director & Principal Engineer
> Beta Five Ltd
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

[-- Attachment #2: Type: text/html, Size: 8533 bytes --]

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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 14:07               ` Bruce Ashfield
@ 2019-05-09 14:10                 ` Paul Barker
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Barker @ 2019-05-09 14:10 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: OE Core

On Thu, 9 May 2019, at 15:07, Bruce Ashfield wrote:
> 
> 
> On Thu, May 9, 2019 at 10:00 AM Paul Barker <paul@betafive.co.uk> wrote:
> > On Thu, 9 May 2019, at 14:48, Bruce Ashfield wrote:
> >  > 
> >  > 
> >  > On Thu, May 9, 2019 at 9:43 AM Richard Purdie 
> >  > <richard.purdie@linuxfoundation.org> wrote:
> >  > > On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
> >  > > > On Thu, 9 May 2019, at 11:13, Paul Barker wrote:
> >  > > > > On Wed, 8 May 2019, at 14:02, Adrian Bunk wrote:
> >  > > > > > On Wed, May 08, 2019 at 11:58:36AM +0000, paul@betafive.co.uk
> >  > > > > > wrote:
> >  > > > > > > ...
> >  > > > > > > +--- strace-4.26.orig/strace.c
> >  > > > > > > ++++ strace-4.26/strace.c
> >  > > > > > > +@@ -26,7 +26,7 @@
> >  > > > > > > + #include <locale.h>
> >  > > > > > > + #include <sys/utsname.h>
> >  > > > > > > + #ifdef HAVE_PRCTL
> >  > > > > > > +-# include <sys/prctl.h>
> >  > > > > > > ++# include <linux/prctl.h>
> >  > > > > > > + #endif
> >  > > > > > > + #include <asm/unistd.h>
> >  > > > > > > diff --git a/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > > > b/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > > > index 24f92c99e5..b71122babf 100644
> >  > > > > > > --- a/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > > > +++ b/meta/recipes-devtools/strace/strace_4.26.bb
> >  > > > > > > @@ -15,6 +15,7 @@ SRC_URI = "
> >  > > > > > > https://strace.io/files/${PV}/strace-${PV}.tar.xz <https://strace.io/files/$%7BPV%7D/strace-$%7BPV%7D.tar.xz> <https://strace.io/files/$%7BPV%7D/strace-$%7BPV%7D.tar.xz> \
> >  > > > > > > file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \
> >  > > > > > > file://0001-tests-sigaction-Check-for-mips-and-
> >  > > > > > > alpha-before-usin.patch \
> >  > > > > > > file://0001-mips-o32-fix-build.patch \
> >  > > > > > > + file://musl-fixes-armv8.patch \
> >  > > > > > > "
> >  > > > > > > ...
> >  > > > > > 
> >  > > > > > #include <sys/prctl.h> is the documented way for getting the
> >  > > > > > prototype 
> >  > > > > > of prctl(), which cannot be in linux/prctl.h for obvious reasons.
> >  > > > > > 
> >  > > > > > This patch creates the following problem:
> >  > > > > > 
> >  > > > > > ../strace-4.26/strace.c: In function 'startup_child':
> >  > > > > > ../strace-4.26/strace.c:1355:3: warning: implicit declaration of 
> >  > > > > > function 'prctl' [-Wimplicit-function-declaration]
> >  > > > > > prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
> >  > > > > > ^~~~~
> >  > > > > > 
> >  > > > > 
> >  > > > > Ah that's definitely not a solution then. I'll have to look into
> >  > > > > this 
> >  > > > > further and see if I can come up with a v2 patch that doesn't
> >  > > > > cause 
> >  > > > > this warning.
> >  > > > > 
> >  > > > 
> >  > > > So alpine fixes this by patching the linux headers: 
> >  > > > https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> >  > > > 
> >  > > > I think that should be acceptable here if we just do it when building
> >  > > > with musl libc.
> >  > > > 
> >  > > > Any thoughts on that before I work up a v2 patch?
> >  > > 
> >  > > This really needs to get fixed upstream. I don't mind a patch but only
> >  > > if its gone upstream, we don't want to be carrying patches to libc-
> >  > > headers.
> >  > 
> >  > I can live with that as well, we have carried them just for musl in the 
> >  > past, but yes, we should at least know that someone is trying to 
> >  > upstream it. I can't get the alpine linux git to come in right now, so 
> >  > I can't check the referenced change to see how it looks.
> >  > 
> >  > I'm going to do new libc-headers when I get the -dev kernel up and 
> >  > running with the 5.2-rc kernels, so I can watch to see that it 
> >  > continues to apply. I can also do some extra build testing here, if you 
> >  > want the headers change to come through my next pull request.
> >  > 
> > 
> >  There's a lot of redefinition between musl and the kernel headers that hasn't been reconciled yet (see https://www.spinics.net/lists/y2038/msg03836.html for some discussion) so I think there's much more to be done upstream than just fixing this one instance.
> 
> Agreed. There's a long, bikeshedding, philosophical debate about musl 
> and headers that is always ongoing (not this discussion, that is not my 
> comment). But if this one instance is a small change, I think it is 
> worth carrying, the amount of musl patches to libc-headers has 
> fluctuated over time, so this is no different. We can only deal with 
> the problems we are seeing in our builds (I state the obvious).
> 
> > 
> >  I'm now dropping the `#include <linux/prctl.h>` line in arch/arm64/include/uapi/asm/ptrace.h (https://github.com/torvalds/linux/blob/v5.1/arch/arm64/include/uapi/asm/ptrace.h#L68) in linux-libc-headers and that's giving working builds for me but I'm not sure how universally it can be applied. I'm happy to carry that as a bbappend in our distro layer for now but that will leave strace broke on aarch64 when using musl for others.
> > 
> 
> I'm still ok with patching it out of the headers, build tests would 
> shake any issues out, but I can't see there being too many. 
> 

I'll send a v2 including this then. The patch can go into SRC_URI_append_libc-musl so it has no chance of affecting glibc builds.

Thanks,

-- 
Paul Barker
Managing Director & Principal Engineer
Beta Five Ltd


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

* Re: [PATCH 2/2] strace: Fix aarch64 build with musl
  2019-05-09 13:43         ` Richard Purdie
  2019-05-09 13:48           ` Bruce Ashfield
@ 2019-05-09 14:31           ` Adrian Bunk
  1 sibling, 0 replies; 12+ messages in thread
From: Adrian Bunk @ 2019-05-09 14:31 UTC (permalink / raw)
  To: Richard Purdie; +Cc: OE Core

On Thu, May 09, 2019 at 02:43:54PM +0100, Richard Purdie wrote:
> On Thu, 2019-05-09 at 08:08 -0400, Paul Barker wrote:
>...
> > So alpine fixes this by patching the linux headers: 
> > https://git.alpinelinux.org/aports/tree/main/linux-headers/fix-aarch64-asm-ptrace.patch
> > 
> > I think that should be acceptable here if we just do it when building
> > with musl libc.
> > 
> > Any thoughts on that before I work up a v2 patch?
> 
> This really needs to get fixed upstream. I don't mind a patch but only
> if its gone upstream, we don't want to be carrying patches to libc-
> headers.

The root problem is that musl upstream has the opinion that the kernel 
headers are unfixably broken, and therefore the musl headers contain
own definitions of structs that are part of the kernel<->userspace ABI:
  https://wiki.musl-libc.org/faq.html#Q:-Why-am-I-getting-

The kernel headers were in a bad state 20 years ago, but are pretty 
usable today - which doesn't help since musl won't even try to be
cooperative and work towards using everything from the kernel headers
that belongs there.

And the lack of a __MUSL__ define makes it impossible to work around all
this musl-specific breakage in an upstreamable way in the kernel headers.
There are actually workarounds for musl in the upstream kernel headers,
but they can break depending on the #include order.

The FAQ above suggests using the patched headers from sabotage linux,
but they are from kernel 3.12.

> Cheers,
> 
> Richard

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



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

end of thread, other threads:[~2019-05-09 14:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-08 11:58 [PATCH 0/2] Fix strace & gdb build on aarch64/musl paul
2019-05-08 11:58 ` [PATCH 1/2] gdb: Fix aarch64 build with musl paul
2019-05-08 11:58 ` [PATCH 2/2] strace: " paul
2019-05-08 13:02   ` Adrian Bunk
2019-05-09 10:13     ` Paul Barker
2019-05-09 12:08       ` Paul Barker
2019-05-09 13:43         ` Richard Purdie
2019-05-09 13:48           ` Bruce Ashfield
2019-05-09 14:00             ` Paul Barker
2019-05-09 14:07               ` Bruce Ashfield
2019-05-09 14:10                 ` Paul Barker
2019-05-09 14:31           ` Adrian Bunk

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.