[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: default directories in installed library projects



Ludovic Brenta wrote:
> I'd like to rephrase what Nicolas said.  GNAT can cross-compile and
> that has been the case for years.  However, upstream GNAT will not
> support multiarch anytime soon.
> 
> For the C language, the /usr/bin/gcc compiler driver supports
> multiarch; this means that compile-time options like -m32, -march
> etc. cause it to select one of several installed "cc1" compilers and
> "ld" linkers, each emitting object code for a different target, and
> also to select the appropriate default include directories and
> libraries.
> 
> Unfortunately, the same does not apply to /usr/bin/gnatmake for the
> Ada language.  If you want to compile Ada for, say, both 32- and
> 64-bit targets, you need two independent installations of the
> compiler, i.e. two different gnatmakes, two different gccs, etc.,
> none of which actually supports multiarch.

That conflicts with my experience.

Using Fedora's packaged x86-64 GNAT I can build what appears to be a
working 32-bit program just by passing -m32 to Gnatmake. Gnatmake passes
the option on to the compiler driver "gcc" both when compiling and when
linking. GPRbuild doesn't understand -m32 itself but "-cargs -m32 -largs
-m32" works.

To get the 64-bit GNAT to build a 32-bit shared library the project file
must support LDFLAGS, because -largs is only used for linking programs.
I include «for Library_Options use external_as_list("LDFLAGS", " ");» in
my project files and set LDFLAGS=-m32 in the environment. This works the
same way with both Gnatmake and GPRbuild.

To make this work I had to install the packages libgnat.i686, libgnat-
devel.i686, libgnat-static.i686 and glibc-devel.i686. No 32-bit Gnatmake
or GPRbuild was needed. I thought I would need gcc-gnat.i686 which
contains the 32-bit gnat1, but it turns out that compilation works fine
without that.

I'm pretty sure Fedora hasn't added any features to the Ada aspect of
GCC, so there seems to be quite a lot of multiarch support upstream.
The compiler driver and the actual compiler and linker seem to support
multiarch for Ada like they do for C, and the multiarch support in
the builders seems adequate for building programs. The support for
building shared libraries is a bit lacking, but it can be done with the
right directives in the project file. I think this level of support is
quite sufficient to justify that library packages should have multiarch
support.

I don't want to tell you how to do your packaging, but if this doesn't
work in Debian then I think it has more to do with how GNAT is packaged
in Debian than with missing support upstream.

For actual cross-compilation to a completely different architecture I
would of course expect to need a separate cross-compiler.

Björn Persson

Attachment: signature.asc
Description: PGP signature


Reply to: