diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1dcb3eb5981..5fc09eca087 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2011-08-05 Nicolas Roche + + * gcc-interface/Makefile.in: Don't use directly ../xgcc to build shared + libgnat. Use rather the value of GCC_FOR_TARGET. Fix issue with + canadian cross. + * gcc-interface/Make-lang.in: Add support for canadian cross setting. + 2011-08-05 Matthew Heaney * a-comutr.adb, a-cimutr.adb, a-cbmutr.adb (Child_Count, Child_Depth): diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 18a22bc0b69..98f142ec628 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -94,7 +94,11 @@ ada: gnat1$(exeext) gnatbind$(exeext) # There are too many Ada sources to check against here. Let's # always force the recursive make. -ADA_TOOLS_FLAGS_TO_PASS=\ +ifeq ($(build), $(host)) + ifeq ($(host), $(target)) + # This is a regular native. So use the compiler from our current build + # tree. + ADA_TOOLS_FLAGS_TO_PASS=\ "CC=../../xgcc -B../../" \ "CFLAGS=$(CFLAGS)" \ "exeext=$(exeext)" \ @@ -103,6 +107,58 @@ ADA_TOOLS_FLAGS_TO_PASS=\ "GNATMAKE=../../gnatmake" \ "GNATLINK=../../gnatlink" \ "GNATBIND=../../gnatbind" + else + # This is a regular cross compiler. Use the native compiler to compile + # the tools. + + # put the host RTS dir first in the PATH to hide the default runtime + # files that are among the sources + RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib ))) + + ADA_TOOLS_FLAGS_TO_PASS=\ + CC="$(CC)" \ + $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ + ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \ + GNATMAKE="gnatmake" \ + GNATBIND="gnatbind" \ + GNATLINK="gnatlink" \ + LIBGNAT="" + endif +else + # Build is different from host so we are either building a canadian cross + # or a cross-native compiler. We provide defaults for tools targeting the + # host platform, but they can be overriden by just setting _FOR_HOST + # variables. + GNATMAKE_FOR_HOST=$(host)-gnatmake + GNATBIND_FOR_HOST=$(host)-gnatbind + GNATLINK_FOR_HOST=$(host)-gnatlink + GNATLS_FOR_HOST=$(host)-gnatls + + ifeq ($(host), $(target)) + # This is a cross native. All the sources are taken from the currently + # built runtime. + ADA_TOOLS_FLAGS_TO_PASS=\ + CC="$(CC)" \ + $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ + ADA_INCLUDES="-I../rts" \ + GNATMAKE="$(GNATMAKE_FOR_HOST)" \ + GNATBIND="$(GNATBIND_FOR_HOST)" \ + GNATLINK="$(GNATLINK_FOR_HOST)" \ + LIBGNAT="" + else + # This is a canadian cross. We should use a toolchain running on the + # build platform and targeting the host platform. + RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib ))) + ADA_TOOLS_FLAGS_TO_PASS=\ + CC="$(CC)" \ + $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ + ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \ + GNATMAKE="$(GNATMAKE_FOR_HOST)" \ + GNATBIND="$(GNATBIND_FOR_HOST)" \ + GNATLINK="$(GNATLINK_FOR_HOST)" \ + LIBGNAT="" + endif +endif GCC_LINK=$(LINKER) $(ALL_LINKERFLAGS) -static-libgcc $(LDFLAGS) diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 1e7a392edf4..f877417b700 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -2488,13 +2488,15 @@ gnatlib-shared-default: THREAD_KIND="$(THREAD_KIND)" \ gnatlib $(RM) $(RTSDIR)/libgna*$(soext) - cd $(RTSDIR); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ $(TARGET_LIBGCC2_CFLAGS) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(MISCLIB) -lm - cd $(RTSDIR); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ $(TARGET_LIBGCC2_CFLAGS) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ @@ -2556,12 +2558,14 @@ gnatlib-shared-win32: THREAD_KIND="$(THREAD_KIND)" \ gnatlib $(RM) $(RTSDIR)/libgna*$(soext) - cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ $(TARGET_LIBGCC2_CFLAGS) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) - cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ $(TARGET_LIBGCC2_CFLAGS) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ @@ -2577,13 +2581,15 @@ gnatlib-shared-darwin: THREAD_KIND="$(THREAD_KIND)" \ gnatlib $(RM) $(RTSDIR)/libgnat$(soext) $(RTSDIR)/libgnarl$(soext) - cd $(RTSDIR); ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS) \ -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(MISCLIB) -lm - cd $(RTSDIR); ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ + cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ + | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ $(SO_OPTS) \