Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 352281

Summary: =sys-boot-yaboot-1.3.16 fails to build against e2fsprogs{-libs}-1.41.14 due to missing posix_memalign() function
Product: Gentoo Linux Reporter: Alex Buell <alex.buell>
Component: New packagesAssignee: PPC Porters <ppc>
Status: RESOLVED FIXED    
Severity: normal CC: hiyuh.root, ppc64, stylinae
Priority: High    
Version: 10.1   
Hardware: PPC   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: yaboot-1.3.16-r1.ebuild w/ patch
yaboot-e2fsprogs-1.41.14.patch

Description Alex Buell 2011-01-20 20:37:42 UTC
ld -Ttext 0x200000 -Bstatic -melf32ppclinux second/crt0.o second/yaboot.o second
/cache.o second/prom.o second/file.o second/partition.o second/fs.o second/cfg.o
 second/setjmp.o second/cmdline.o second/fs_of.o second/fs_ext2.o second/fs_iso.
o second/iso_util.o lib/nosys.o lib/string.o lib/strtol.o lib/vsprintf.o lib/cty
pe.o lib/malloc.o lib/strstr.o lib/ssp.o second/md5.o second/fs_xfs.o second/fs_
reiserfs.o -lext2fs `powerpc-unknown-linux-gnu-gcc -m32 -print-libgcc-file-name`
 -o second/yaboot
/usr/lib/libext2fs.a(inode.o): In function `ext2fs_open_inode_scan':
(.text+0x1268): undefined reference to `posix_memalign'
/usr/lib/libext2fs.a(openfs.o): In function `ext2fs_open2':
(.text+0x2e4): undefined reference to `posix_memalign'
/usr/lib/libext2fs.a(rw_bitmaps.o): In function `write_bitmaps':
(.text+0xa8): undefined reference to `posix_memalign'
/usr/lib/libext2fs.a(rw_bitmaps.o): In function `write_bitmaps':
(.text+0xf8): undefined reference to `posix_memalign'
/usr/lib/libext2fs.a(rw_bitmaps.o): In function `read_bitmaps':
(.text+0x4e8): undefined reference to `posix_memalign'
make: *** [yaboot] Error 1

It is, however, your lucky day as this also broke silo on SPARC and there is already a patch to provide the missing posix_memalign function().
Comment 1 Alex Buell 2011-01-20 20:39:48 UTC
This patch needs to be adapted for use with yaboot to provide the missing posix_memalign functionality:

diff -uNr silo-1.4.14/second/fs/ext2.c silo/second/fs/ext2.c
--- a/common/malloc.c
+++ b/common/malloc.c
@@ -27,6 +27,12 @@ static char *malloc_ptr = (char *) MALLOC_BASE;
 
 static char *last_alloc = 0;
 
+static char *align_ptr_to(char *ptr, unsigned long align)
+{
+    return (char *) ((((unsigned long) ptr) + (align - 1UL)) &
+                    ~(align - 1UL));
+}
+
 void *malloc (int size)
 {
     char *caddr;
@@ -34,10 +40,34 @@ void *malloc (int size)
     caddr = malloc_ptr;
     malloc_ptr += size;
     last_alloc = caddr;
-    malloc_ptr = (char *) ((((unsigned long) malloc_ptr) + 7) & (~7));
+    malloc_ptr = align_ptr_to(malloc_ptr, 8UL);
     return caddr;
 }
 
+int posix_memalign(void **memptr, unsigned long alignment, unsigned long size)
+{
+    char *caddr;
+
+    if (alignment & (alignment - 1UL))
+        return -1;
+    if (alignment & (sizeof(void *) - 1UL))
+        return -1;
+
+    if (size == 0) {
+      *memptr = (void *) 0;
+      return 0;
+    }
+
+    caddr = align_ptr_to(malloc_ptr, alignment);
+    malloc_ptr = (caddr + size);
+    last_alloc = caddr;
+    malloc_ptr = align_ptr_to(malloc_ptr, 8UL);
+
+    *memptr = caddr;
+
+    return 0;
+}
+
 void free (void *m)
 {
     if (m == last_alloc)
Comment 2 Alex Buell 2011-01-20 20:40:55 UTC
I will spin a patch for this within the next few days; I have a big emerge world to finish first on my PPC. 
Comment 3 Alex Buell 2011-01-23 18:39:47 UTC
Patch and ebuild attached. Please test and mark as stable if OK. 
Comment 4 Alex Buell 2011-01-23 18:41:17 UTC
Created attachment 260552 [details]
yaboot-1.3.16-r1.ebuild w/ patch
Comment 5 Alex Buell 2011-01-23 18:41:54 UTC
Created attachment 260553 [details, diff]
yaboot-e2fsprogs-1.41.14.patch
Comment 6 Wormo (RETIRED) gentoo-dev 2011-01-24 06:06:06 UTC
Thanks for submitting your patch! Assigning to yaboot maintainers
Comment 7 hiyuh 2011-03-02 04:21:08 UTC
FYI, i tested attached ones on my ~ppc Mac mini and would have to say ITJUSTWORKS(tm).
Comment 8 Alex Buell 2011-03-02 10:15:30 UTC
(In reply to comment #7)
> FYI, i tested attached ones on my ~ppc Mac mini and would have to say
> ITJUSTWORKS(tm).

Brilliant, that means I did a good job:)
Comment 9 Adam Stylinski 2011-03-16 00:48:35 UTC
Why haven't we committed this patch yet?  Yaboot will not compile without it.
Comment 10 Stefan de Konink 2011-04-30 11:05:33 UTC
ping
Comment 11 Joe Jezak (RETIRED) gentoo-dev 2011-05-22 07:49:10 UTC
In CVS, thanks!