Bug#1022246: device-tree-compiler: FTBFS on hppa - assembler issues

2023-04-28 Thread Uwe Kleine-König
Control: tag -1 + fixed-upstream

Hello,

On Sat, Oct 22, 2022 at 05:08:03PM +, John David Anglin wrote:
> Source: device-tree-compiler
> Version: 1.6.1-4
> Severity: normal
> Tags: ftbfs patch
> 
> Dear Maintainer,
> 
> Build fails here:
>  AS tests/trees.o
> tests/trees.S: Assembler messages:
> tests/trees.S:256: Error: junk at end of line, first unrecognized character 
> is `''
> tests/trees.S:257: Error: junk at end of line, first unrecognized character 
> is `''
> tests/trees.S:258: Error: junk at end of line, first unrecognized character 
> is `''
> tests/trees.S:219: Error: invalid operands (*UND* and .data sections) for `-'
> 

I tried to compile upstream's main branch on hppa and couldn't reproduce
it. I guess it was fixed by


https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=d24cc189dca6148eedf9dc9e2d45144b3851dae0

which is included in v1.7.0.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | https://www.pengutronix.de/ |


signature.asc
Description: PGP signature


Bug#1022246: device-tree-compiler: FTBFS on hppa - assembler issues

2022-10-22 Thread John David Anglin
Source: device-tree-compiler
Version: 1.6.1-4
Severity: normal
Tags: ftbfs patch

Dear Maintainer,

Build fails here:
 AS tests/trees.o
tests/trees.S: Assembler messages:
tests/trees.S:256: Error: junk at end of line, first unrecognized character is 
`''
tests/trees.S:257: Error: junk at end of line, first unrecognized character is 
`''
tests/trees.S:258: Error: junk at end of line, first unrecognized character is 
`''
tests/trees.S:219: Error: invalid operands (*UND* and .data sections) for `-'

The GNU assembler on hppa differs in a number of ways with the assembler
on other architectures:

1) The end-of-line character is `!'. `;' introduces a comment.
2) The `.string' directive doesn't add a null termination character.
3) It is strict about the format for characters and junk at end of line.

With the attached patch, the device-tree-compiler package builds successfully
on hppa:
https://buildd.debian.org/status/fetch.php?pkg=device-tree-compiler=hppa=1.6.1-4=1666457482=0

Please push upstream and add to debian/patches if okay.

Thanks,
Dave Anglin

-- System Information:
Debian Release: bookworm/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable')
Architecture: hppa (parisc64)

Kernel: Linux 5.19.16+ (SMP w/4 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Index: device-tree-compiler-1.6.1/flattree.c
===
--- device-tree-compiler-1.6.1.orig/flattree.c
+++ device-tree-compiler-1.6.1/flattree.c
@@ -124,7 +124,7 @@ static void asm_emit_cell(void *e, cell_
 {
FILE *f = e;
 
-   fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
+   fprintf(f, "\t.byte 0x%02x\n\t.byte 0x%02x\n\t.byte 0x%02x\n\t.byte 
0x%02x\n",
(val >> 24) & 0xff, (val >> 16) & 0xff,
(val >> 8) & 0xff, val & 0xff);
 }
@@ -133,10 +133,17 @@ static void asm_emit_string(void *e, con
 {
FILE *f = e;
 
+#if defined(__hppa__)
+   if (len != 0)
+   fprintf(f, "\t.stringz\t\"%.*s\"\n", len, str);
+   else
+   fprintf(f, "\t.stringz\t\"%s\"\n", str);
+#else
if (len != 0)
fprintf(f, "\t.string\t\"%.*s\"\n", len, str);
else
fprintf(f, "\t.string\t\"%s\"\n", str);
+#endif
 }
 
 static void asm_emit_align(void *e, int a)
@@ -438,7 +445,11 @@ static void dump_stringtable_asm(FILE *f
 
while (p < (strbuf.val + strbuf.len)) {
len = strlen(p);
+#if defined(__hppa__)
+   fprintf(f, "\t.stringz \"%s\"\n", p);
+#else
fprintf(f, "\t.string \"%s\"\n", p);
+#endif
p += len+1;
}
 }
Index: device-tree-compiler-1.6.1/tests/trees.S
===
--- device-tree-compiler-1.6.1.orig/tests/trees.S
+++ device-tree-compiler-1.6.1/tests/trees.S
@@ -1,6 +1,78 @@
 #include 
 #include "testdata.h"
 
+#ifdef __hppa__
+#define FDTLONG(val) \
+   .byte   ((val) >> 24) & 0xff ! \
+   .byte   ((val) >> 16) & 0xff ! \
+   .byte   ((val) >> 8) & 0xff ! \
+   .byte   (val) & 0xff!
+
+#define TREE_HDR(tree) \
+   .balign 8   ! \
+   .globl  tree! \
+tree:  \
+   FDTLONG(FDT_MAGIC)  ! \
+   FDTLONG(tree##_end - tree) ! \
+   FDTLONG(tree##_struct - tree) ! \
+   FDTLONG(tree##_strings - tree) ! \
+   FDTLONG(tree##_rsvmap - tree) ! \
+   FDTLONG(0x11)   ! \
+   FDTLONG(0x10)   ! \
+   FDTLONG(0)  ! \
+   FDTLONG(tree##_strings_end - tree##_strings) ! \
+   FDTLONG(tree##_struct_end - tree##_struct) !
+
+#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \
+   FDTLONG(addrh)  ! \
+   FDTLONG(addrl)  ! \
+   FDTLONG(lenh)   ! \
+   FDTLONG(lenl)
+
+#define EMPTY_RSVMAP(tree) \
+   .balign 8   ! \
+tree##_rsvmap: ! \
+   RSVMAP_ENTRY(0, 0, 0, 0) \
+tree##_rsvmap_end: !
+
+#define PROPHDR(tree, name, len) \
+   FDTLONG(FDT_PROP)   ! \
+   FDTLONG(len)! \
+   FDTLONG(tree##_##name - tree##_strings) !
+
+#define PROP_EMPTY(tree, name) \
+   PROPHDR(tree, name, 0)  !
+
+#define PROP_INT(tree, name, val) \
+   PROPHDR(tree, name, 4) \
+   FDTLONG(val)!
+
+#define PROP_INT64(tree, name, valh, vall) \
+   PROPHDR(tree, name, 8) \
+   FDTLONG(valh)   ! \
+   FDTLONG(vall)   !
+
+#define PROP_STR(tree, name, str) \
+   PROPHDR(tree, name, 55f - 54f) \
+54:\
+   .stringzstr ! \
+55:\
+   .balign 4   !
+
+#define BEGIN_NODE(name) \
+   FDTLONG(FDT_BEGIN_NODE) ! \
+   .stringzname! \
+   .balign 4   !
+
+#define END_NODE \
+