1

我编译了一个 GCC 4.8.1 交叉编译器(BUILD/HOST:debian/glibc,TARGET:alpinelinux/uclibc)。C 编译器运行良好,但 Ada 暂时无法运行。

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 _
_ _ _

有人知道,怎么了?

正在发生的事情的更详细的输出:

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
4

1 回答 1

1

很明显,__sched_cpualloc/free* 函数要么特定于 Glibc 2.7,要么未在 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

我猜这些是 CPU 并发任务所必需的。

如果您可以访问 uclibc 源代码,也许可以通过在此处引用 Glibc 来定义这些函数并重新编译库。. 或者更好的是,只需使用这两个函数创建一个小型库,并在创建二进制 ELF 映像时链接它。

__sched_cpualloc 和 __sched_cpufree 不是火箭科学,事实证明。这是出现在 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 }

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

最后,CPU_ALLOC_SIZE 也很简单:

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

所以我想你现在可以为 uclibc 编写自己的包装器并测试它是否有效。

于 2013-08-22T08:02:41.140 回答