1

I compiled a GCC 4.8.1 Cross-Compiler (BUILD/HOST: debian/glibc, TARGET: alpinelinux/uclibc). The C compiler is working great, but Ada won't work at moment.

juan@debian:~/HelloAda$ x86_64-alpine-linux-uclibc-gnatmake hello.adb 
x86_64-alpine-linux-uclibc-gcc -c hello.adb
x86_64-alpine-linux-uclibc-gnatbind -x hello.ali
x86_64-alpine-linux-uclibc-gnatlink hello.ali
/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a(adaint.o): In function `__gnat_cpu_alloc':
/home/juan/GCC/obj/gcc/ada/rts/adaint.c:3797: undefined reference to `__sched_cpualloc'
/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a(adaint.o): In function `__gnat_cpu_free':
/home/juan/GCC/obj/gcc/ada/rts/adaint.c:3807: undefined reference to `__sched_cpufree'
collect2: error: ld returned 1 exit status
x86_64-alpine-linux-uclibc-gnatlink: error when calling /home/juan/opt/cross/bin/x86_64-alpine-linux-uclibc-gcc
x86_64-alpine-linux-uclibc-gnatmake: *** link failed.

/home/juan/GCC/obj/gcc/ada/rts/adaint.c: http://nopaste.info/ffcb612692.html

/usr/include/sched.h: http://nopaste.info/5332aed42a.html
/usr/include/bits/sched.h: http://nopaste.info/46323ab5d8.html

/opt/alpine/usr/include/sched.h: http://nopaste.info/998896bafe.html
/opt/alpine/usr/include/bits/sched.h: http://nopaste.info/e8cfbd2844.html

Does someone know, what's going wrong?

A more verbose output of what is going on:

juan@debian:~/HelloAda$ x86_64-alpine-linux-uclibc-gcc -c hello.adb 
juan@debian:~/HelloAda$ x86_64-alpine-linux-uclibc-gnatbind hello
juan@debian:~/HelloAda$ x86_64-alpine-linux-uclibc-gnatlink -v -v hello

GNATLINK 4.8.1
Copyright (C) 1995-2013, Free Software Foundation, Inc.
x86_64-alpine-linux-uclibc-gcc -c -mtune=generic -march=x86-64 -gnatA -gnatWb -gnatiw -v -gnatws /home/juan/HelloAda/b~hello.adb
Using built-in specs.
COLLECT_GCC=/home/juan/opt/cross/bin/x86_64-alpine-linux-uclibc-gcc
Target: x86_64-alpine-linux-uclibc
Configured with: ../src/configure --prefix=/home/juan/opt/cross --build=x86_64-cross-linux-gnu --host=x86_64-cross-linux-gnu --target=x86_64-alpine-linux-uclibc --disable-altivec --disable-build-with-cxx --disable-checking --disable-fixed-point --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --enable-languages=c,ada --enable-shared --with-dynamic-linker=ld64-uClibc.so.0.9.32 --with-dynamic-linker-prefix=/opt/alpine/lib --with-system-zlib --without-system-libunwindmake --with-sysroot=/opt/alpine
Thread model: posix
gcc version 4.8.1 (GCC) 
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64' '-gnatA' '-gnatWb' '-gnatiw' '-v' '-gnatws'
 /home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/gnat1 -quiet -dumpbase b~hello.adb -auxbase b~hello -mtune=generic -march=x86-64 -gnatA -gnatWb -gnatiw -gnatws /home/juan/HelloAda/b~hello.adb -o /tmp/ccG4vv8d.s
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64' '-gnatA' '-gnatWb' '-gnatiw' '-v' '-gnatws'
 /home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/bin/as -v --64 -o b~hello.o /tmp/ccG4vv8d.s
GNU assembler version 2.23.2 (x86_64-alpine-linux-uclibc) using BFD version (GNU Binutils) 2.23.2
COMPILER_PATH=/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/bin/
LIBRARY_PATH=/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib/../lib/:/opt/alpine/lib/../lib/:/opt/alpine/usr/lib/../lib/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib/:/opt/alpine/lib/:/opt/alpine/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64' '-gnatA' '-gnatWb' '-gnatiw' '-v' '-gnatws'
/home/juan/opt/cross/bin/x86_64-alpine-linux-uclibc-gcc b~hello.o ./hello.o -v -o hello -L./ -L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/ /home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a -static-libgcc
Using built-in specs.
COLLECT_GCC=/home/juan/opt/cross/bin/x86_64-alpine-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/lto-wrapper
Target: x86_64-alpine-linux-uclibc
Configured with: ../src/configure --prefix=/home/juan/opt/cross --build=x86_64-cross-linux-gnu --host=x86_64-cross-linux-gnu --target=x86_64-alpine-linux-uclibc --disable-altivec --disable-build-with-cxx --disable-checking --disable-fixed-point --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --enable-languages=c,ada --enable-shared --with-dynamic-linker=ld64-uClibc.so.0.9.32 --with-dynamic-linker-prefix=/opt/alpine/lib --with-system-zlib --without-system-libunwindmake --with-sysroot=/opt/alpine
Thread model: posix
gcc version 4.8.1 (GCC) 
COMPILER_PATH=/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/bin/
LIBRARY_PATH=/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib/../lib/:/opt/alpine/lib/../lib/:/opt/alpine/usr/lib/../lib/:/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib/:/opt/alpine/lib/:/opt/alpine/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-L./' '-L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/' '-static-libgcc' '-mtune=generic' '-march=x86-64'
 /home/juan/opt/cross/libexec/gcc/x86_64-alpine-linux-uclibc/4.8.1/collect2 --sysroot=/opt/alpine --eh-frame-hdr -m elf_x86_64 -dynamic-linker /opt/alpine/lib/ld64-uClibc.so.0.9.32 -o hello /opt/alpine/usr/lib/../lib/crt1.o /opt/alpine/usr/lib/../lib/crti.o /home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/crtbegin.o -L./ -L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/ -L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1 -L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib/../lib -L/opt/alpine/lib/../lib -L/opt/alpine/usr/lib/../lib -L/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/../../../../x86_64-alpine-linux-uclibc/lib -L/opt/alpine/lib -L/opt/alpine/usr/lib b~hello.o ./hello.o /home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/crtend.o /opt/alpine/usr/lib/../lib/crtn.o
/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a(adaint.o): In function `__gnat_cpu_alloc':
/home/juan/GCC/obj/gcc/ada/rts/adaint.c:3797: undefined reference to `__sched_cpualloc'
/home/juan/opt/cross/lib/gcc/x86_64-alpine-linux-uclibc/4.8.1/adalib/libgnat.a(adaint.o): In function `__gnat_cpu_free':
/home/juan/GCC/obj/gcc/ada/rts/adaint.c:3807: undefined reference to `__sched_cpufree'
collect2: error: ld returned 1 exit status
x86_64-alpine-linux-uclibc-gnatlink: error when calling /home/juan/opt/cross/bin/x86_64-alpine-linux-uclibc-gcc
user1091344
  • 612
  • 6
  • 27
  • 1
    This is a bit of a guess : Where does the adainit for your alpine adainit.c live ? it looks like it is finding the gcc one (which doesnt have __sched_cpu* methods), whereas the alpine one would/should. You may have to tell alpine-gnatmake explicitly to look in these (alpine) dirs before the GCC ones. (or my guess is wrong :( ) – NWS Aug 21 '13 at 08:16
  • Thanks for your input. In adaint.c, there is an #include on line 3785. So, it is including the wrong sched.h? – user1091344 Aug 21 '13 at 08:59
  • That would be my conclusion (and im at work so cannot examine all your links at leisure), Look at the help for gnatmake (just type gnatmake without any args) and see how to explicitly include directories before the default ones. – NWS Aug 21 '13 at 10:04
  • Hi, I tried some arguments. But I got always the same error as in my entry post. If you are at home, could you look for it? – user1091344 Aug 21 '13 at 13:43
  • Sorry but im not going to install AlpineLinux. My help only goes so far. Sorry. – NWS Aug 27 '13 at 07:14
  • Although i do see your COLLECT_GCC_OPTIONS still has /home/juan/GCC/obj/gcc/ada/rts/adaint.c in it. – NWS Aug 27 '13 at 07:15

1 Answers1

1

It's quite clear that __sched_cpualloc/free* functions are either specific to Glibc 2.7 or not implemented in uclibc.

$ objdump -T libc.so.6 | grep __sched
000c4c30 g    DF .text  00000043  GLIBC_2.0   __sched_getparam
000c4d10 g    DF .text  00000037  GLIBC_2.0   __sched_yield
000c5540 g    DF .text  00000029  GLIBC_2.7   __sched_cpualloc
000c4d50 g    DF .text  0000003f  GLIBC_2.0   __sched_get_priority_max
000c5570 g    DF .text  00000020  GLIBC_2.7   __sched_cpufree
000c4d90 g    DF .text  0000003f  GLIBC_2.0   __sched_get_priority_min
000c5500 g   iD  .text  0000003f  GLIBC_2.6   __sched_cpucount
000c4c80 g    DF .text  00000045  GLIBC_2.0   __sched_setscheduler
000c4cd0 g    DF .text  0000003f  GLIBC_2.0   __sched_getscheduler

I guess these required for the CPU concurrency tasks.

If you have access to uclibc source, perhaps it will be possible to define these functions and recompile the library by referencing Glibc here.. Or better yet, just make a small library with these two functions and link that when creating the binary ELF image.

__sched_cpualloc and __sched_cpufree aren't rocket science, as it turns out. Here is the code as it appears in Glibc:

9 #include <sched.h>
20 #include <stdlib.h>
21 
22 
23 cpu_set_t *
24 __sched_cpualloc (size_t count)
25 {
26   return malloc (CPU_ALLOC_SIZE (count));
27 }

and

23 void
24 __sched_cpufree (cpu_set_t *set)
25 {
26   free (set);
27 }

finally, CPU_ALLOC_SIZE is also simple:

165 # define __CPU_ALLOC_SIZE(count) \
166   ((((count) + __NCPUBITS - 1) / __NCPUBITS) * 8)

So I guess you can write your own wrappers for uclibc now and test to see if it works.

Arjun
  • 368
  • 1
  • 3
  • 10
  • Ugh, my english is horrid. – Arjun Aug 22 '13 at 08:09
  • You'll just need to pretty much copy/paste what I wrote and compile it into a small static library which you can link with your main binary ELF image at the final stage. I don't see why it wouldn't work, but do keep me updated for any errors. – Arjun Aug 22 '13 at 12:06
  • 1
    Hmm... You removed your profile name. I guess you gave up on this problem? – Arjun Aug 23 '13 at 05:10
  • No, I did not ;) May I ask, are you an Ada expert? – user1091344 Aug 23 '13 at 23:15
  • I don't know why, but now, it works. :-) I looked into the uclibc source. There is already __sched_cpualloc and __sched_cpufree implemented. (file: uClibc-0.9.33/libc/sysdeps/linux/common/bits/sched.h) – user1091344 Aug 23 '13 at 23:28
  • 1
    But thanks to your help, I finally got it working :-) I think, gnatmake took always the wrong sched.h. – user1091344 Aug 23 '13 at 23:29
  • Glad you got it working. No, I'm not an Ada expert... more like C expert haha. – Arjun Aug 23 '13 at 23:47