comp.lang.ada
 help / color / mirror / Atom feed
* GNAT GPL 2012 on Raspberry Pi
@ 2012-07-28 22:56 Jan Andres
  2012-07-28 23:43 ` Patrick
  2012-07-29 10:20 ` Lucretia
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Andres @ 2012-07-28 22:56 UTC (permalink / raw)


So a couple of days ago the postman finally brought that Raspberry Pi I
had ordered a long time ago and I found some time to take a look at it.
I installed Raspbian "wheezy", a slightly adapted version of Debian
optimized for the Pi. It has binary packages of gcc-4.6.x with Ada
support, but not for GNAT GPL, so I played around a bit with
bootstrapping GNAT GPL 2012 from my x86_64 Linux box. It only takes a few
minor tweaks and the resulting compiler seems to be working well at
first glance. (I haven't run the test suite, though.)

I thought I'd share this just in case it's useful to someone. Below are
some notes about the build process and a patch to be applied to the GNAT
GPL source tree in order to build for Raspbian. Note that the build
process is somewhat glitchy in places so if you're having trouble,
try to follow the build instructions as closely as possible. Note
especially that although the Raspbian distribution refers to its
architecture as "arm-linux-gnueabihf", the "hf" suffix must be omitted
when building GNAT GPL.



Host: Fedora 17 x86_64
Target: Raspbian wheezy


preparations:
-------------
install native gnat-gpl-2012 binaries for x86_64
prepend gnat-gpl's bin directory to PATH
create image of target system in /home/jan/arm
unpack binutils version 2.22 (other versions may work)
unpack gcc-4.5-2012 and gnat-gpl-2012
move ada subdirectory from gnat-gpl to gcc (cf. README.BUILD)
apply patch for gcc-4.5-2012


step 0: binutils
----------------
cd binutils-2.22
mkdir o
cd o
../configure --prefix=/home/jan/gcc-cross1 --build=x86_64-redhat-linux --host=x86_64-redhat-linux --target=arm-linux-gnueabi --with-sysroot=/home/jan/arm
make
make install
prepend /home/jan/gcc-cross1 to PATH for the following steps


step 1: cross compiler
----------------------
cd gcc-4.5-2012-src
mkdir o-cross
cd o-cross
../configure --prefix=/home/jan/gcc-cross1 --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=arm-linux-gnueabi --enable-languages=c,ada --with-sysroot=/home/jan/arm --disable-nls --enable-serial-configure --disable-shared --disable-libada --with-arch=armv6 --with-fpu=vfp --with-float=hard
make
-> build terminates in libgcc, bits/predefs.h: No such file or directory
patch up gcc/specs
-> for cpp, add -I/home/jan/arm/usr/include/arm-linux-gnueabihf
-> set multilib to .:arm-linux-gnueabihf
make
-> build should now finish
make -C gcc gnatlib cross-gnattools
make -C gcc ada.all.cross
make install
cd /home/jan/gcc-cross1/lib/gcc/arm-linux-gnueabi/4.5.4/
arm-linux-gnueabi-gcc -dumpspecs >specs
patch up specs as above


step 2: native compiler for ARM
-------------------------------
cd gcc-4.5-2012-src
mkdir o-native
cd o-native
../configure --prefix=/home/jan/gnat-native-arm --build=x86_64-pc-linux-gnu --host=arm-linux-gnueabi --target=arm-linux-gnueabi --enable-languages=c,ada --disable-nls --enable-serial-configure --disable-shared --disable-libada --with-arch=armv6 --with-fpu=vfp --with-float=hard
make
make -C gcc gnatlib GCC_FOR_TARGET=arm-linux-gnueabi-gcc
make -C gcc gnattools GNATBIND_FOR_HOST=arm-linux-gnueabi-gnatbind GNATMAKE_FOR_HOST=arm-linux-gnueabi-gnatmake GNATLINK_FOR_HOST=arm-linux-gnueabi-gnatlink
make install and copy /home/jan/gnat-native-arm to target
from here on, work on target
cd /home/jan/gnat-native-arm/lib/gcc/arm-linux-gnueabi/4.5.4/
/home/jan/gnat-native-arm/bin/gcc -dumpspecs >specs
patch up specs as above, but use -I/usr/include/arm-linux-gnueabihf this time


NOTES
-----
Backend exceptions (aka ZCX) are currently disabled as they have issues
(most exceptions get the program caught in an infinite loop). To enable
set EH_MECHANISM in gcc-interface/Makefile.in and set ZCX_By_Default in
system-linux-arm.adb.



diff -urN gcc-4.5-2012-src/gcc/ada/gcc-interface/Makefile.in gcc-4.5-2012-patched/gcc/ada/gcc-interface/Makefile.in
--- gcc-4.5-2012-src/gcc/ada/gcc-interface/Makefile.in	2012-04-17 20:53:53.000000000 +0200
+++ gcc-4.5-2012-patched/gcc/ada/gcc-interface/Makefile.in	2012-07-28 21:31:15.408271476 +0200
@@ -1124,6 +1124,55 @@
   LIBRARY_VERSION := $(LIB_VERSION)
 endif
 
+# ARM Linux
+ifeq ($(strip $(filter-out arm% linux%,$(arch) $(osys))),)
+  LIBGNAT_TARGET_PAIRS = \
+  a-intnam.ads<a-intnam-linux.ads \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
+  s-inmaop.adb<s-inmaop-posix.adb \
+  s-intman.adb<s-intman-posix.adb \
+  s-tpopsp.adb<s-tpopsp-tls.adb \
+  g-trasym.adb<g-trasym-dwarf.adb \
+  g-sercom.adb<g-sercom-linux.adb \
+  a-exetim.adb<a-exetim-posix.adb \
+  a-exetim.ads<a-exetim-default.ads \
+  s-linux.ads<s-linux.ads \
+  s-osinte.adb<s-osinte-posix.adb \
+  system.ads<system-linux-arm.ads \
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
+
+  ifeq ($(strip $(filter-out xenomai,$(THREAD_KIND))),)
+    LIBGNAT_TARGET_PAIRS += \
+    s-osinte.ads<s-osinte-linux-xenomai.ads \
+    s-osprim.adb<s-osprim-linux-xenomai.adb \
+    s-taprop.adb<s-taprop-linux-xenomai.adb \
+    s-taspri.ads<s-taspri-linux-xenomai.ads
+  else
+    LIBGNAT_TARGET_PAIRS += \
+    s-mudido.adb<s-mudido-affinity.adb \
+    s-osinte.ads<s-osinte-linux.ads \
+    s-osprim.adb<s-osprim-posix.adb \
+    s-taprop.adb<s-taprop-linux.adb \
+    s-tasinf.ads<s-tasinf-linux.ads \
+    s-tasinf.adb<s-tasinf-linux.adb \
+    s-taspri.ads<s-taspri-posix.ads
+  endif
+
+  #EH_MECHANISM=-gcc
+  THREADSLIB = -lpthread -lrt
+  EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
+
+  TOOLS_TARGET_PAIRS =  \
+    mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
+    indepsw.adb<indepsw-gnu.adb
+
+  GNATLIB_SHARED = gnatlib-shared-dual
+  GMEM_LIB = gmemlib
+  LIBRARY_VERSION := $(LIB_VERSION)
+endif
+
 # x86 kfreebsd
 ifeq ($(strip $(filter-out %86 kfreebsd%,$(arch) $(osys))),)
   LIBGNAT_TARGET_PAIRS = \
diff -urN gcc-4.5-2012-src/gcc/ada/gcc-interface/Make-lang.in gcc-4.5-2012-patched/gcc/ada/gcc-interface/Make-lang.in
--- gcc-4.5-2012-src/gcc/ada/gcc-interface/Make-lang.in	2012-04-22 17:18:47.000000000 +0200
+++ gcc-4.5-2012-patched/gcc/ada/gcc-interface/Make-lang.in	2012-07-28 15:12:33.589141702 +0200
@@ -149,7 +149,7 @@
         GNATMAKE="$(GNATMAKE_FOR_HOST)"      \
         GNATBIND="$(GNATBIND_FOR_HOST)"      \
         GNATLINK="$(GNATLINK_FOR_HOST)"      \
-        LIBGNAT=""
+        #LIBGNAT=""
   else
     # This is a canadian cross. We should use a toolchain running on the
     # build platform and targeting the host platform.
diff -urN gcc-4.5-2012-src/gcc/ada/init.c gcc-4.5-2012-patched/gcc/ada/init.c
--- gcc-4.5-2012-src/gcc/ada/init.c	2012-05-10 14:57:46.000000000 +0200
+++ gcc-4.5-2012-patched/gcc/ada/init.c	2012-07-28 16:44:47.816483513 +0200
@@ -533,7 +533,7 @@
   Raise_From_Signal_Handler (exception, msg);
 }
 
