Hello all, Currently, what you get when you build GNAT on Cygwin is a hybrid port that is mostly based on the MinGW port. This doesn't work well when it does things (such as e.g. creating threads) "behind Cygwin's back" using the Win32 APIs (e.g. CreateThread) rather than by using Cygwin's POSIX interfaces (e.g. pthread_create).
I'm trying to build a fully POSIXified Cygwin port by going through the list of LIBGNAT_TARGET_PAIRS for the Windows port, examining all the *-mingw.ad[bs] files listed, and replacing them by references to the existing -linux or -posix versions, or new -cygwin versions in a couple of cases. I had hoped that this would be something I could do with a limited understanding of the Ada build system, but I must have done something wrong. Bootstrap fails during building gnatlib-shared-win32 at the final link stage, with a whole bunch of undefined references to the following functions: > ___gnat_adjust_n_cleanups_for > ___gnat_all_others_value > ___gnat_begin_handler > ___gnat_eid_for > ___gnat_end_handler > ___gnat_is_handled_by_others > ___gnat_others_value As far as I can tell these should come from $objdir/gcc/ada/rts/a-exexpr.adb (which is correctly softlinked to $srcdir/gcc/ada/a-exexpr-gcc.adb), but there is no a-exexpr.o file when the build fails, so make has thought it's not a dependency for some reason, and when I try to build it at the command line, I get the error message mentioned in the subject: > ad...@ubik /gnu/gcc/releases/4.3.4-1/gcc4-4.3.4-1/build/gcc > $ make ada/rts/a-exexpr.o > /gnu/gcc/releases/4.3.4-1/gcc4-4.3.4-1/build/./prev-gcc/xgcc > -B/gnu/gcc/releases /4.3.4-1/gcc4-4.3.4-1/build/./prev-gcc/ > -B/usr/i686-pc-cygwin/bin/ -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada > -I/gnu/gcc/releases/4.3.4-1/gcc4-4.3.4-1/src/gcc-4.3.4/gcc/ada > ada/rts/a-exexpr.adb -o ada/rts/a-exexpr.o > a-exexpr.adb:42:14: missing stub for subunit > make: *** [ada/rts/a-exexpr.o] Error 1 > > ad...@ubik /gnu/gcc/releases/4.3.4-1/gcc4-4.3.4-1/build/gcc > $ I couldn't find anything about this in the manual, and the comment in sem_ch10.adb where the error is generated is a bit inscrutable to me: > -- If the unit is a subunit whose parent has not been analyzed (which > -- indicates that the main unit is a subunit, either the current one or > -- one of its descendents) then the subunit is compiled as part of the > -- analysis of the parent, which we proceed to do. Basically this gets > -- handled from the top down and we don't want to do anything at this > -- level (i.e. this subunit will be handled on the way down from the > -- parent), so at this level we immediately return. If the subunit > -- ends up not analyzed, it means that the parent did not contain a > -- stub for it, or that there errors were dectected in some ancestor. I don't understand this, but it suggests to me that the error would occur if I had somehow inadvertently altered the position or relations of the a-exexpr module in some kind of dependency graph between the units. I'm not sure how the minor changes I made to the list of target pairs could have done this though, or why the build didn't even try and compile ada/rts/a-exexpr.o before it got to the link stage. I'm working on 4.3 branch to develop this, just because I happened to have a need for it there, but the details of changing LIBGNAT_TARGET_PAIRS should be the same on mainline even after the gcc-interface/ refactoring. (Will of course bring it up to head and submit it once I've got it working... who knows if it'll make stage 1 though.) I've attached a copy of my full working diff, but it's largely extraneous; the critical part is the section that sets the variables for the Cygwin target, which after my changes looks like: ---------------------------<snip>--------------------------- ifeq ($(strip $(filter-out cygwin% mingw% pe,$(osys))),) [ ... snip irrelevant part ... ] ifneq ($(strip $(filter cygwin%,$(osys))),) W32_TARG=cygwin LIBGNAT_TARGET_PAIRS = \ s-taspri.ads<s-taspri-posix.ads \ s-tasinf.adb<s-tasinf-linux.adb \ s-tasinf.ads<s-tasinf-linux.ads \ s-intman.adb<s-intman-posix.adb \ s-tpopsp.adb<s-tpopsp-posix-foreign.adb \ s-osprim.adb<s-osprim-posix.adb \ s-osinte.adb<s-osinte-posix.adb endif LIBGNAT_TARGET_PAIRS += \ a-excpol.adb<a-excpol-abort.adb \ a-numaux.adb<a-numaux-x86.adb \ a-numaux.ads<a-numaux-x86.ads \ s-gloloc.adb<s-gloloc-mingw.adb \ s-inmaop.adb<s-inmaop-dummy.adb \ g-bytswa.adb<g-bytswa-x86.adb \ g-stsifd.adb<g-stsifd-sockets.adb \ g-soccon.ads<g-soccon-$(W32_TARG).ads \ ifeq ($(strip $(filter-out rtx_w32 rtx_rtss,$(THREAD_KIND))),) [ ... snip irrelevant part ... ] else LIBGNAT_TARGET_PAIRS += \ a-exetim.adb<a-exetim-mingw.adb \ a-exetim.ads<a-exetim-mingw.ads \ a-intnam.ads<a-intnam-$(W32_TARG).ads \ s-osinte.ads<s-osinte-$(W32_TARG).ads \ s-taprop.adb<s-taprop-$(W32_TARG).adb \ system.ads<system-$(W32_TARG).ads EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o # Which install goal to use. INSTALL_GNATLIB_MAIN = unused-install-gnatlib INSTALL_GNATLIB_WIN32 = install-gnatlib # Mingw uses winsock-based sockets; cygwin uses POSIX sockets. ifneq ($(strip $(filter-out cygwin%,$(osys))),) [ ... snip irrelevant part ... ] endif # Set shared lib prefix (lib for mingw, cyg for cygwin) WIN32_SHARED_LIB_PREFIX=lib ifneq ($(strip $(filter cygwin%,$(osys))),) WIN32_SHARED_LIB_PREFIX=cyg endif # ??? This will be replaced by gnatlib-shared-dual-win32 when GNAT # auto-import support for array/record will be done. GNATLIB_SHARED = gnatlib-shared-win32 endif TOOLS_TARGET_PAIRS= \ mlib-tgt-specific.adb<mlib-tgt-$(W32_TARG).adb \ indepsw.adb<indepsw-$(W32_TARG).adb EH_MECHANISM=-gcc GMEM_LIB = gmemlib PREFIX_OBJS = $(PREFIX_REAL_OBJS) EXTRA_GNATTOOLS = ../../gnatdll$(exeext) EXTRA_GNATMAKE_OBJS = mdll.o mdll-utl.o mdll-fil.o soext = .dll LIBRARY_VERSION := $(LIB_VERSION) endif ---------------------------<snip>--------------------------- Can anyone offer me any advice to help me better understand what must have gone wrong for this error message to appear, which might give me a clue how to fix it? cheers, DaveK
--- origsrc/gcc-4.3.4/gcc/ada/Makefile.in 2009-02-28 17:30:26.000000000 +0000 +++ src/gcc-4.3.4/gcc/ada/Makefile.in 2009-09-08 02:48:54.843750000 +0100 @@ -198,6 +198,10 @@ TARGET_ADA_SRCS = # Type of tools build we are doing; default is not compiling tools. TOOLSCASE = +# Which install goal to use. +INSTALL_GNATLIB_MAIN = install-gnatlib +INSTALL_GNATLIB_WIN32 = unused-install-gnatlib + # End of variables for you to override. all: all.indirect @@ -273,7 +277,7 @@ ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdi $(CC) -c -x assembler $< $(OUTPUT_OPTION) .c.o: - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \ $(OUTPUT_OPTION) .adb.o: @@ -1298,24 +1302,42 @@ endif LIBRARY_VERSION := $(subst .,_,$(LIB_VERSION)) endif -ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),) +ifeq ($(strip $(filter-out cygwin% mingw% pe,$(osys))),) + + # Set target pair suffix for mingw or cygwin + W32_TARG=mingw LIBGNAT_TARGET_PAIRS = \ - a-dirval.adb<a-dirval-mingw.adb \ + a-dirval.adb<a-dirval-$(W32_TARG).adb \ + s-memory.adb<s-memory-$(W32_TARG).adb \ + s-taspri.ads<s-taspri-$(W32_TARG).ads \ + s-tasinf.adb<s-tasinf-$(W32_TARG).adb \ + s-tasinf.ads<s-tasinf-$(W32_TARG).ads \ + g-soliop.ads<g-soliop-$(W32_TARG).ads \ + s-intman.adb<s-intman-$(W32_TARG).adb \ + s-osprim.adb<s-osprim-$(W32_TARG).adb \ + s-interr.adb<s-interr-sigaction.adb + + ifneq ($(strip $(filter cygwin%,$(osys))),) + W32_TARG=cygwin + LIBGNAT_TARGET_PAIRS = \ + s-taspri.ads<s-taspri-posix.ads \ + s-tasinf.adb<s-tasinf-linux.adb \ + s-tasinf.ads<s-tasinf-linux.ads \ + s-intman.adb<s-intman-posix.adb \ + s-tpopsp.adb<s-tpopsp-posix-foreign.adb \ + s-osprim.adb<s-osprim-posix.adb \ + s-osinte.adb<s-osinte-posix.adb + endif + + LIBGNAT_TARGET_PAIRS += \ a-excpol.adb<a-excpol-abort.adb \ a-numaux.adb<a-numaux-x86.adb \ a-numaux.ads<a-numaux-x86.ads \ s-gloloc.adb<s-gloloc-mingw.adb \ s-inmaop.adb<s-inmaop-dummy.adb \ - s-memory.adb<s-memory-mingw.adb \ - s-taspri.ads<s-taspri-mingw.ads \ - s-tasinf.adb<s-tasinf-mingw.adb \ - s-tasinf.ads<s-tasinf-mingw.ads \ g-bytswa.adb<g-bytswa-x86.adb \ - g-socthi.ads<g-socthi-mingw.ads \ - g-socthi.adb<g-socthi-mingw.adb \ g-stsifd.adb<g-stsifd-sockets.adb \ - g-soccon.ads<g-soccon-mingw.ads \ - g-soliop.ads<g-soliop-mingw.ads + g-soccon.ads<g-soccon-$(W32_TARG).ads \ ifeq ($(strip $(filter-out rtx_w32 rtx_rtss,$(THREAD_KIND))),) LIBGNAT_TARGET_PAIRS += \ @@ -1331,18 +1353,31 @@ ifeq ($(strip $(filter-out cygwin32% min LIBGNAT_TARGET_PAIRS += \ a-exetim.adb<a-exetim-mingw.adb \ a-exetim.ads<a-exetim-mingw.ads \ - a-intnam.ads<a-intnam-mingw.ads \ - s-interr.adb<s-interr-sigaction.adb \ - s-intman.adb<s-intman-mingw.adb \ - s-osinte.ads<s-osinte-mingw.ads \ - s-osprim.adb<s-osprim-mingw.adb \ - s-taprop.adb<s-taprop-mingw.adb \ - system.ads<system-mingw.ads + a-intnam.ads<a-intnam-$(W32_TARG).ads \ + s-osinte.ads<s-osinte-$(W32_TARG).ads \ + s-taprop.adb<s-taprop-$(W32_TARG).adb \ + system.ads<system-$(W32_TARG).ads EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o - MISCLIB = -lwsock32 + # Which install goal to use. + INSTALL_GNATLIB_MAIN = unused-install-gnatlib + INSTALL_GNATLIB_WIN32 = install-gnatlib + + # Mingw uses winsock-based sockets; cygwin uses POSIX sockets. + ifneq ($(strip $(filter-out cygwin%,$(osys))),) + LIBGNAT_TARGET_PAIRS += \ + g-socthi.ads<g-socthi-$(W32_TARG).ads \ + g-socthi.adb<g-socthi-$(W32_TARG).adb + MISCLIB = -lwsock32 + endif + + # Set shared lib prefix (lib for mingw, cyg for cygwin) + WIN32_SHARED_LIB_PREFIX=lib + ifneq ($(strip $(filter cygwin%,$(osys))),) + WIN32_SHARED_LIB_PREFIX=cyg + endif # ??? This will be replaced by gnatlib-shared-dual-win32 when GNAT # auto-import support for array/record will be done. @@ -1350,9 +1385,10 @@ ifeq ($(strip $(filter-out cygwin32% min endif TOOLS_TARGET_PAIRS= \ - mlib-tgt-specific.adb<mlib-tgt-mingw.adb \ - indepsw.adb<indepsw-mingw.adb + mlib-tgt-specific.adb<mlib-tgt-$(W32_TARG).adb \ + indepsw.adb<indepsw-$(W32_TARG).adb + EH_MECHANISM=-gcc GMEM_LIB = gmemlib PREFIX_OBJS = $(PREFIX_REAL_OBJS) EXTRA_GNATTOOLS = ../../gnatdll$(exeext) @@ -1797,7 +1833,7 @@ gnatbl.o: gnatbl.c adaint.h true; \ fi -install-gnatlib: ../stamp-gnatlib +$(INSTALL_GNATLIB_MAIN): ../stamp-gnatlib # 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. @@ -1839,6 +1875,48 @@ install-gnatlib: ../stamp-gnatlib cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads +$(INSTALL_GNATLIB_WIN32): ../stamp-gnatlib +# 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. This is the win32 version. + -$(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 rts/*.ali; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ + done + -$(INSTALL_DATA) rts/g-trasym$(objext) $(DESTDIR)$(ADA_RTL_OBJ_DIR) + -cd rts; for file in *$(arext);do \ + $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ + $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \ + done + -$(foreach file, $(EXTRA_ADALIB_FILES), \ + $(INSTALL_DATA_DATE) rts/$(file) $(DESTDIR)$(ADA_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. We are win32 here. + for file in gnat gnarl; do \ + if [ -f rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) ]; then \ + $(INSTALL) rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \ + $(DESTDIR)$(bindir); \ + fi; \ + if [ -f rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(soext) ]; then \ + $(LN_S) $(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \ + $(DESTDIR)$(bindir)/lib$${file}$(soext); \ + fi; \ + done +# This copy must be done preserving the date on the original file. + for file in rts/*.ad?; do \ + $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \ + done + cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb + cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads + ../stamp-gnatlib2: $(RM) rts/s-*.ali $(RM) rts/s-*$(objext) @@ -1995,14 +2073,18 @@ gnatlib-shared-win32: gnatlib $(RM) rts/libgna*$(soext) cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ - -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -o $(WIN32_SHARED_LIB_PREFIX)gnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -Wl,--out-implib,libgnat$(soext)$(arext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ - $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) + $(SO_OPTS)$(WIN32_SHARED_LIB_PREFIX)gnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) \ + -Wl,--enable-auto-import cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ - -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -o $(WIN32_SHARED_LIB_PREFIX)gnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -Wl,--out-implib,libgnarl$(soext)$(arext) \ $(GNATRTL_TASKING_OBJS) \ - $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) + $(SO_OPTS)$(WIN32_SHARED_LIB_PREFIX)gnarl$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) \ + -L. $(THREADSLIB) -Wl,libgnat$(soext)$(arext) \ + -Wl,--enable-auto-import gnatlib-shared-darwin: $(MAKE) $(FLAGS_TO_PASS) \ @@ -2186,37 +2268,37 @@ raise.o : raise.c raise.h vx_stack_info.o : vx_stack_info.c gen-soccon: gen-soccon.c gsocket.h - $(CC) $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(CC) $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ -UIN_GCC -DTARGET=\"$(target_alias)\" \ $< $(OUTPUT_OPTION) cio.o : cio.c - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) init.o : init.c adaint.h raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) initialize.o : initialize.c raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) targext.o : targext.c - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \ $< $(OUTPUT_OPTION) # No optimization to compile this file as optimizations (-O1 or above) breaks # the SEH handling on Windows. The reasons are not clear. seh_init.o : seh_init.c raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) -O0 \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) -O0 \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) # Need to keep the frame pointer in this file to pop the stack properly on # some targets. tracebak.o : tracebak.c tb-alvms.c tb-alvxw.c tb-gcc.c - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ -fno-omit-frame-pointer $< $(OUTPUT_OPTION) # In GNU Make, ignore whether `stage*' exists.