# DP: There are two exception mechanisms to choose from: zero-cost and # DP: setjump/longjump. The Ada run-time library uses either of them # DP: but not both. Build both versions of the run-time library. # This patch changes the way the upstream Makefiles build the run-time # library. Before the patch: libada/Makefile calls gcc/ada/Makefile, # which builds the "rts" subdirectory containing symbolic links to # most source files, and modified copies of a few source files (to # take target dependencies into account, and also to select the # exception handling mechanism in system.ads). Then, gcc/ada/Makefile # calls itself recursively but in the "rts" subdirectory and builds # libgnat.a and libgnarl.a (and a couple other libraries: # libgccprefix.a, libgmem.a). Upon return from this recursive call, # it deletes the source and object files from "rts", reconstructs the # source files, and builds libgnat.so and libgnarl.so by calling # itself recursively a second time in the "rts" directory. # Furthermore, gcc/ada/Makefile disables parallel makes, so building # the static and then shared versions of the RTS is entirely # sequential even on SMP systems. # As a consequence of the above, building the SJLJ version of the # library would overwrite the ZCX version. Thus it is necessary to # manually save the previous version of the library before building the # second one. # After the patch: libada/Makefile calls gcc/ada/Makefile, which # builds the source directory (named gnatlib-sources instead of rts), # containing the symbolic links and target-dependent files. # In a second step, libada/Makefile calls gcc/ada/Makefile again to # build the targets gnatlib-shared-zcx, gnatlib-static-zcx and # gnatlib-static-sjlj (we could also build gnatlib-shared-sjlj, but # that triggers compiler errors on PowerPC). # Each of these three targets copies the source directory "rts" into a # new directory named rts-shared-zcx, rts-static-zcx or # rts-static-sjlj. In the new directory, they change the value of # System.ZCX_By_Default, and then they call gcc/ada/Makefile # recursively in the new directory to build the library. # gcc/ada/Makefile.in has a .NOTPARALLEL directive preventing it from # launching commands in parallel. However, libada/Makefile has no # such directive and can invoke up to three instances of # gcc/ada/Makefile.in in parallel. This is okay because each of them # runs in a different directory. # This patch also updates libgnat{vsn,prj}/Makefile and # gnattools/Makefile to look for the shared ZCX version of the library # in the appropriate directory, rather than just "rts", and updates # the "make install" and binary targets as well. Index: b/src/libada/Makefile.in =================================================================== --- a/src/libada/Makefile.in +++ b/src/libada/Makefile.in @@ -16,7 +16,8 @@ # . # Default target; must be first. -all: gnatlib +GNATLIB = gnatlib-static-zcx gnatlib-static-sjlj gnatlib-shared-zcx +all: $(GNATLIB) $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE) .PHONY: all @@ -97,26 +98,28 @@ "CFLAGS=$(CFLAGS)" # Rules to build gnatlib. -.PHONY: gnatlib gnatlib-plain gnatlib-sjlj gnatlib-zcx gnatlib-shared osconstool -gnatlib: @default_gnatlib_target@ +.PHONY: $(GNATLIB) osconstool -gnatlib-plain: osconstool $(GCC_DIR)/ada/Makefile - test -f stamp-libada || \ - $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) gnatlib \ - && touch stamp-libada - -rm -rf adainclude - -rm -rf adalib - $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adainclude - $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adalib - -gnatlib-sjlj gnatlib-zcx gnatlib-shared: osconstool $(GCC_DIR)/ada/Makefile - test -f stamp-libada || \ - $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) $@ \ - && touch stamp-libada - -rm -rf adainclude - -rm -rf adalib - $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adainclude - $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adalib +$(GCC_DIR)/ada/gnatlib-sources-sjlj/a-except.ads: + $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) \ + EH_MECHANISM="" \ + gnatlib-sources-sjlj/a-except.ads + +$(GCC_DIR)/ada/gnatlib-sources-zcx/a-except.ads: + $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) \ + EH_MECHANISM="-gcc" \ + gnatlib-sources-zcx/a-except.ads + +$(GNATLIB): osconstool $(GCC_DIR)/ada/Makefile \ +$(GCC_DIR)/ada/gnatlib-sources-zcx/a-except.ads \ +$(GCC_DIR)/ada/gnatlib-sources-sjlj/a-except.ads + $(MAKE) -C $(GCC_DIR)/ada $(FLAGS_TO_PASS) \ + GNATLIBFLAGS="$(GNATLIBFLAGS)" \ + GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ + TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ + THREAD_KIND="$(THREAD_KIND)" \ + TRACE="$(TRACE)" \ + $@ osconstool: $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) ./bldtools/oscons/xoscons Index: b/src/gcc/ada/gcc-interface/Makefile.in =================================================================== --- a/src/gcc/ada/gcc-interface/Makefile.in +++ b/src/gcc/ada/gcc-interface/Makefile.in @@ -2353,84 +2353,109 @@ $(patsubst %$(objext),%.adb,$(GNATRTL_OBJS)), \ $(ADA_EXCLUDE_SRCS)) -../stamp-gnatlib-$(RTSDIR): - @if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \ - then \ - $(ECHO) You must first build the GNAT library: make gnatlib; \ - false; \ - else \ - true; \ - fi +libgnat = libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) +libgnat-sjlj = libgnat$(hyphen)sjlj$(hyphen)$(LIBRARY_VERSION)$(soext) -install-gnatlib: ../stamp-gnatlib-$(RTSDIR) +install-gnatlib: rts-static-zcx/libgnat$(arext) rts-static-sjlj/libgnat$(arext) +install-gnatlib: rts-shared-zcx/$(libgnat) # Create the directory before deleting it, in case the directory is # a list of directories (as it may be on VMS). This ensures we are # deleting the right one. - -$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR) - -$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR) - $(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR) - $(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR) - -$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR) - -$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR) - for file in $(RTSDIR)/*.ali; do \ - $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ + -$(MKDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR) + $(RMDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR) + $(RMDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR) + + -$(MKDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR) + $(RMDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR) + $(RMDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR) + -$(MKDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR) + + for file in rts-shared-zcx/*.ali; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \ + done + for file in rts-static-sjlj/*.ali; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR); \ + done + + -cd rts-static-zcx; for file in *$(arext);do \ + $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \ + $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)/$$file; \ done - -cd $(RTSDIR); for file in *$(arext);do \ - $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ - $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \ + -cd rts-static-sjlj; for file in *$(arext);do \ + $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR); \ + $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR)/$$file; \ done + + -$(foreach file, $(EXTRA_ADALIB_FILES), \ + $(INSTALL_DATA_DATE) rts-static-zcx/$(file) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR) && \ + ) true -$(foreach file, $(EXTRA_ADALIB_FILES), \ - $(INSTALL_DATA_DATE) $(RTSDIR)/$(file) $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \ + $(INSTALL_DATA_DATE) rts-static-sjlj/$(file) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR) && \ ) true # Install the shared libraries, if any, using $(INSTALL) instead # of $(INSTALL_DATA). The latter may force a mode inappropriate # for shared libraries on some targets, e.g. on HP-UX where the x # permission is required. -# Also install the .dSYM directories if they exist (these directories -# contain the debug information for the shared libraries on darwin) for file in gnat gnarl; do \ - if [ -f $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 ]; then \ - $(INSTALL) $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ - $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ - fi; \ - if [ -d $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM ]; then \ - $(CP) -r $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM \ - $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ + if [ -f rts-shared-zcx/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 ]; then \ + $(INSTALL) rts-shared-zcx/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ + $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \ fi; \ done # This copy must be done preserving the date on the original file. - for file in $(RTSDIR)/*.ad?; do \ - $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \ + for file in rts-shared-zcx/*.adb rts-shared-zcx/*.ads; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR); \ done - cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb - cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads + $(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)/*.adb + $(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)/*.ads + for file in rts-static-sjlj/*.adb rts-static-sjlj/*.ads; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR); \ + done + $(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)/*.adb + $(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)/*.ads + + (cd $(DESTDIR)$(libsubdir); \ + ln -s rts-native/adainclude adainclude; \ + ln -s rts-native/adalib adalib;) + +replace_zcx_by_default=\ +'s/ZCX_By_Default.*/ZCX_By_Default : constant Boolean := $(zcx_by_default);/' + +gnatlib-sources-zcx/a-except.ads: dir=$(dir $@) +gnatlib-sources-zcx/a-except.ads: zcx_by_default=True + +gnatlib-sources-sjlj/a-except.ads: dir=$(dir $@) +gnatlib-sources-sjlj/a-except.ads: zcx_by_default=False -../stamp-gnatlib1-$(RTSDIR): Makefile - $(RMDIR) $(RTSDIR) - $(MKDIR) $(RTSDIR) - $(CHMOD) u+w $(RTSDIR) +gnatlib-sources-zcx/a-except.ads gnatlib-sources-sjlj/a-except.ads: + $(MKDIR) $(dir) + $(CHMOD) u+w $(dir) # Copy target independent sources $(foreach f,$(ADA_INCLUDE_SRCS) $(LIBGNAT_SRCS), \ - $(LN_S) $(fsrcpfx)ada/$(f) $(RTSDIR) ;) true + $(LN_S) $(fsrcpfx)ada/$(f) $(dir) ;) true # Remove files not used - $(RM) $(patsubst %,$(RTSDIR)/%,$(ADA_EXCLUDE_FILES)) + $(RM) $(patsubst %,$(dir)/%,$(ADA_EXCLUDE_FILES)) # Remove files to be replaced by target dependent sources $(RM) $(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \ - $(RTSDIR)/$(word 1,$(subst <, ,$(PAIR)))) - for f in $(RTSDIR)/*-*-*.ads $(RTSDIR)/*-*-*.adb; do \ + $(dir)/$(word 1,$(subst <, ,$(PAIR)))) + for f in $(dir)/*-*-*.ads $(dir)/*-*-*.adb; do \ case "$$f" in \ - $(RTSDIR)/s-stratt-*) ;; \ + $(dir)/s-stratt-*) ;; \ *) $(RM) $$f ;; \ esac; \ done # Copy new target dependent sources $(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \ $(LN_S) $(fsrcpfx)ada/$(word 2,$(subst <, ,$(PAIR))) \ - $(RTSDIR)/$(word 1,$(subst <, ,$(PAIR)));) + $(dir)/$(word 1,$(subst <, ,$(PAIR)));) + sed -e $(replace_zcx_by_default) $(dir)/system.ads > $(dir)/s.ads # Copy tsystem.h - $(CP) $(srcdir)/tsystem.h $(RTSDIR) - $(RM) ../stamp-gnatlib-$(RTSDIR) - touch ../stamp-gnatlib1-$(RTSDIR) + $(CP) $(srcdir)/tsystem.h $(dir) ifeq ($(strip $(filter-out alpha64 ia64 dec hp vms% openvms% alphavms%,$(subst -, ,$(host)))),) OSCONS_CPP=../../$(DECC) -E /comment=as_is -DNATIVE \ @@ -2457,9 +2482,11 @@ $(CP) $^ ./bldtools/oscons (cd ./bldtools/oscons ; gnatmake -q xoscons) -$(RTSDIR)/s-oscons.ads: ../stamp-gnatlib1-$(RTSDIR) s-oscons-tmplt.c gsocket.h ./bldtools/oscons/xoscons - $(RM) $(RTSDIR)/s-oscons-tmplt.i $(RTSDIR)/s-oscons-tmplt.s - (cd $(RTSDIR) ; \ +.PRECIOUS: %/s-oscons.ads +%/s-oscons.ads: dir = $(dir $@) +%/s-oscons.ads: s-oscons-tmplt.c gsocket.h ./bldtools/oscons/xoscons + $(RM) $(dir)/s-oscons-tmplt.i $(dir)/s-oscons-tmplt.s + (cd $(dir) ; \ $(OSCONS_CPP) ; \ $(OSCONS_EXTRACT) ; \ ../bldtools/oscons/xoscons s-oscons) @@ -2470,9 +2497,12 @@ # Example: cd $(RTSDIR); ar rc libfoo.a $(LONG_LIST_OF_OBJS) # is guaranteed to overflow the buffer. -gnatlib: ../stamp-gnatlib1-$(RTSDIR) $(RTSDIR)/s-oscons.ads +%/libgnat$(arext): build_dir = $(dir $@) +%/libgnat$(arext): libgnarl = $(subst libgnat,libgnarl,$@) +%/libgnat$(arext): libgnala = $(subst libgnat,libgnala,$@) +%/libgnat$(arext): % %/s-oscons.ads # C files - $(MAKE) -C $(RTSDIR) \ + $(MAKE) -C $(build_dir) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \ @@ -2481,7 +2511,7 @@ srcdir=$(fsrcdir) \ -f ../Makefile $(LIBGNAT_OBJS) # Ada files - $(MAKE) -C $(RTSDIR) \ + $(MAKE) -C $(build_dir) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ ADA_INCLUDES="" \ @@ -2490,24 +2520,24 @@ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ srcdir=$(fsrcdir) \ -f ../Makefile $(GNATRTL_OBJS) - $(RM) $(RTSDIR)/libgnat$(arext) $(RTSDIR)/libgnarl$(arext) - $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnat$(arext) \ - $(addprefix $(RTSDIR)/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS)) - $(RANLIB_FOR_TARGET) $(RTSDIR)/libgnat$(arext) - $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnarl$(arext) \ - $(addprefix $(RTSDIR)/,$(GNATRTL_TASKING_OBJS)) - $(RANLIB_FOR_TARGET) $(RTSDIR)/libgnarl$(arext) + $(RM) $@ $(libgnarl) + $(AR_FOR_TARGET) $(AR_FLAGS) $@ \ + $(addprefix $(build_dir),$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) g-trasym.o) + $(RANLIB_FOR_TARGET) $@ + $(AR_FOR_TARGET) $(AR_FLAGS) $(libgnarl) \ + $(addprefix $(build_dir),$(GNATRTL_TASKING_OBJS)) + $(RANLIB_FOR_TARGET) $(libgnarl) ifeq ($(GMEM_LIB),gmemlib) - $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgmem$(arext) \ - $(RTSDIR)/memtrack.o - $(RANLIB_FOR_TARGET) $(RTSDIR)/libgmem$(arext) + $(AR_FOR_TARGET) $(AR_FLAGS) $(build_dir)libgmem$(arext) \ + $(build_dir)memtrack.o + $(RANLIB_FOR_TARGET) $(build_dir)libgmem$(arext) endif - $(CHMOD) a-wx $(RTSDIR)/*.ali - touch ../stamp-gnatlib-$(RTSDIR) # Warning: this target assumes that LIBRARY_VERSION has been set correctly. -gnatlib-shared-default: - $(MAKE) -C $(RTSDIR) \ +%/$(libgnat) %/$(libgnat-sjlj): build_dir = $(dir $@) +%/$(libgnat) %/$(libgnat-sjlj): libgnarl = $(notdir $(subst libgnat,libgnarl,$@)) +%/$(libgnat) %/$(libgnat-sjlj): % %/s-oscons.ads + $(MAKE) -C $(build_dir) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \ @@ -2515,7 +2545,7 @@ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ srcdir=$(fsrcdir) \ -f ../Makefile $(LIBGNAT_OBJS) - $(MAKE) -C $(RTSDIR) \ + $(MAKE) -C $(build_dir) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ ADA_INCLUDES="" \ @@ -2525,176 +2555,46 @@ srcdir=$(fsrcdir) \ -f ../Makefile \ $(GNATRTL_OBJS) - $(RM) $(RTSDIR)/libgna*$(soext) $(RTSDIR)/libgna*$(soext).1 - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ + $(RM) $(build_dir)/libgna*$(soext) $(build_dir)/libgna*$(soext).1 + cd $(build_dir); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \ $(PICFLAG_FOR_TARGET) \ - -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ + -o $(notdir $@).1 \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ - $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ + $(SO_OPTS)$(notdir $@).1 \ $(MISCLIB) -lm - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \ + cd $(build_dir); $(LN_S) $(notdir $@).1 $(notdir $@) + cd $(build_dir); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \ $(PICFLAG_FOR_TARGET) \ - -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ + -o $(libgnarl).1 \ $(GNATRTL_TASKING_OBJS) \ - $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \ + $(SO_OPTS)$(libgnarl).1 \ $(THREADSLIB) - cd $(RTSDIR); for lib in gnat gnarl; do \ - l=lib$${lib}$(hyphen)$(LIBRARY_VERSION)$(soext); \ - $(LN_S) $$l.1 $$l; \ - done -# Delete the object files, lest they be linked statically into the tools -# executables. Only the .ali, .a and .so files must remain. - rm -f $(RTSDIR)/*.o - $(CHMOD) a-wx $(RTSDIR)/*.ali + cd $(build_dir); $(LN_S) $(libgnarl).1 $(libgnarl) -gnatlib-shared-dual: - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib - $(RM) $(RTSDIR)/*.o $(RTSDIR)/*.ali - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib-shared-default +gnatlib-shared-dual: gnatlib-static-zcx gnatlib-static-sjlj gnatlib-shared-zcx -gnatlib-shared-dual-win32: - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ - PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib - $(RM) $(RTSDIR)/*.o $(RTSDIR)/*.ali - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib-shared-win32 - -# ??? we need to add the option to support auto-import of arrays/records to -# the GNATLIBFLAGS when this will be supported by GNAT. At this point we will -# use the gnatlib-shared-dual-win32 target to build the GNAT runtimes on -# Windows. -gnatlib-shared-win32: - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib - $(RM) $(RTSDIR)/libgna*$(soext) - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ - $(PICFLAG_FOR_TARGET) \ - -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ - $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \ - $(PICFLAG_FOR_TARGET) \ - -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(GNATRTL_TASKING_OBJS) \ - $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) - -gnatlib-shared-darwin: - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET) -fno-common" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib - $(RM) $(RTSDIR)/libgnat$(soext) $(RTSDIR)/libgnarl$(soext) - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \ - -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ - $(SO_OPTS) \ - -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(MISCLIB) - cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \ - | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \ - -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(GNATRTL_TASKING_OBJS) \ - $(SO_OPTS) \ - -Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) - cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - libgnat$(soext) - cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - libgnarl$(soext) - cd $(RTSDIR); dsymutil libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) - cd $(RTSDIR); dsymutil libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) - -gnatlib-shared-vms: - $(MAKE) $(FLAGS_TO_PASS) \ - GNATLIBFLAGS="$(GNATLIBFLAGS)" \ - GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ - MULTISUBDIR="$(MULTISUBDIR)" \ - THREAD_KIND="$(THREAD_KIND)" \ - gnatlib - $(RM) $(RTSDIR)/libgna*$(soext) - cd $(RTSDIR) && \ - ../../gnatsym -s SYMVEC_$$$$.opt \ - $(LIBGNAT_OBJS) $(GNATRTL_NONTASKING_OBJS) && \ - ../../xgcc -g -B../../ -shared -shared-libgcc \ - -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) libgnat.a \ - sys\$$library:trace.exe \ - --for-linker=/noinform \ - --for-linker=SYMVEC_$$$$.opt \ - --for-linker=gsmatch=equal,$(GSMATCH_VERSION) - cd $(RTSDIR) && \ - ../../gnatsym -s SYMVEC_$$$$.opt \ - $(GNATRTL_TASKING_OBJS) && \ - ../../xgcc -g -B../../ -shared -shared-libgcc \ - -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - libgnarl.a libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - sys\$$library:trace.exe \ - --for-linker=/noinform \ - --for-linker=SYMVEC_$$$$.opt \ - --for-linker=gsmatch=equal,$(GSMATCH_VERSION) - -gnatlib-shared: +gnatlib-shared-zcx: rts = $(subst gnatlib,rts,$@) +gnatlib-shared-zcx: gnatlib-sources-zcx/a-except.ads + if [ ! -d $(rts) ] ; then \ + cp -a gnatlib-sources-zcx $(rts); \ + $(MV) $(rts)/s.ads $(rts)/system.ads; \ + fi $(MAKE) $(FLAGS_TO_PASS) \ + EH_MECHANISM="-gcc" \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \ - $(GNATLIB_SHARED) + $(rts)/$(libgnat) -# When building a SJLJ runtime for VxWorks, in addition to forcing -# ZCX_By_default to False, we need to ensure that extra linker options -# are not passed to prevent the inclusion of useless objects and -# potential troubles from the presence of extra symbols and references -# in some configurations. The inhibition is performed by commenting -# the pragma instead of deleting the line, as the latter might result -# in getting multiple blank lines, hence a style check error, as a -# result. -gnatlib-sjlj: - $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="" \ - THREAD_KIND="$(THREAD_KIND)" ../stamp-gnatlib1-$(RTSDIR) - sed -e 's/ZCX_By_Default.*/ZCX_By_Default : constant Boolean := False;/' $(RTSDIR)/system.ads > $(RTSDIR)/s.ads - sed -e 's/\(pragma Linker.*crtbe.*\)/-- \1/' $(RTSDIR)/s.ads > $(RTSDIR)/s2.ads - $(RM) $(RTSDIR)/s.ads - $(MV) $(RTSDIR)/s2.ads $(RTSDIR)/system.ads +gnatlib-static-sjlj: rts = $(subst gnatlib,rts,$@) +gnatlib-static-sjlj: gnatlib-sources-sjlj/a-except.ads + if [ ! -d $(rts) ] ; then \ + cp -a gnatlib-sources-sjlj $(rts); \ + $(MV) $(rts)/s.ads $(rts)/system.ads; \ + fi $(MAKE) $(FLAGS_TO_PASS) \ EH_MECHANISM="" \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ @@ -2703,13 +2603,15 @@ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ - PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" gnatlib + PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \ + $(rts)/libgnat.a -gnatlib-zcx: - $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="-gcc" \ - THREAD_KIND="$(THREAD_KIND)" ../stamp-gnatlib1-$(RTSDIR) - sed -e 's/ZCX_By_Default.*/ZCX_By_Default : constant Boolean := True;/' $(RTSDIR)/system.ads > $(RTSDIR)/s.ads - $(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads +gnatlib-static-zcx: rts = $(subst gnatlib,rts,$@) +gnatlib-static-zcx: gnatlib-sources-zcx/a-except.ads + if [ ! -d $(rts) ] ; then \ + cp -a gnatlib-sources-zcx $(rts); \ + $(MV) $(rts)/s.ads $(rts)/system.ads; \ + fi $(MAKE) $(FLAGS_TO_PASS) \ EH_MECHANISM="-gcc" \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ @@ -2718,10 +2620,15 @@ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ MULTISUBDIR="$(MULTISUBDIR)" \ THREAD_KIND="$(THREAD_KIND)" \ - PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" gnatlib + PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \ + $(rts)/libgnat$(arext) ADA_INCLUDE_DIR = $(libsubdir)/adainclude ADA_RTL_OBJ_DIR = $(libsubdir)/adalib +ADA_NATIVE_INCLUDE_DIR = $(libsubdir)/rts-native/adainclude +ADA_NATIVE_RTL_OBJ_DIR = $(libsubdir)/rts-native/adalib +ADA_SJLJ_INCLUDE_DIR = $(libsubdir)/rts-sjlj/adainclude +ADA_SJLJ_RTL_OBJ_DIR = $(libsubdir)/rts-sjlj/adalib # Special flags Index: b/src/gnattools/Makefile.in =================================================================== --- a/src/gnattools/Makefile.in +++ b/src/gnattools/Makefile.in @@ -36,15 +36,16 @@ LN_S=@LN_S@ target_noncanonical=@target_noncanonical@ +RTS=../gcc/ada/rts-shared-zcx CFLAGS=-O2 -Wall ADA_CFLAGS=-O2 -gnatn -ADA_INCLUDES=-nostdinc -I- -I. -I../gcc/ada/rts -I../libgnatvsn -I../libgnatprj +ADA_INCLUDES=-nostdinc -I- -I. -I$(RTS) -I../libgnatvsn -I../libgnatprj LIB_VERSION=$(strip $(shell grep ' Library_Version :' \ ../libgnatvsn/gnatvsn.ads | sed -e 's/.*"\(.*\)".*/\1/')) -SHARED_ADA_LIBS := -L../gcc/ada/rts -lgnat-$(LIB_VERSION) +SHARED_ADA_LIBS := -L$(RTS) -lgnat-$(LIB_VERSION) SHARED_ADA_LIBS += -L../libgnatvsn -lgnatvsn SHARED_ADA_LIBS += -L../libgnatprj -lgnatprj -STATIC_ADA_LIBS := ../gcc/ada/rts/libgnat.a +STATIC_ADA_LIBS := ../gcc/ada/rts-static-zcx/libgnat.a STATIC_GCC_LIBS := ../gcc/libcommon-target.a ../gcc/libcommon.a ../libcpp/libcpp.a \ ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a @@ -118,6 +119,7 @@ .PHONY: gnattools gnattools-native gnattools-cross regnattools gnattools: @default_gnattools_target@ + (cd $(RTS); if [ -d obj ]; then mv obj/* .; rmdir obj; fi) BODIES := $(foreach f,$(OBJECTS),$(wildcard $(patsubst %.o,@srcdir@/../gcc/ada/%.adb,$(f)))) SPECS := $(foreach f,$(OBJECTS),$(wildcard $(patsubst %.o,@srcdir@/../gcc/ada/%.ads,$(f)))) @@ -133,9 +135,12 @@ rm -f $(word 1,$(subst <, ,$(PAIR)));\ $(LN_S) @srcdir@/../gcc/ada/$(word 2,$(subst <, ,$(PAIR))) \ $(word 1,$(subst <, ,$(PAIR)));) +# Move the RTS object files away lest they be linked statically into the +# tools. Only the .ali, .a and .so files must remain. + (cd $(RTS); mkdir obj; mv *.o obj; chmod a-wx *.ali) touch $@ -gnattools-native: ../gcc/ada/rts/libgnat-$(LIB_VERSION).so +gnattools-native: $(RTS)/libgnat-$(LIB_VERSION).so gnattools-native: ../libgnatvsn/libgnatvsn.so gnattools-native: stamp-gnattools-sources gnattools-native: $(TOOLS) @@ -151,7 +156,7 @@ $(GCC) -o $@ $^ \ ../libgnatprj/libgnatprj.a \ ../libgnatvsn/libgnatvsn.a \ - ../gcc/ada/rts/libgnat.a $(STATIC_GCC_LIBS) + $(STATIC_ADA_LIBS) $(STATIC_GCC_LIBS) gnatlink: $(GNATLINK_OBJS) b_gnatl.o $(GCC) -o $@ $^ $(SHARED_ADA_LIBS) $(STATIC_GCC_LIBS) Index: b/src/libgnatprj/Makefile.in =================================================================== --- a/src/libgnatprj/Makefile.in +++ b/src/libgnatprj/Makefile.in @@ -26,7 +26,8 @@ sed -e 's/.*"\(.*\)".*/\1/')) GCC:=../gcc/xgcc -B../gcc/ GPP := ../gcc/xg++ -B../gcc/ -LIBGNAT_JUST_BUILT := -nostdinc -I../gcc/ada/rts +RTS:=../gcc/ada/rts-shared-zcx +LIBGNAT_JUST_BUILT := -nostdinc -I$(RTS) LIBGNATVSN := -I../libgnatvsn CFLAGS := -g -O2 ADAFLAGS := -g -O2 -gnatn @@ -76,7 +77,7 @@ : # Make libgnatprj.so $(GCC) -o $@ -shared -fPIC -Wl,--soname,$@ -Wl,--no-allow-shlib-undefined \ $^ $(addprefix ../libiberty/pic/,$(LIBIBERTY_OBJECTS)) \ - -L../gcc/ada/rts -lgnat-$(LIB_VERSION) \ + -L$(RTS) -lgnat-$(LIB_VERSION) \ -L../libgnatvsn -lgnatvsn $(LN_S) -f libgnatprj.so.$(LIB_VERSION) libgnatprj.so chmod a=r obj-shared/*.ali Index: b/src/libgnatvsn/Makefile.in =================================================================== --- a/src/libgnatvsn/Makefile.in +++ b/src/libgnatvsn/Makefile.in @@ -25,7 +25,8 @@ @srcdir@/../gcc/ada/gnatvsn.ads | \ sed -e 's/.*"\(.*\)".*/\1/')) GCC:=../gcc/xgcc -B../gcc/ -LIBGNAT_JUST_BUILT := -nostdinc -I../gcc/ada/rts +RTS:=../gcc/ada/rts-shared-zcx +LIBGNAT_JUST_BUILT := -nostdinc -I$(RTS) CFLAGS := -g -O2 -gnatn BASEVER := $(shell cat @srcdir@/../gcc/BASE-VER) DEVPHASE := $(shell cat @srcdir@/../gcc/DEV-PHASE) @@ -66,7 +67,7 @@ libgnatvsn.so.$(LIB_VERSION): $(addprefix obj-shared/,$(OBJECTS)) : # Make libgnatvsn.so $(GCC) -o $@ -shared -fPIC -Wl,--soname,$@ $^ \ - -L../gcc/ada/rts -lgnat-$(LIB_VERSION) + -L$(RTS) -lgnat-$(LIB_VERSION) ln -s libgnatvsn.so.$(LIB_VERSION) libgnatvsn.so chmod a=r obj-shared/*.ali # Make the .ali files, but not the .o files, visible to the gnat tools. Index: b/src/gcc/ada/gcc-interface/Make-lang.in =================================================================== --- a/src/gcc/ada/gcc-interface/Make-lang.in +++ b/src/gcc/ada/gcc-interface/Make-lang.in @@ -85,7 +85,8 @@ "ADA_FOR_TARGET=$(ADA_FOR_TARGET)" \ "INSTALL=$(INSTALL)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ - "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" # List of Ada tools to build and install ADA_TOOLS=gnatbind gnatchop gnat gnatkr gnatlink gnatls gnatmake \