-#if defined (i386) || defined (__x86_64__) || defined (__powerpc__)
+#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) || defined (__arm__)
 /* This must be in keeping with System.OS_Interface.Alternate_Stack_Size.  */
 char __gnat_alternate_stack[16 * 1024]; /* 2 * SIGSTKSZ */
 #endif
diff -urN gcc-4.5-2012-src/gcc/ada/raise-gcc.c gcc-4.5-2012-patched/gcc/ada/raise-gcc.c
--- gcc-4.5-2012-src/gcc/ada/raise-gcc.c	2012-05-10 14:57:46.000000000 +0200
+++ gcc-4.5-2012-patched/gcc/ada/raise-gcc.c	2012-07-28 13:50:07.075298488 +0200
@@ -1102,7 +1102,7 @@
 	return __gnat_handle_vms_condition (version_arg, phases_arg);
 #endif
 
-      return _URC_FATAL_PHASE1_ERROR;
+      return _URC_FAILURE;
     }
 
   db_indent (DB_INDENT_RESET);
diff -urN gcc-4.5-2012-src/gcc/ada/system-linux-arm.ads gcc-4.5-2012-patched/gcc/ada/system-linux-arm.ads
--- gcc-4.5-2012-src/gcc/ada/system-linux-arm.ads	1970-01-01 01:00:00.000000000 +0100
+++ gcc-4.5-2012-patched/gcc/ada/system-linux-arm.ads	2012-07-28 21:57:25.113351902 +0200
@@ -0,0 +1,151 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                        GNAT RUN-TIME COMPONENTS                          --
+--                                                                          --
+--                               S Y S T E M                                --
+--                                                                          --
+--                                 S p e c                                  --
+--                              (ARM Version)                               --
+--                                                                          --
+--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--                                                                          --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. The copyright notice above, and the license provisions that follow --
+-- apply solely to the  contents of the part following the private keyword. --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+--                                                                          --
+--                                                                          --
+--                                                                          --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.000_001;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   pragma Preelaborable_Initialization (Address);
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 32;
+   Memory_Size  : constant := 2 ** 32;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := Low_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   --  0 .. 98 corresponds to the system priority range 1 .. 99.
+   --
+   --  If the scheduling policy is SCHED_FIFO or SCHED_RR the runtime makes use
+   --  of the entire range provided by the system.
+   --
+   --  If the scheduling policy is SCHED_OTHER the only valid system priority
+   --  is 1 and other values are simply ignored.
+
+   Max_Priority           : constant Positive := 97;
+   Max_Interrupt_Priority : constant Positive := 98;
+
+   subtype Any_Priority       is Integer      range  0 .. 98;
+   subtype Priority           is Any_Priority range  0 .. 97;
+   subtype Interrupt_Priority is Any_Priority range 98 .. 98;
+
+   Default_Priority : constant Priority := 48;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is used
+   --  by the compiler. They are in the private part of System, where they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
+   Command_Line_Args         : constant Boolean := True;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := True;
+   Stack_Check_Limits        : constant Boolean := False;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Always_Compatible_Rep     : constant Boolean := False;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := False;
+
+end System;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GNAT GPL 2012 on Raspberry Pi
  2012-07-28 22:56 GNAT GPL 2012 on Raspberry Pi Jan Andres
