Message ID | 20230321190032.908584-1-jdmason@kudzu.us |
---|---|
State | New |
Headers | show |
Series | libunwind: work around arm printf issue | expand |
On Tue, 21 Mar 2023 at 20:00, Jon Mason <jdmason@kudzu.us> wrote:
> +Upstream-Status: Pending
Please submit upstream first.
Alex
On Tue, Mar 21, 2023 at 12:00 PM Jon Mason <jdmason@kudzu.us> wrote: > > When building for Arm, the following error is seen: > | ../../libunwind-1.6.2/src/arm/Gtrace.c:529:7: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > | printf("XXX1\n"); > > Since every other reference to printf either has BSD or !linux then, I > think it's safe to assume this is not valid and a BSD ifdef can be > placed around this code. > I think you can add #include <stdio.h> that should make the compiler happy, and you can easily upstream that change too. > Signed-off-by: Jon Mason <jdmason@kudzu.us> > --- > .../0007-Remove-undefined-printf.patch | 32 +++++++++++++++++++ > .../libunwind/libunwind_1.6.2.bb | 1 + > 2 files changed, 33 insertions(+) > create mode 100644 meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch > > diff --git a/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch b/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch > new file mode 100644 > index 000000000000..1826d8d72405 > --- /dev/null > +++ b/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch > @@ -0,0 +1,32 @@ > +From ed4777e3200aadacfaf2b48e1cd6dec9da37c737 Mon Sep 17 00:00:00 2001 > +From: Jon Mason <jon.mason@arm.com> > +Date: Tue, 21 Mar 2023 15:14:10 +0000 > +Subject: [PATCH] Remove undefined printf > + > +Seeing the following error when building with clang for Linux on Arm > +| ../../libunwind-1.6.2/src/arm/Gtrace.c:529:7: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > +| printf("XXX1\n"); > + > +Based on other printf's in libunwind, this appears to not be used on > +Linux (and appears to only be used for BSD). So, add an ifdef around > +this chunk to only be defined for BSD > + > +Upstream-Status: Pending > +--- > + src/arm/Gtrace.c | 2 ++ > + 1 file changed, 2 insertions(+) > + > +diff --git a/src/arm/Gtrace.c b/src/arm/Gtrace.c > +index 51fc281..fb73d87 100644 > +--- a/src/arm/Gtrace.c > ++++ b/src/arm/Gtrace.c > +@@ -526,7 +526,9 @@ tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) > + break; > + > + case UNW_ARM_FRAME_SYSCALL: > ++#if defined(__FreeBSD__) > + printf("XXX1\n"); > ++#endif > + break; > + > + default: > diff --git a/meta/recipes-support/libunwind/libunwind_1.6.2.bb b/meta/recipes-support/libunwind/libunwind_1.6.2.bb > index 716be9a452f4..74d7874f50bb 100644 > --- a/meta/recipes-support/libunwind/libunwind_1.6.2.bb > +++ b/meta/recipes-support/libunwind/libunwind_1.6.2.bb > @@ -5,6 +5,7 @@ SRC_URI = "http://download.savannah.nongnu.org/releases/libunwind/libunwind-${PV > file://0004-Fix-build-on-mips-musl.patch \ > file://0005-ppc32-Consider-ucontext-mismatches-between-glibc-and.patch \ > file://0006-Fix-for-X32.patch \ > + file://0007-Remove-undefined-printf.patch \ > " > SRC_URI:append:libc-musl = " file://musl-header-conflict.patch" > > -- > 2.30.2 >
diff --git a/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch b/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch new file mode 100644 index 000000000000..1826d8d72405 --- /dev/null +++ b/meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch @@ -0,0 +1,32 @@ +From ed4777e3200aadacfaf2b48e1cd6dec9da37c737 Mon Sep 17 00:00:00 2001 +From: Jon Mason <jon.mason@arm.com> +Date: Tue, 21 Mar 2023 15:14:10 +0000 +Subject: [PATCH] Remove undefined printf + +Seeing the following error when building with clang for Linux on Arm +| ../../libunwind-1.6.2/src/arm/Gtrace.c:529:7: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] +| printf("XXX1\n"); + +Based on other printf's in libunwind, this appears to not be used on +Linux (and appears to only be used for BSD). So, add an ifdef around +this chunk to only be defined for BSD + +Upstream-Status: Pending +--- + src/arm/Gtrace.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/arm/Gtrace.c b/src/arm/Gtrace.c +index 51fc281..fb73d87 100644 +--- a/src/arm/Gtrace.c ++++ b/src/arm/Gtrace.c +@@ -526,7 +526,9 @@ tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) + break; + + case UNW_ARM_FRAME_SYSCALL: ++#if defined(__FreeBSD__) + printf("XXX1\n"); ++#endif + break; + + default: diff --git a/meta/recipes-support/libunwind/libunwind_1.6.2.bb b/meta/recipes-support/libunwind/libunwind_1.6.2.bb index 716be9a452f4..74d7874f50bb 100644 --- a/meta/recipes-support/libunwind/libunwind_1.6.2.bb +++ b/meta/recipes-support/libunwind/libunwind_1.6.2.bb @@ -5,6 +5,7 @@ SRC_URI = "http://download.savannah.nongnu.org/releases/libunwind/libunwind-${PV file://0004-Fix-build-on-mips-musl.patch \ file://0005-ppc32-Consider-ucontext-mismatches-between-glibc-and.patch \ file://0006-Fix-for-X32.patch \ + file://0007-Remove-undefined-printf.patch \ " SRC_URI:append:libc-musl = " file://musl-header-conflict.patch"
When building for Arm, the following error is seen: | ../../libunwind-1.6.2/src/arm/Gtrace.c:529:7: error: call to undeclared library function 'printf' with type 'int (const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] | printf("XXX1\n"); Since every other reference to printf either has BSD or !linux then, I think it's safe to assume this is not valid and a BSD ifdef can be placed around this code. Signed-off-by: Jon Mason <jdmason@kudzu.us> --- .../0007-Remove-undefined-printf.patch | 32 +++++++++++++++++++ .../libunwind/libunwind_1.6.2.bb | 1 + 2 files changed, 33 insertions(+) create mode 100644 meta/recipes-support/libunwind/libunwind/0007-Remove-undefined-printf.patch