2014-04-30 17 views
7

tl; dr
Jak mogę skompilować kod źródłowy Ada do pliku biblioteki statycznej odpowiednim dla aplikacji na iPada z systemem iOS celów połączyć przeciwko? (GCC nie jest to wymóg. Rozwiązania użyciu LLVM lub inne są również mile widziane!)
Ada cross-kompilator dla iOS skierowany


Mam dużą bibliotekę przenośnego kodu Ada, które chciałbym użyć w projekcie iPad/iOS. Mój system operacyjny to Mac OS X 10.9 (z zainstalowanym GCC 4.8.1 pod adresem /opt/local z MacPort). Aby to zrobić, próbuję zbudować krzyżowy kompilator GCC ARM z obsługą Ada.

jestem w stanie zbudować GCC pracy i komara, który tworzy pliki wykonywalne ARM, ale nie wydaje się zbudować lub zainstalować Ada standardowej biblioteki, który jest wymagany do budowy mojego kodu Ada

Pakiety źródłowe I Korzystam:

gcc-4.8.1 
binutils-2.24 
libiconv-1.14 
gmp-5.1.3 
mpc-1.0.2 
mpfr-3.1.2 

konfiguracja build GCC:

$ bin/arm-none-eabi-gcc -v --version 
Using built-in specs. 
COLLECT_GCC=bin/arm-none-eabi-gcc 
COLLECT_LTO_WRAPPER=/Users/ardnew/cross/libexec/gcc/arm-none-eabi/4.8.1/lto-wrapper 
arm-none-eabi-gcc (GCC) 4.8.1 
Copyright (C) 2013 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 


Target: arm-none-eabi 
Configured with: /Users/ardnew/cross/src/gcc-4.8.1/configure --target=arm-none-eabi --prefix=/Users/ardnew/cross --with-cpu=cortex-a8 --enable-languages=c,ada --disable-multilib --enable-interwork --disable-threads --disable-shared --disable-nls --disable-lto --disable-libssp --disable-decimal-float --disable-libgomp --disable-libmudflap 
Thread model: single 
gcc version 4.8.1 (GCC) 
COLLECT_GCC_OPTIONS='-v' '--version' '-mcpu=cortex-a8' 
/Users/ardnew/cross/libexec/gcc/arm-none-eabi/4.8.1/cc1 -quiet -v -D__USES_INITFINI__ help-dummy -quiet -dumpbase help-dummy -mcpu=cortex-a8 -auxbase help-dummy -version --version -o /var/folders/4c/y_sll7bj6b9bt15389wr66_80000gn/T//ccrSSKFx.s 
GNU C (GCC) version 4.8.1 (arm-none-eabi) 
    compiled by GNU C version 4.8.1, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 
COLLECT_GCC_OPTIONS='-v' '--version' '-mcpu=cortex-a8' 
/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/as -mcpu=cortex-a8 -meabi=5 --version -o /var/folders/4c/y_sll7bj6b9bt15389wr66_80000gn/T//ccZYvQLp.o /var/folders/4c/y_sll7bj6b9bt15389wr66_80000gn/T//ccrSSKFx.s 
GNU assembler (GNU Binutils) 2.24 
Copyright 2013 Free Software Foundation, Inc. 
This program is free software; you may redistribute it under the terms of 
the GNU General Public License version 3 or later. 
This program has absolutely no warranty. 
This assembler was configured for a target of `arm-none-eabi'. 
COMPILER_PATH=/Users/ardnew/cross/libexec/gcc/arm-none-eabi/4.8.1/:/Users/ardnew/cross/libexec/gcc/arm-none-eabi/4.8.1/:/Users/ardnew/cross/libexec/gcc/arm-none-eabi/:/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/:/Users/ardnew/cross/lib/gcc/arm-none-eabi/:/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ 
LIBRARY_PATH=/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/:/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/lib/ 
COLLECT_GCC_OPTIONS='-v' '--version' '-mcpu=cortex-a8' 
/Users/ardnew/cross/libexec/gcc/arm-none-eabi/4.8.1/collect2 -X --version /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crti.o /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtbegin.o crt0.o -L/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1 -L/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/lib /var/folders/4c/y_sll7bj6b9bt15389wr66_80000gn/T//ccZYvQLp.o --start-group -lgcc -lc --end-group /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtend.o /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtn.o 
collect2 version 4.8.1 
/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld -X --version /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crti.o /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtbegin.o crt0.o -L/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1 -L/Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/lib /var/folders/4c/y_sll7bj6b9bt15389wr66_80000gn/T//ccZYvQLp.o --start-group -lgcc -lc --end-group /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtend.o /Users/ardnew/cross/lib/gcc/arm-none-eabi/4.8.1/crtn.o 
GNU ld (GNU Binutils) 2.24 
Copyright 2013 Free Software Foundation, Inc. 
This program is free software; you may redistribute it under the terms of 
the GNU General Public License version 3 or (at your option) a later version. 
This program has absolutely no warranty. 

Program testowy aby zapewnić jego budowy ARM binarne:

$ cat told_unit1.adb told_unit1.ads 

-- 
-- FILE: told_unit1.adb 
-- 
with Ada.Text_IO; 
use Ada.Text_IO; 

package body told_unit1 is 

    procedure hello is 
    begin 
    put_line("hello, world"); 
    end hello; 

    function double(x : in float) return float is 
    begin 
    return x + x; 
    end double; 

end told_unit1; 


-- 
-- FILE: told_unit1.ads 
-- 
package told_unit1 is 

    procedure hello; 
    pragma Export 
    (
    convention  => C, 
    entity   => hello, 
    external_name => "ada_hello" 
); 

    function double(x : in float) return float; 
    pragma Export 
    (
    convention  => C, 
    entity   => double, 
    external_name => "ada_double" 
); 

end told_unit1; 

Następnie kompilacji kodu Ada i kontrolowanie go file:

$ arm-none-eabi-gcc -c told_unit1.adb 

$ file told_unit1.o 
told_unit1.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped 

A potem, gdy próbuję powiązać obiektu plik biblioteki to pukes:

$ arm-none-eabi-gnatbind -aO$ADA_OBJECT_PATH -Ltold told_unit1 
error: "a-textio.ali" not found, "a-textio.adb" must be compiled 

Wracając do mojego GCC buduj logi, stwierdziłem, że libada (która jak sądzę jest częścią GNAT) nigdy nie została zbudowana. Kiedy próbuję uruchomić make all-target-libada z katalogu kompilacji GCC, w końcu mówi mi:

Configuring in arm-none-eabi/libada 
configure: loading cache ./config.cache 
checking build system type... x86_64-apple-darwin13.1.0 
checking host system type... arm-none-eabi 
checking target system type... arm-none-eabi 
checking for arm-none-eabi-gcc... /Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/xgcc -B/Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/ -B/Users/ardnew/cross/arm-none-eabi/bin/ -B/Users/ardnew/cross/arm-none-eabi/lib/ -isystem /Users/ardnew/cross/arm-none-eabi/include -isystem /Users/ardnew/cross/arm-none-eabi/sys-include 
checking for C compiler default output file name... 
configure: error: in `/Users/ardnew/cross/src/gcc-4.8.1-obj/arm-none-eabi/libada': 
configure: error: C compiler cannot create executables 
See `config.log' for more details. 
make: *** [configure-target-libada] Error 1 

I tak pójdę sprawdzić, że odnosząc się do jego config.log i znaleźć następujące:

configure:2351: $? = 0 
configure:2340: /Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/xgcc -B/Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/ -B/Users/ardnew/cross/arm-none-eabi/bin/ -B/Users/ardnew/cross/arm-none-eabi/lib/ -isystem /Users/ardnew/cross/arm-none-eabi/include -isystem /Users/ardnew/cross/arm-none-eabi/sys-include -v >&5 
COLLECT_LTO_WRAPPER=/Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/lto-wrapper 
Target: arm-none-eabi 
Configured with: /Users/ardnew/cross/src/gcc-4.8.1/configure --target=arm-none-eabi --prefix=/Users/ardnew/cross --with-cpu=cortex-a8 --enable-languages=c,ada --disable-multilib --enable-interwork --disable-threads --disable-shared --disable-nls --disable-lto --disable-libssp --disable-decimal-float --disable-libgomp --disable-libmudflap 
configure:2351: $? = 0 
xgcc: error: unrecognized command line option '-qversion' 
xgcc: fatal error: no input files 
compilation terminated. 
configure:2351: $? = 1 
configure:2371: checking for C compiler default output file name 
configure:2393: /Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/xgcc -B/Users/ardnew/cross/src/gcc-4.8.1-obj/./gcc/ -B/Users/ardnew/cross/arm-none-eabi/bin/ -B/Users/ardnew/cross/arm-none-eabi/lib/ -isystem /Users/ardnew/cross/arm-none-eabi/include -isystem /Users/ardnew/cross/arm-none-eabi/sys-include -g -O2 conftest.c >&5 
/Users/ardnew/cross/arm-none-eabi/bin/ld: cannot find crt0.o: No such file or directory 
/Users/ardnew/cross/arm-none-eabi/bin/ld: cannot find -lg 
/Users/ardnew/cross/arm-none-eabi/bin/ld: cannot find -lc 
collect2: error: ld returned 1 exit status 
configure:2397: $? = 1 
configure:2434: result: 
configure: failed program was: 
| /* confdefs.h */ 
| #define PACKAGE_NAME "" 
| #define PACKAGE_TARNAME "" 
| #define PACKAGE_VERSION "" 
| #define PACKAGE_STRING "" 
| #define PACKAGE_BUGREPORT "" 
| #define PACKAGE_URL "" 
| /* end confdefs.h. */ 
| 
| int 
| main() 
| { 
| 
| ; 
| return 0; 
| } 
configure:2440: error: in `/Users/ardnew/cross/src/gcc-4.8.1-obj/arm-none-eabi/libada': 
configure:2444: error: C compiler cannot create executables 
See `config.log' for more details. 

Więc na ten punkt jestem ponad moją głową i nie jestem pewien, co robić dalej. Wygląda na to, że brakuje mi biblioteki uruchomieniowej C dla ARM?

Każda pomoc w konfiguracji GNAT/libada dla celów ARM byłaby świetna.

Alternatywnie, czy istnieje prostszy sposób połączenia z bibliotekami Ada z projektu Xcode iOS?

+0

Powinieneś sprawdzić, czy kompilator 'arm-none-eabi' generuje pliki binarne ELF lub Macho - ten drugi jest wymagany dla obu MacOSX, ale podejrzewam, że konfiguracja wygeneruje ELF, którego nie możesz użyć. Nie jest to duży problem, ale może być konieczne zbudowanie kompilatora GCC i bin-utils z obsługą Mach-o. – marko

+0

@marko 'arm-none-eabi-gcc' produkuje pojemniki ELF (przepraszam za ściankę tekstu, ale sprawdzam blok kodu wkleiłem 4 od góry), i mówisz, że docelowy iOS jest prawdziwy, fizyczny iPad spodziewa się formatu Mach-O, a nie ELF? jeśli zmienię format, wierzę, że mój obecny problem nadal będzie istnieć. – ardnew

+2

Tak. Pliki obiektów ELF nie są użyteczne dla systemu MacOSX lub iOS, ponieważ używają plików obiektów Macho i tylko bibliotek współużytkowanych. ABM ABI jest subtelny również. Spodziewam się, że gcc skierowany na ARM na iOS będzie miał przedrostek 'arm-apple-darwin-' lub coś podobnego. Twoje błędy mogą być związane z niezgodnością formatu pliku wykonywalnego. – marko

Odpowiedz

1

Niestety, odpowiedź brzmi, że nie ma narzędzia do auto-magii, aby to osiągnąć. Możesz użyć narzędzi do sprawdzania poprawności tłumaczeń po fakcie, ale to, czego chcesz, nie jest jeszcze dostępne.

Musiałem poradzić sobie z tym samym pytaniem w przeszłości. Inna odpowiedź radykalnie zmieniłaby jeden z moich budżetów projektu. Być może kiedyś.

Chociaż przyznaję, wydaje mi się, że są w końcu wystarczające niekompatybilności, których źródło musiałoby zostać drastycznie zmienione - zmniejszając wartość tego, co chcesz osiągnąć tutaj. Ostatecznie, nowa inwestycja jest lekka, ale da lepsze źródło, jeśli możesz sobie na to pozwolić.