@ 2012-07-28 23:43 ` Patrick
  2012-07-29 10:20 ` Lucretia
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick @ 2012-07-28 23:43 UTC (permalink / raw)


Hi Jan

You are still pretty far ahead of me but this will be very useful later, thanks for sharing-Patrick



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GNAT GPL 2012 on Raspberry Pi
  2012-07-28 22:56 GNAT GPL 2012 on Raspberry Pi Jan Andres
  2012-07-28 23:43 ` Patrick
@ 2012-07-29 10:20 ` Lucretia
  1 sibling, 0 replies; 3+ messages in thread
From: Lucretia @ 2012-07-29 10:20 UTC (permalink / raw)


I tried to do a Canadian cross on my native machine, I got as far as a cross GNAT, but it would not build gnatlib using the cross compiler, as it was trying to execute a native ARM executable.

I just copied the arm system.ads from the fSF tree.

If you do a google search, you'll find posts from me about attempting to get ZCX working on ARM, there has to be a lot of modifications made to the exception packages as ARM is very different, it has it's own code separate from the GCC mechanism.

Luke.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-29 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-28 22:56 GNAT GPL 2012 on Raspberry Pi Jan Andres
2012-07-28 23:43 ` Patrick
2012-07-29 10:20 ` Lucretia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox