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&arch=hppa&ver=1.6.1-4&stamp=1666457482&raw=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 <fdt.h>
 #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:    \
+       .stringz        str             ! \
+55:    \
+       .balign 4               !
+
+#define BEGIN_NODE(name) \
+       FDTLONG(FDT_BEGIN_NODE) ! \
+       .stringz        name            ! \
+       .balign 4               !
+
+#define END_NODE \
+       FDTLONG(FDT_END_NODE)   !
+
+#define STRING(tree, name, str) \
+tree##_##name:                 ! \
+       .stringz        str             !
+
+#else
+
 #define FDTLONG(val) \
        .byte   ((val) >> 24) & 0xff ; \
        .byte   ((val) >> 16) & 0xff ; \
@@ -69,6 +141,7 @@ tree##_rsvmap_end:           ;
 #define STRING(tree, name, str) \
 tree##_##name:                 ; \
        .string str             ;
+#endif
 
        .data
 
@@ -253,9 +326,13 @@ truncated_string_struct_end:
 truncated_string_strings:
        STRING(truncated_string, good_string, "good")
 truncated_string_bad_string:
+#ifdef __hppa__
+       .ascii  "bad"
+#else
        .byte   'b'
        .byte   'a'
        .byte   'd'
+#endif
        /* NOTE: terminating \0 deliberately missing */
 truncated_string_strings_end:
 truncated_string_end:

Reply via email to