diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index ad21b208f09be1d95a9ed71cd73664987f77bc02..b34db0d91563070e956ad95e1d3d5729cc8c2ae0 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -455,7 +455,7 @@ MC=m2/boot-bin/mc$(exeext) $(MC_ARGS) MC_LIBS=m2/mc-boot-ch/Glibc.o m2/mc-boot-ch/Gmcrts.o M2LINK=m2/boot-bin/mklink$(exeext) -GM2_O= +GM2_O=-O0 GM2_O_S3=-O GM2_OS=-Os GM2_G=-g -fm2-g @@ -505,7 +505,7 @@ GM2_C_OBJS = m2/gm2-lang.o \ m2/gm2-gcc/m2misc.o \ m2/gm2-gcc/init.o GM2_LIBS = m2/gm2-compiler/gm2.a \ - ../$(target_subdir)/libgm2/libm2pim/.libs/libm2pim.a m2/gm2-libs-boot/choosetemp.o + m2/gm2-libs/libgm2.a \ GM2_LIBS_BOOT = m2/gm2-compiler-boot/gm2.a \ m2/gm2-libs-boot/libgm2.a \ @@ -1138,6 +1138,11 @@ BUILD-COMPILER-BOOT = $(BUILD-COMPILER-BOOT-H) \ BUILD-BOOT-H = m2/boot-bin/mc$(exeext) \ $(BUILD-LIBS-BOOT-H) $(BUILD-COMPILER-BOOT-H) $(TARGET_H) $(PLUGIN_HEADERS) +BUILD-LIBS = $(BUILD-LIBS-BOOT-H) \ + $(GM2-LIBS-MODS:%.mod=m2/gm2-libs/%.o) \ + $(GM2-LIBS-CC:%.cc=m2/gm2-libs/%.o) \ + $(GM2-LIBS-C:%.c=m2/gm2-libs/%.o) + # Core library definition modules used by the modula-2 to C++ translator. MC-LIB-DEFS = \ @@ -1595,6 +1600,29 @@ m2/gm2-compiler/gm2.a: build-compiler gm2$(exeext) $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler/%.o) $(RANLIB) $@ +m2/gm2-libs/libgm2.a: build-compiler gm2$(exeext) $(BUILD-LIBS) + -test -d $(@D) || $(mkinstalldirs) $(@D) + $(AR) cr $@ $(GM2-LIBS-MODS:%.mod=m2/gm2-libs/%.o) \ + $(GM2-LIBS-CC:%.cc=m2/gm2-libs/%.o) \ + $(GM2-LIBS-C:%.c=m2/gm2-libs/%.o) + $(RANLIB) $@ + +m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H) + -test -d $(@D) || $(mkinstalldirs) $(@D) + $(GM2_1) -c $(GM2_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $< -o $@ + +m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.c m2/gm2-libs/gm2-libs-host.h + -test -d $(@D) || $(mkinstalldirs) $(@D) + $(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + +m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.cc m2/gm2-libs/gm2-libs-host.h + -test -d $(@D) || $(mkinstalldirs) $(@D) + $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + +m2/gm2-libs/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h + -test -d $(@D) || $(mkinstalldirs) $(@D) + $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ + m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT) -test -d $(@D) || $(mkinstalldirs) $(@D) $(AR) cr $@ $(GM2-LIBS-BOOT-MODS:%.mod=m2/gm2-libs-boot/%.o) \ diff --git a/gcc/m2/gm2-compiler/M2ColorString.mod b/gcc/m2/gm2-compiler/M2ColorString.mod index f0ba7966b02871d46afcc87846275f1686830727..ec44b8607b00af3278466e28298609378a24936f 100644 --- a/gcc/m2/gm2-compiler/M2ColorString.mod +++ b/gcc/m2/gm2-compiler/M2ColorString.mod @@ -27,6 +27,7 @@ FROM DynamicStrings IMPORT InitString, InitStringCharStar, Dup, char, Length, Mult ; FROM StrLib IMPORT StrLen ; FROM libc IMPORT printf ; +FROM SYSTEM IMPORT ADR ; VAR @@ -57,7 +58,7 @@ PROCEDURE append (s: String; name: ARRAY OF CHAR) : String ; VAR c: String ; BEGIN - c := InitStringCharStar (colorize_start (EnableColor, name, StrLen (name))) ; + c := InitStringCharStar (colorize_start (EnableColor, ADR (name), StrLen (name))) ; s := ConCat (s, c) ; c := KillString (c) ; RETURN s diff --git a/gcc/m2/gm2-compiler/M2Comp.mod b/gcc/m2/gm2-compiler/M2Comp.mod index a2a7797397d16d146ceea6fb1fc93f3df24003fd..e33363e9f834d9b98b8a336c45a7d8b1c34a3b3b 100644 --- a/gcc/m2/gm2-compiler/M2Comp.mod +++ b/gcc/m2/gm2-compiler/M2Comp.mod @@ -319,9 +319,9 @@ BEGIN ELSE ModuleType := Program END ; - IF (Main=Sym) OR NeedToParseImplementation(Sym) + IF (Main=Sym) OR NeedToParseImplementation (Sym) THEN - (* only need to read implementation module if hidden types are declared or it is the main module *) + (* Only need to read implementation module if hidden types are declared or it is the main module *) LibName := NIL ; IF Main=Sym THEN @@ -333,13 +333,16 @@ BEGIN THEN FileName := PreprocessModule (FileName, FALSE) ; PutLibName (Sym, makekey (string (LibName))) + ELSE + qprintf1 (' Module %-20s : implementation source file not found\n', SymName) END END ; + IF FileName#NIL THEN IF OpenSource (AssociateModule (Dup (FileName), Sym)) THEN - IF NOT P0SyntaxCheck.CompilationUnit() + IF NOT P0SyntaxCheck.CompilationUnit () THEN WriteFormat0 ('compilation failed') ; CloseSource ; @@ -356,9 +359,9 @@ BEGIN ELSE (* It is quite legitimate to implement a module in C (and pretend it was a M2 implementation) providing that it is not the main program module and the - definition module do not declare a hidden type when -fextended-opaque + definition module does not declare a hidden type when -fextended-opaque is used. *) - IF (NOT WholeProgram) OR (Sym=Main) OR IsHiddenTypeDeclared(Sym) + IF (NOT WholeProgram) OR (Sym=Main) OR IsHiddenTypeDeclared (Sym) THEN (* Unrecoverable error. *) MetaErrorString1 (Sprintf1 (InitString ('file {%%1EUAF%s} containing module {%%1a} cannot be found'), diff --git a/gcc/m2/gm2-libs-ch/cgetopt.c b/gcc/m2/gm2-libs-ch/cgetopt.c index d6b40b183b439121fdc73f6d002e5fd95a849c43..017fe91ad95df1c8e9d3c3919628a9aeb473acf9 100644 --- a/gcc/m2/gm2-libs-ch/cgetopt.c +++ b/gcc/m2/gm2-libs-ch/cgetopt.c @@ -26,7 +26,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "config.h" #include "system.h" -#include "ansi-decl.h" +#include <getopt.h> +// #include "ansi-decl.h" #ifdef __cplusplus @@ -60,7 +61,7 @@ int cgetopt_cgetopt_long (int argc, char *argv[], char *optstring, const struct option *longopts, int *longindex) { - int r = cgetopt_long (argc, argv, optstring, longopts, longindex); + int r = getopt_long (argc, argv, optstring, longopts, longindex); cgetopt_optarg = optarg; cgetopt_optind = optind; @@ -75,7 +76,7 @@ int cgetopt_cgetopt_long_only (int argc, char *argv[], char *optstring, const struct option *longopts, int *longindex) { - int r = cgetopt_long_only (argc, argv, optstring, longopts, longindex); + int r = getopt_long_only (argc, argv, optstring, longopts, longindex); cgetopt_optarg = optarg; cgetopt_optind = optind; diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc index 8b4010838ec57044fc2aa574636e2bb8b09377da..cd7ae808d98750a025e0882f4065815ae9ab02d2 100644 --- a/gcc/m2/gm2spec.cc +++ b/gcc/m2/gm2spec.cc @@ -451,7 +451,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, int need_math = (MATH_LIBRARY[0] != '\0'); /* 1 if we should add -lpthread to the command-line. - FIXME: the default should be a configuration choice. */ + FIXME: the default should be a configuration choice. */ int need_pthread = 1; /* True if we saw -static. */ @@ -533,7 +533,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, break; case OPT_fmod_: module_extension = xstrdup (arg); - args[i] |= SKIPOPT; /* We will add the option if it is needed. */ #if defined(DEBUG_ARG) printf ("seen -fmod=%s\n", module_extension); #endif @@ -701,7 +700,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, printf ("modula-2 source file detected: %s\n", source_file); #endif args[i] |= M2SOURCE; - // args[i] = 0; } } }