Spike toolchain Ada per aarch64: motore compilato ed eseguito, esito nel piano
- spike/run.sh riproduce la prova: hello Ada, i 19 file del motore compilati per ARM, motore che legge una Maildir vera, tasking con protected object - esito: binari compatibili con la glibc di Sailfish 5.1 (max 2.34) - resta: link con libetpan/gpgme/jansson, sysroot del telefono
This commit is contained in:
1 parent
3cbe882c65
commit
781f015597
6 files changed
+200
-1
No files matched your search
@@ -0,0 +1,6 @@
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Command_Line;
|
||||
procedure Hello is
|
||||
begin
|
||||
Put_Line ("Ada gira su questa macchina: " & Ada.Command_Line.Command_Name);
|
||||
end Hello;
|
||||
@@ -0,0 +1,80 @@
|
||||
-- Prova del motore di GrumpyDove per aarch64: scansiona le cartelle,
|
||||
-- estrae gli header di un messaggio, cerca un testo. Nessun Qt, nessuna
|
||||
-- libreria esterna: solo Ada e il runtime GNAT.
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Exceptions;
|
||||
with Interfaces.C;
|
||||
use type Interfaces.C.int;
|
||||
with Mail_Folders;
|
||||
with Mail_Header;
|
||||
with Mail_Search;
|
||||
|
||||
procedure Prova is
|
||||
Buf : String (1 .. 512);
|
||||
Len : Interfaces.C.int;
|
||||
Depth : Interfaces.C.int;
|
||||
Tot : Natural := 0;
|
||||
|
||||
-- Legge un messaggio abbastanza corto in una stringa fissa.
|
||||
function Read_Message (Path : String) return String is
|
||||
F : File_Type;
|
||||
Line : String (1 .. 1024);
|
||||
Last : Natural;
|
||||
Whole : String (1 .. 16384);
|
||||
Pos : Natural := 0;
|
||||
begin
|
||||
Open (F, In_File, Path);
|
||||
while not End_Of_File (F) loop
|
||||
Get_Line (F, Line, Last);
|
||||
for I in 1 .. Last loop
|
||||
if Pos < Whole'Last then
|
||||
Pos := Pos + 1;
|
||||
Whole (Pos) := Line (I);
|
||||
end if;
|
||||
end loop;
|
||||
if Pos < Whole'Last then
|
||||
Pos := Pos + 1;
|
||||
Whole (Pos) := ASCII.LF;
|
||||
end if;
|
||||
end loop;
|
||||
Close (F);
|
||||
return Whole (1 .. Pos);
|
||||
end Read_Message;
|
||||
|
||||
begin
|
||||
Mail_Folders.Scan;
|
||||
Put_Line ("radice delle cartelle: " & Mail_Folders.Root);
|
||||
|
||||
for I in 0 .. 40 loop
|
||||
Len := Mail_Folders.Folder_At
|
||||
(Interfaces.C.int (I), Depth, Buf'Address, Interfaces.C.int (Buf'Length));
|
||||
exit when Len < 0;
|
||||
Tot := Tot + 1;
|
||||
Put_Line (" " & (1 .. Natural (Depth) => ' ')
|
||||
& Buf (1 .. Natural (Len)));
|
||||
end loop;
|
||||
Put_Line ("cartelle trovate:" & Natural'Image (Tot));
|
||||
|
||||
declare
|
||||
Raw : constant String := Read_Message (Mail_Folders.Root
|
||||
& "/Local/In/cur/msg1:2,S");
|
||||
From : constant String := Mail_Header.Field (Raw, "from");
|
||||
Subject : constant String := Mail_Header.Decode_Words
|
||||
(Mail_Header.Field (Raw, "subject"));
|
||||
begin
|
||||
Put_Line ("messaggio letto: " & Natural'Image (Raw'Length) & " byte");
|
||||
Put_Line (" da: " & Mail_Header.Who (From));
|
||||
Put_Line (" indirizzo:" & Mail_Header.Address (From));
|
||||
Put_Line (" oggetto: " & Subject);
|
||||
end;
|
||||
|
||||
Put_Line ("ricerca 'preventivo':"
|
||||
& Boolean'Image (Mail_Search.Holds
|
||||
("Re: preventivo tettoia", "preventivo", Mail_Search.Contains)));
|
||||
Put_Line ("ricerca 'assente':"
|
||||
& Boolean'Image (Mail_Search.Holds
|
||||
("Re: preventivo tettoia", "assente", Mail_Search.Contains)));
|
||||
exception
|
||||
when E : others =>
|
||||
Put_Line ("ECCEZIONE: " & Ada.Exceptions.Exception_Information (E));
|
||||
end Prova;
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# Ripete lo spike della toolchain Ada per aarch64 senza telefono.
|
||||
#
|
||||
# Uso: ./run.sh [/percorso/ai/sorgenti/di/grumpydove]
|
||||
# Serve: gnat-12-aarch64-linux-gnu, qemu-user-static.
|
||||
#
|
||||
# Compila: un hello, i 19 file Ada del motore (solo verifica), un programma
|
||||
# che legge una Maildir con il motore, e un test di tasking. Poi esegue i
|
||||
# binari in emulazione aarch64.
|
||||
set -e
|
||||
|
||||
SRC=${1:-/tmp/gd/grumpydove/src}
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
WORK=$HERE/work
|
||||
GCC=aarch64-linux-gnu-gnatmake
|
||||
QEMU="qemu-aarch64-static -L /usr/aarch64-linux-gnu"
|
||||
|
||||
[ -d "$SRC" ] || { echo "mancano i sorgenti di grumpydove in $SRC"; exit 1; }
|
||||
|
||||
rm -rf "$WORK"; mkdir -p "$WORK"
|
||||
cd "$WORK"
|
||||
|
||||
echo "== 1. hello Ada =="
|
||||
cp "$HERE/hello.adb" .
|
||||
$GCC hello.adb >/dev/null
|
||||
$QEMU ./hello
|
||||
|
||||
echo "== 2. tutti i file Ada del motore, per aarch64 (verifica semantica) =="
|
||||
mkdir -p engine && cp "$SRC"/*.adb "$SRC"/*.ads engine/
|
||||
(cd engine && $GCC -c -gnatc -gnat2022 -gnatwa -I. grumpydove.adb 2>&1 \
|
||||
| grep -vE "^aarch64-linux-gnu-gcc" || true)
|
||||
echo " (sopra compaiono solo i warning dell'originale)"
|
||||
|
||||
echo "== 3. il motore legge una Maildir vera =="
|
||||
mkdir -p home/Mail/Local/In/{cur,new,tmp} home/Mail/Local/Out/{cur,new,tmp} \
|
||||
home/Mail/Local/Junk/{cur,new,tmp} home/Mail/Local/Trash/{cur,new,tmp} \
|
||||
home/Mail/progetti/In/{cur,new,tmp} home/Mail/progetti/Out/{cur,new,tmp}
|
||||
printf 'From: Luca Bianchi <luca@example.net>\nTo: carlo@example.org\nSubject: Re: preventivo tettoia\nDate: Mon, 10 Nov 2026 14:22:00 +0100\n\nVa bene, la misura da tre metri mi torna.\n' \
|
||||
> home/Mail/Local/In/cur/msg1:2,S
|
||||
cp "$HERE/prova.adb" engine/
|
||||
(cd engine && $GCC -gnat2022 -O1 -I. prova.adb >/dev/null)
|
||||
HOME=$WORK/home $QEMU ./engine/prova
|
||||
|
||||
echo "== 4. tasking Ada (thread + protected) =="
|
||||
cp "$HERE/tasking.adb" .
|
||||
$GCC -gnat2022 -O1 tasking.adb >/dev/null
|
||||
$QEMU ./tasking
|
||||
|
||||
echo "== 5. glibc richiesta dal binario =="
|
||||
objdump -T engine/prova | grep -o "GLIBC_[0-9.]*" | sort -uV | tr '\n' ' '; echo
|
||||
echo " (Sailfish 5.1 arriva a GLIBC_2.34)"
|
||||
@@ -0,0 +1,31 @@
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
procedure Tasking is
|
||||
protected Counter is
|
||||
procedure Bump;
|
||||
function Value return Natural;
|
||||
private
|
||||
N : Natural := 0;
|
||||
end Counter;
|
||||
protected body Counter is
|
||||
procedure Bump is begin N := N + 1; end Bump;
|
||||
function Value return Natural is begin return N; end Value;
|
||||
end Counter;
|
||||
|
||||
task type Worker (Id : Positive);
|
||||
task body Worker is
|
||||
pragma Unreferenced (Id);
|
||||
begin
|
||||
for I in 1 .. 10_000 loop
|
||||
Counter.Bump;
|
||||
end loop;
|
||||
end Worker;
|
||||
begin
|
||||
declare
|
||||
T1 : Worker (1);
|
||||
T2 : Worker (2);
|
||||
T3 : Worker (3);
|
||||
begin
|
||||
null;
|
||||
end; -- qui le tre task sono terminate
|
||||
Put_Line ("incrementi totali:" & Natural'Image (Counter.Value) & " (attesi 30000)");
|
||||
end Tasking;
|
||||
Reference in new issue
Block a user