This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][Ada] PR ada/5911 Enable multilib build for Ada
- From: Laurent GUERBY <laurent at guerby dot net>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Arnaud Charlet <charlet at adacore dot com>, Paolo Bonzini <bonzini at gnu dot org>, Joel Sherrill <joel dot sherrill at oarcorp dot com>, Eric Botcazou <ebotcazou at adacore dot com>, Samuel Tardieu <sam at rfc1149 dot net>
- Date: Sun, 31 Aug 2008 10:30:49 +0200
- Subject: [PATCH][Ada] PR ada/5911 Enable multilib build for Ada
The following patch has been tested on x86_64-linux trunk
with this patch to correct an unrelated dwarf2out.c Ada bootstrap issue:
http://gcc.gnu.org/ml/gcc-patches/2008-08/msg02353.html
Testing is currently not possible on sparc-solaris/linux because
bootstrap for C is broken:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37279
Previous comments from the draft version of this patch have been
incorporated:
http://gcc.gnu.org/ml/gcc/2008-07/msg00338.html
Two generic patches have already been commited, so the current patch is
really small and is mostly following Paolo advice on enabling multilib
magic.
I will need help for testing and completing the TODO part to support
more platforms, Eric volunteered for sparc and Joel for RTEMS.
This patch might break bootstrap either if we hit code generation ICE on
gnatlib multilib variants we were previously not compiling or if the
LIBGNAT_TARGET_PAIRS end up selecting non compilable sources
(inconsistent 32 vs 64 bits leading to compile errors).
Using a multilib variant can also lead to wrong code in some case such
as endianness dependant sources and missing corresponding
LIBGNAT_TARGET_PAIRS multilib handling.
In both case the fix will be expanding the multilib TODO section with
appropriate selection machinery, hopefully nothing too complicated even
for non Ada developpers, as promised I'll help on any problem that comes
up. I tested that --disable-multilib disables Ada multilib too.
To compile with gnatmake once the multilib'ed Ada compiler is installed
you currently need to use --RTS flag as follows:
export FLAGS="-m64"; gnatmake $FLAGS --RTS=$(gcc -print-multi-directory $FLAGS) main.adb
export FLAGS="-m32"; gnatmake $FLAGS --RTS=$(gcc -print-multi-directory $FLAGS) main.adb
export FLAGS=""; gnatmake $FLAGS --RTS=$(gcc -print-multi-directory $FLAGS) main.adb
In the future I think --RTS could be avoided by adding %I to
gcc/ada/lang-spec.h and handling the corresponding -imultilib in GNAT
option processing (same as C include handling for multilib). Other
approach is to link and call functions in gcc/gcc.c, Paolo
mentionned that some cleanup might be done first in gcc.c.
I don't know much about this part of the code, so volunteer help
is welcomed.
Ok to commit?
Laurent
2008-08-31 Laurent Guerby <laurent@guerby.net>
Paolo Bonzini <bonzini@gnu.org>
PR ada/5911
* Makefile.in (all, install, mostlyclean, clean, distclean): Add
multilib handling.
* configure.ac: Add multilib handling.
* configure: Regenerate.
2008-08-31 Laurent Guerby <laurent@guerby.net>
PR ada/5911
* gcc-interface/Makefile.in: Add multilib handling for x86_64.
* system-linux-sparc.ads (Storage_Unit, Word_Size, Memory_Size): Use
Standard attributes.
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in (revision 139820)
+++ gcc/ada/gcc-interface/Makefile.in (working copy)
@@ -316,6 +316,18 @@
osys:=$(word 3,$(targ))
endif
+# Make arch match the current multilib so that the RTS selection code
+# picks up the right files. For a given target this must be coherent
+# with MULTILIB_DIRNAMES defined in gcc/config/target/t-*.
+
+ifeq ($(strip $(filter-out %x86_64, $(arch))),)
+ ifeq ($(strip $(MULTISUBDIR)),/32)
+ arch:=i686
+ endif
+endif
+
+# TODO: handle more multilib targets
+
# LIBGNAT_TARGET_PAIRS is a list of pairs of filenames.
# The members of each pair must be separated by a '<' and no whitespace.
# Each pair must be separated by some amount of whitespace from the following
Index: gcc/ada/system-linux-sparc.ads
===================================================================
--- gcc/ada/system-linux-sparc.ads (revision 139820)
+++ gcc/ada/system-linux-sparc.ads (working copy)
@@ -65,9 +65,9 @@
type Address is private;
Null_Address : constant Address;
- Storage_Unit : constant := 8;
- Word_Size : constant := 32;
- Memory_Size : constant := 2 ** 32;
+ Storage_Unit : constant := Standard'Storage_Unit;
+ Word_Size : constant := Standard'Word_Size;
+ Memory_Size : constant := 2 ** Standard'Address_Size;
-- Address comparison
Index: libada/Makefile.in
===================================================================
--- libada/Makefile.in (revision 139820)
+++ libada/Makefile.in (working copy)
@@ -17,7 +17,18 @@
# Default target; must be first.
all: gnatlib
+ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)
+.PHONY: all install
+
+## Multilib support variables.
+MULTISRCTOP =
+MULTIBUILDTOP =
+MULTIDIRS =
+MULTISUBDIR =
+MULTIDO = true
+MULTICLEAN = true
+
# Standard autoconf-set variables.
SHELL = @SHELL@
srcdir = @srcdir@
@@ -48,12 +59,12 @@
# Get target-specific overrides for TARGET_LIBGCC2_CFLAGS.
host_subdir = @host_subdir@
-GCC_DIR=../../$(host_subdir)/gcc
+GCC_DIR=$(MULTIBUILDTOP)../../$(host_subdir)/gcc
include $(GCC_DIR)/libgcc.mvars
target_noncanonical:=@target_noncanonical@
version := $(shell cat $(srcdir)/../gcc/BASE-VER)
-libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)
+libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)$(MULTISUBDIR)
# exeext should not be used because it's the *host* exeext. We're building
# a *target* library, aren't we?!? Likewise for CC. Still, provide bogus
@@ -64,11 +75,12 @@
"LDFLAGS=$(LDFLAGS)" \
"LN_S=$(LN_S)" \
"SHELL=$(SHELL)" \
- "GNATLIBFLAGS=$(GNATLIBFLAGS)" \
- "GNATLIBCFLAGS=$(GNATLIBCFLAGS)" \
+ "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \
+ "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
"TARGET_LIBGCC2_CFLAGS=$(TARGET_LIBGCC2_CFLAGS)" \
"THREAD_KIND=$(THREAD_KIND)" \
"TRACE=$(TRACE)" \
+ "MULTISUBDIR=$(MULTISUBDIR)" \
"libsubdir=$(libsubdir)" \
"objext=$(objext)" \
"prefix=$(prefix)" \
@@ -119,7 +131,8 @@
TAGS:
# Installation rules.
-install:
+install: install-gnatlib
+ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE)
install-info:
@@ -129,10 +142,13 @@
# Cleaning rules.
mostlyclean:
+ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE)
clean:
+ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE)
distclean:
+ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE)
$(RM) Makefile config.status config.log
maintainer-clean:
Index: libada/configure.ac
===================================================================
--- libada/configure.ac (revision 139820)
+++ libada/configure.ac (working copy)
@@ -49,6 +49,54 @@
[MAINT='#'])
AC_SUBST([MAINT])dnl
+AC_CANONICAL_SYSTEM
+target_alias=${target_alias-$host_alias}
+
+AM_ENABLE_MULTILIB(, ..)
+# Calculate toolexeclibdir
+# Also toolexecdir, though it's only used in toolexeclibdir
+case ${enable_version_specific_runtime_libs} in
+ yes)
+ # Need the gcc compiler version to know where to install libraries
+ # and header files if --enable-version-specific-runtime-libs option
+ # is selected.
+ toolexecdir='$(libdir)/gcc/$(target_alias)'
+ toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
+ ;;
+ no)
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ # Install a library built with a cross compiler in tooldir, not libdir.
+ toolexecdir='$(exec_prefix)/$(target_alias)'
+ toolexeclibdir='$(toolexecdir)/lib'
+ else
+ toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
+ toolexeclibdir='$(libdir)'
+ fi
+ multi_os_directory=`$CC -print-multi-os-directory`
+ case $multi_os_directory in
+ .) ;; # Avoid trailing /.
+ *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
+ esac
+ ;;
+esac
+AC_SUBST(toolexecdir)
+AC_SUBST(toolexeclibdir)
+#TODO: toolexeclibdir is currently disregarded
+
+# Check the compiler.
+# The same as in boehm-gc and libstdc++. Have to borrow it from there.
+# We must force CC to /not/ be precious variables; otherwise
+# the wrong, non-multilib-adjusted value will be used in multilibs.
+# As a side effect, we have to subst CFLAGS ourselves.
+
+m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
+m4_define([_AC_ARG_VAR_PRECIOUS],[])
+AC_PROG_CC
+m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
+
+AC_SUBST(CFLAGS)
+
AC_ARG_ENABLE([shared],
[AC_HELP_STRING([--disable-shared],
[don't provide a shared libgnat])],