diff options
-rw-r--r-- | gcc/m2/Make-lang.in | 23 | ||||
-rw-r--r-- | gcc/m2/gm2-compiler/M2GCCDeclare.def | 11 | ||||
-rw-r--r-- | gcc/m2/gm2-compiler/M2GCCDeclare.mod | 135 | ||||
-rw-r--r-- | gcc/m2/gm2-compiler/M2GenGCC.mod | 15 | ||||
-rw-r--r-- | gcc/m2/gm2-compiler/M2Quads.mod | 15 | ||||
-rw-r--r-- | gcc/m2/gm2-compiler/M2Scaffold.mod | 2 | ||||
-rw-r--r-- | gcc/m2/gm2-gcc/m2decl.cc | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs-iso/M2RTS.def | 1 | ||||
-rw-r--r-- | gcc/m2/gm2-libs-iso/M2RTS.mod | 2 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2Dependent.def | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2Dependent.mod | 58 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2LINK.def | 41 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2RTS.def | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2RTS.mod | 2 | ||||
-rw-r--r-- | libgm2/libm2pim/Makefile.am | 2 | ||||
-rw-r--r-- | libgm2/libm2pim/Makefile.in | 2 |
16 files changed, 73 insertions, 245 deletions
diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index 17a0b03..3fc691b6 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -516,13 +516,13 @@ cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev) m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \ - m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) m2/gm2-libs-boot/M2LINK.o + m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) -test -d $(@D) || $(mkinstalldirs) $(@D) @$(call LINK_PROGRESS,$(INDEX.m2),start) +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \ attribs.o \ $(GM2_LIBS) \ - $(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \ + $(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o \ $(BACKENDLIBS) $(LIBSTDCXX) -lm @$(call LINK_PROGRESS,$(INDEX.m2),end) @@ -530,14 +530,13 @@ m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \ $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \ $(GM2_LIBS_BOOT) $(MC_LIBS) \ m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \ - m2/gm2-libs-boot/M2LINK.o \ $(m2.prev) -test -d $(@D) || $(mkinstalldirs) $(@D) @$(call LINK_PROGRESS,$(INDEX.m2),start) +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-boot/m2flex.o \ attribs.o \ $(GM2_LIBS_BOOT) $(MC_LIBS) \ - m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \ + m2/gm2-gcc/rtegraph.o \ $(BACKEND) $(LIBS) $(BACKENDLIBS) @$(call LINK_PROGRESS,$(INDEX.m2),end) @@ -613,7 +612,6 @@ GM2-LIBS-BOOT-DEFS = \ Indexing.def \ M2Dependent.def \ M2EXCEPTION.def \ - M2LINK.def \ M2RTS.def \ NumberIO.def \ PushBackInput.def \ @@ -878,7 +876,6 @@ GM2-LIBS-DEFS = \ LegacyReal.def \ M2Dependent.def \ M2EXCEPTION.def \ - M2LINK.def \ M2RTS.def \ MathLib0.def \ MemUtils.def \ @@ -1352,23 +1349,23 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \ m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXX_FLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ + $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXX_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ + $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXX_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ + $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit -test -d $(@D) || $(mkinstalldirs) $(@D) unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.cc $(srcdir)/m2/init/mcinit - $(CXX) $(CXX_FLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ + $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h - $(CC) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc + $(CC) $(CFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc mcflex.c: $(srcdir)/m2/mc/mc.flex flex -t $< > $@ @@ -1404,10 +1401,6 @@ m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SR -test -d $(@D) || $(mkinstalldirs) $(@D) $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ -m2/gm2-libs-boot/M2LINK.o: $(srcdir)/m2/gm2-libs-ch/M2LINK.c m2/gm2-libs-boot/$(SRC_PREFIX)M2LINK.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ - m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.def b/gcc/m2/gm2-compiler/M2GCCDeclare.def index 2215b54..38ca33f 100644 --- a/gcc/m2/gm2-compiler/M2GCCDeclare.def +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.def @@ -26,7 +26,6 @@ DEFINITION MODULE M2GCCDeclare ; Author : Gaius Mulley System : UNIX (gm2) Date : Sat Jul 17 10:28:43 1999 - Last edit : Sat Jul 17 10:28:43 1999 Description: declares Modula-2 types to GCC, only declares a type once all subcomponents are known. *) @@ -40,7 +39,6 @@ EXPORT QUALIFIED FoldConstants, InitDeclarations, StartDeclareScope, EndDeclareScope, DeclareModuleVariables, IsProcedureGccNested, DeclareProcedure, PoisonSymbols, DeclareParameters, - DeclareM2linkGlobals, CompletelyResolved, MarkExported, PrintSym, ConstantKnownAndUsed, PutToBeSolvedByQuads, @@ -146,15 +144,6 @@ PROCEDURE DeclareModuleVariables (sym: CARDINAL) ; (* - DeclareM2linkGlobals - will create M2LINK.StaticInitialization - and M2LINK.ForcedModuleInitOrder providing - they have not already been created. -*) - -PROCEDURE DeclareM2linkGlobals (tokenno: CARDINAL) ; - - -(* IsProcedureGccNested - returns TRUE if procedure, sym, will be considered as nested by GCC. This will occur if either its outer defining scope diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.mod b/gcc/m2/gm2-compiler/M2GCCDeclare.mod index f6fb239..3b1fc18 100644 --- a/gcc/m2/gm2-compiler/M2GCCDeclare.mod +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.mod @@ -154,9 +154,9 @@ FROM m2linemap IMPORT location_t, BuiltinsLocation ; FROM m2decl IMPORT BuildIntegerConstant, BuildStringConstant, BuildCStringConstant, BuildStartFunctionDeclaration, BuildParameterDeclaration, BuildEndFunctionDeclaration, - DeclareKnownVariable, GetBitsPerBitset, BuildPtrToTypeString, - DeclareM2linkStaticInitialization, - DeclareM2linkForcedModuleInitOrder ; + DeclareKnownVariable, GetBitsPerBitset, BuildPtrToTypeString ; +(* DeclareM2linkStaticInitialization, + DeclareM2linkForcedModuleInitOrder ; *) FROM m2type IMPORT MarkFunctionReferenced, BuildStartRecord, BuildStartVarient, BuildStartFunctionType, BuildStartFieldVarient, BuildStartVarient, BuildStartType, BuildStartArrayType, @@ -205,14 +205,6 @@ CONST Progress = FALSE ; EnableSSA = FALSE ; -TYPE - M2LinkEntry = POINTER TO RECORD - var : CARDINAL ; - gcc : Tree ; - varname, - modname: Name ; - END ; - VAR ToBeSolvedByQuads, (* constants which must be solved *) (* by processing the quadruples. *) @@ -240,7 +232,6 @@ VAR EnumerationIndex : Index ; action : IsAction ; enumDeps : BOOLEAN ; - M2LinkIndex : Index ; (* Array of M2LinkEntry. *) PROCEDURE mystop ; BEGIN END mystop ; @@ -3170,9 +3161,9 @@ PROCEDURE DoVariableDeclaration (var, module: CARDINAL; name: ADDRESS; isTemporary, isGlobal: BOOLEAN; scope: Tree) ; VAR - type, initial: Tree ; - varType : CARDINAL ; - location : location_t ; + type : Tree ; + varType : CARDINAL ; + location: location_t ; BEGIN IF IsComponent (var) THEN @@ -3209,93 +3200,16 @@ BEGIN END ; location := TokenToLocation (GetDeclaredMod (var)) ; (* The M2LINK module global variables are a special case and have initializers. *) - initial := DetectM2LinkInitial (location, var, module) ; PreAddModGcc (var, DeclareKnownVariable (location, name, type, isExported, isImported, isTemporary, - isGlobal, scope, initial)) ; - IF initial # NIL - THEN - (* Remember special case has been created. *) - AddEntryM2Link (var, module, Mod2Gcc (var)) - END ; + isGlobal, scope, NIL)) ; WatchRemoveList (var, todolist) ; WatchIncludeList (var, fullydeclared) END DoVariableDeclaration ; (* - AddEntryM2Link - remember module_var has been created. -*) - -PROCEDURE AddEntryM2Link (var, module: CARDINAL; gcc: Tree) ; -VAR - entry: M2LinkEntry ; -BEGIN - IF M2LinkIndex = NIL - THEN - M2LinkIndex := InitIndex (1) - END ; - NEW (entry) ; - entry^.var := var ; - entry^.gcc := gcc ; - entry^.varname := GetSymName (var) ; - entry^.modname := GetSymName (module) ; - IncludeIndiceIntoIndex (M2LinkIndex, entry) -END AddEntryM2Link ; - - -(* - GetEntryM2Link - return the gcc tree matching varname modname. -*) - -PROCEDURE GetEntryM2Link (varname, modname: Name) : Tree ; -VAR - entry : M2LinkEntry ; - high, i: CARDINAL ; -BEGIN - IF M2LinkIndex # NIL - THEN - i := 1 ; - high := HighIndice (M2LinkIndex) ; - WHILE i <= high DO - entry := GetIndice (M2LinkIndex, i) ; - IF (entry^.varname = varname) AND (entry^.modname = modname) - THEN - RETURN entry^.gcc - END ; - INC (i) - END - END ; - RETURN NIL -END GetEntryM2Link ; - - -(* - DeclareM2linkGlobals - will create M2LINK.StaticInitialization - and M2LINK.ForcedModuleInitOrder providing - they have not already been created. -*) - -PROCEDURE DeclareM2linkGlobals (tokenno: CARDINAL) ; -VAR - m2link: Name ; -BEGIN - m2link := MakeKey ('M2LINK') ; - IF GetEntryM2Link (MakeKey ('StaticInitialization'), m2link) = NIL - THEN - Assert (DeclareM2linkStaticInitialization (TokenToLocation (tokenno), - VAL (INTEGER, ScaffoldStatic)) # NIL) - END ; - IF GetEntryM2Link (MakeKey ('ForcedModuleInitOrder'), m2link) = NIL - THEN - Assert (DeclareM2linkForcedModuleInitOrder (TokenToLocation (tokenno), - GetRuntimeModuleOverride ()) # NIL) - END ; -END DeclareM2linkGlobals ; - - -(* IsGlobal - is the variable not in a procedure scope. *) @@ -3344,28 +3258,6 @@ END DeclareVariable ; (* - DetectM2LinkInitial - -*) - -PROCEDURE DetectM2LinkInitial (location: location_t; variable, decl: CARDINAL) : Tree ; -BEGIN - IF (decl # NulSym) AND WholeProgram AND (GetSymName (decl) = MakeKey ('M2LINK')) - THEN - IF GetSymName (variable) = MakeKey ('StaticInitialization') - THEN - RETURN BuildIntegerConstant (VAL (INTEGER, ScaffoldStatic)) - ELSIF GetSymName (variable) = MakeKey ('ForcedModuleInitOrder') - THEN - RETURN BuildPtrToTypeString (location, - GetRuntimeModuleOverride (), - Mod2Gcc (GetSType (variable))) - END - END ; - RETURN NIL -END DetectM2LinkInitial ; - - -(* DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program. *) @@ -6295,16 +6187,6 @@ END ConstantKnownAndUsed ; (* - InitM2LinkModule - -*) - -PROCEDURE InitM2LinkModule ; -BEGIN - M2LinkIndex := NIL -END InitM2LinkModule ; - - -(* InitDeclarations - initializes default types and the source filename. *) @@ -6329,6 +6211,5 @@ BEGIN EnumerationIndex := InitIndex(1) ; IncludeElementIntoSet(WatchList, 8) ; HaveInitDefaultTypes := FALSE ; - recursionCaught := FALSE ; - InitM2LinkModule + recursionCaught := FALSE END M2GCCDeclare. diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod index caca8a3..445c68e 100644 --- a/gcc/m2/gm2-compiler/M2GenGCC.mod +++ b/gcc/m2/gm2-compiler/M2GenGCC.mod @@ -149,8 +149,7 @@ FROM M2GCCDeclare IMPORT WalkAction, CompletelyResolved, PoisonSymbols, GetTypeMin, GetTypeMax, IsProcedureGccNested, DeclareParameters, - ConstantKnownAndUsed, PrintSym, - DeclareM2linkGlobals ; + ConstantKnownAndUsed, PrintSym ; FROM M2Range IMPORT CodeRangeCheck, FoldRangeCheck, CodeErrorCheck, GetMinMax ; @@ -1163,17 +1162,7 @@ BEGIN GetModuleCtors (moduleSym, ctor, init, fini, dep) ; finishFunctionDecl (location, Mod2Gcc (fini)) ; BuildEndFunctionCode (location, Mod2Gcc (fini), - IsModuleWithinProcedure (moduleSym)) ; - IF ScaffoldMain OR (NOT cflag) - THEN - IF CompilingMainModule AND - (ScaffoldDynamic OR ScaffoldStatic OR ScaffoldMain) AND - (moduleSym = GetMainModule ()) - THEN - qprintf0 (" generating scaffold m2link information\n"); - DeclareM2linkGlobals (tokenpos) - END - END + IsModuleWithinProcedure (moduleSym)) END END CodeFinallyEnd ; diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index 3802b99..4dffb63 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -209,7 +209,8 @@ FROM M2Options IMPORT NilChecking, GenerateLineDebug, Exceptions, Profiling, Coding, Optimizing, ScaffoldDynamic, ScaffoldStatic, cflag, - ScaffoldMain, SharedFlag, WholeProgram ; + ScaffoldMain, SharedFlag, WholeProgram, + GetRuntimeModuleOverride ; FROM M2Pass IMPORT IsPassCodeGeneration, IsNoPass ; @@ -2531,7 +2532,8 @@ BEGIN (* int _M2_init (int argc, char *argv[], char *envp[]) { - M2RTS_ConstructModules (module_name, libname, argc, argv, envp); + M2RTS_ConstructModules (module_name, libname, + overrideliborder, argc, argv, envp); } *) PushT (initFunction) ; BuildProcedureStart ; @@ -2566,10 +2568,17 @@ BEGIN PushT(1) ; BuildAdrFunction ; + PushTF(Adr, Address) ; + PushTtok (MakeConstLitString (tok, + makekey (GetRuntimeModuleOverride ())), + tok) ; + PushT(1) ; + BuildAdrFunction ; + PushTtok (SafeRequestSym (tok, MakeKey ("argc")), tok) ; PushTtok (SafeRequestSym (tok, MakeKey ("argv")), tok) ; PushTtok (SafeRequestSym (tok, MakeKey ("envp")), tok) ; - PushT (5) ; + PushT (6) ; BuildProcedureCall (tok) ; END ELSIF ScaffoldStatic diff --git a/gcc/m2/gm2-compiler/M2Scaffold.mod b/gcc/m2/gm2-compiler/M2Scaffold.mod index c0f0efd..706db05 100644 --- a/gcc/m2/gm2-compiler/M2Scaffold.mod +++ b/gcc/m2/gm2-compiler/M2Scaffold.mod @@ -87,7 +87,7 @@ VAR static void _M2_init (int argc, char *argv[], char *envp[]) { - M2RTS_ConstructModules (module_name, libname, argc, argv, envp); + M2RTS_ConstructModules (module_name, libname, overrideliborder, argc, argv, envp); } diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc index e44bb35..4fb646e 100644 --- a/gcc/m2/gm2-gcc/m2decl.cc +++ b/gcc/m2/gm2-gcc/m2decl.cc @@ -40,7 +40,7 @@ extern GTY (()) tree current_function_decl; static GTY (()) tree param_type_list; static GTY (()) tree param_list = NULL_TREE; /* Ready for the next time we call/define a function. */ - +#if 0 tree m2decl_DeclareM2linkStaticInitialization (location_t location, int ScaffoldStatic) @@ -71,6 +71,7 @@ m2decl_DeclareM2linkForcedModuleInitOrder (location_t location, m2block_popGlobalScope (); return forced_order; } +#endif /* DeclareKnownVariable declares a variable to GCC. */ diff --git a/gcc/m2/gm2-libs-iso/M2RTS.def b/gcc/m2/gm2-libs-iso/M2RTS.def index ee12e6f..4fd6c9f 100644 --- a/gcc/m2/gm2-libs-iso/M2RTS.def +++ b/gcc/m2/gm2-libs-iso/M2RTS.def @@ -34,6 +34,7 @@ TYPE PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS; diff --git a/gcc/m2/gm2-libs-iso/M2RTS.mod b/gcc/m2/gm2-libs-iso/M2RTS.mod index 958744d..42e5c32 100644 --- a/gcc/m2/gm2-libs-iso/M2RTS.mod +++ b/gcc/m2/gm2-libs-iso/M2RTS.mod @@ -72,9 +72,11 @@ VAR *) PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; BEGIN M2Dependent.ConstructModules (applicationmodule, libname, + overrideliborder, argc, argv, envp) END ConstructModules ; diff --git a/gcc/m2/gm2-libs/M2Dependent.def b/gcc/m2/gm2-libs/M2Dependent.def index 4b77a07..0044925 100644 --- a/gcc/m2/gm2-libs/M2Dependent.def +++ b/gcc/m2/gm2-libs/M2Dependent.def @@ -33,7 +33,8 @@ TYPE ArgCVEnvP = PROCEDURE (INTEGER, ADDRESS, ADDRESS) ; -PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; +PROCEDURE ConstructModules (applicationmodule, libname, + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS; diff --git a/gcc/m2/gm2-libs/M2Dependent.mod b/gcc/m2/gm2-libs/M2Dependent.mod index cc7e9cf..d3d2c50 100644 --- a/gcc/m2/gm2-libs/M2Dependent.mod +++ b/gcc/m2/gm2-libs/M2Dependent.mod @@ -29,7 +29,7 @@ IMPLEMENTATION MODULE M2Dependent ; FROM libc IMPORT abort, exit, write, getenv, printf, snprintf, strncpy ; (* FROM Builtins IMPORT strncmp, strcmp ; not available during bootstrap. *) -FROM M2LINK IMPORT ForcedModuleInitOrder, StaticInitialization, PtrToChar ; +(* FROM M2LINK IMPORT ForcedModuleInitOrder, StaticInitialization, PtrToChar ; *) FROM ASCII IMPORT nul, nl ; FROM SYSTEM IMPORT ADR, SIZE ; FROM Storage IMPORT ALLOCATE ; @@ -39,6 +39,8 @@ IMPORT M2RTS ; TYPE + PtrToChar = POINTER TO CHAR ; + DependencyState = (unregistered, unordered, started, ordered, user) ; DependencyList = RECORD @@ -62,7 +64,8 @@ TYPE END ; VAR - Modules : ARRAY DependencyState OF ModuleChain ; + Modules : ARRAY DependencyState OF ModuleChain ; + DynamicInitialization, Initialized, WarningTrace, ModuleTrace, @@ -70,7 +73,7 @@ VAR DependencyTrace, PreTrace, PostTrace, - ForceTrace : BOOLEAN ; + ForceTrace : BOOLEAN ; (* @@ -455,18 +458,15 @@ END ResolveDependant ; (* RequestDependant - used to specify that modulename is dependant upon module dependantmodule. It only takes effect - if we are not using StaticInitialization. + if we are using DynamicInitialization. *) PROCEDURE RequestDependant (modulename, libname, dependantmodule, dependantlibname: ADDRESS) ; BEGIN CheckInitialized ; - IF NOT StaticInitialization - THEN - PerformRequestDependant (modulename, libname, - dependantmodule, dependantlibname) - END + PerformRequestDependant (modulename, libname, + dependantmodule, dependantlibname) END RequestDependant ; @@ -676,7 +676,7 @@ END ForceModule ; the dynamic ordering with the preference. *) -PROCEDURE ForceDependencies ; +PROCEDURE ForceDependencies (overrideliborder: ADDRESS) ; VAR len, modlen, @@ -685,10 +685,10 @@ VAR libname, pc, start: PtrToChar ; BEGIN - IF ForcedModuleInitOrder # NIL + IF overrideliborder # NIL THEN - traceprintf2 (ForceTrace, "user forcing order: %s\n", ForcedModuleInitOrder) ; - pc := ForcedModuleInitOrder ; + traceprintf2 (ForceTrace, "user forcing order: %s\n", overrideliborder) ; + pc := overrideliborder ; start := pc ; len := 0 ; modname := NIL ; @@ -762,13 +762,15 @@ END CheckApplication ; module constructor in turn. *) -PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; +PROCEDURE ConstructModules (applicationmodule, libname, + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; VAR mptr: ModuleChain ; nulp: ArgCVEnvP ; BEGIN CheckInitialized ; + DynamicInitialization := TRUE ; (* This procedure is only called if we desire dynamic initialization. *) traceprintf3 (ModuleTrace, "application module: %s [%s]\n", applicationmodule, libname); mptr := LookupModule (unordered, applicationmodule, libname) ; @@ -781,7 +783,7 @@ BEGIN ResolveDependencies (applicationmodule, libname) ; traceprintf (PreTrace, "Post resolving dependents\n"); DumpModuleData (PostTrace) ; - ForceDependencies ; + ForceDependencies (overrideliborder) ; traceprintf (ForceTrace, "After user forcing ordering\n"); DumpModuleData (ForceTrace) ; CheckApplication ; @@ -885,20 +887,17 @@ VAR mptr: ModuleChain ; BEGIN CheckInitialized ; - IF NOT StaticInitialization + mptr := LookupModule (unordered, modulename, libname) ; + IF mptr = NIL THEN - mptr := LookupModule (unordered, modulename, libname) ; - IF mptr = NIL - THEN - traceprintf3 (ModuleTrace, "module: %s [%s] registering", - modulename, libname); - moveTo (unordered, - CreateModule (modulename, libname, init, fini, dependencies)) ; - traceprintf (ModuleTrace, "\n") ; - ELSE - warning3 ("module: %s [%s] (ignoring duplicate registration)\n", - modulename, libname) - END + traceprintf3 (ModuleTrace, "module: %s [%s] registering", + modulename, libname); + moveTo (unordered, + CreateModule (modulename, libname, init, fini, dependencies)) ; + traceprintf (ModuleTrace, "\n") ; + ELSE + warning3 ("module: %s [%s] (ignoring duplicate registration)\n", + modulename, libname) END END RegisterModule ; @@ -1001,7 +1000,8 @@ BEGIN SetupDebugFlags ; FOR state := MIN (DependencyState) TO MAX (DependencyState) DO Modules[state] := NIL - END + END ; + DynamicInitialization := FALSE END Init ; diff --git a/gcc/m2/gm2-libs/M2LINK.def b/gcc/m2/gm2-libs/M2LINK.def deleted file mode 100644 index b0ef0b6..0000000 --- a/gcc/m2/gm2-libs/M2LINK.def +++ /dev/null @@ -1,41 +0,0 @@ -(* M2LINK.def defines the linking mode used in Modula-2. - -Copyright (C) 2022-2023 Free Software Foundation, Inc. -Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. - -This file is part of GNU Modula-2. - -GNU Modula-2 is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GNU Modula-2 is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -<http://www.gnu.org/licenses/>. *) - -DEFINITION MODULE FOR "C" M2LINK ; - - -TYPE - PtrToChar = POINTER TO CHAR ; - -(* These variables are set by the compiler in the program module - according to linking command line options. *) - -VAR - ForcedModuleInitOrder: PtrToChar ; - StaticInitialization : BOOLEAN ; - - -END M2LINK. diff --git a/gcc/m2/gm2-libs/M2RTS.def b/gcc/m2/gm2-libs/M2RTS.def index 2b84c8c..7a859f8 100644 --- a/gcc/m2/gm2-libs/M2RTS.def +++ b/gcc/m2/gm2-libs/M2RTS.def @@ -33,7 +33,8 @@ TYPE ArgCVEnvP = PROCEDURE (INTEGER, ADDRESS, ADDRESS) ; -PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; +PROCEDURE ConstructModules (applicationmodule, libname, + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; PROCEDURE DeconstructModules (applicationmodule, libname: ADDRESS; diff --git a/gcc/m2/gm2-libs/M2RTS.mod b/gcc/m2/gm2-libs/M2RTS.mod index f941a32..dec1d5f 100644 --- a/gcc/m2/gm2-libs/M2RTS.mod +++ b/gcc/m2/gm2-libs/M2RTS.mod @@ -71,9 +71,11 @@ VAR *) PROCEDURE ConstructModules (applicationmodule, libname: ADDRESS; + overrideliborder: ADDRESS; argc: INTEGER; argv, envp: ADDRESS) ; BEGIN M2Dependent.ConstructModules (applicationmodule, libname, + overrideliborder, argc, argv, envp) END ConstructModules ; diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am index eae14fa..5304268 100644 --- a/libgm2/libm2pim/Makefile.am +++ b/libgm2/libm2pim/Makefile.am @@ -136,7 +136,7 @@ M2DEFS = Args.def ASCII.def \ LegacyReal.def libc.def \ libm.def LMathLib0.def \ M2Dependent.def \ - M2EXCEPTION.def M2LINK.def \ + M2EXCEPTION.def \ M2RTS.def \ MathLib0.def MemUtils.def \ NumberIO.def PushBackInput.def \ diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in index ec81103..b77a628 100644 --- a/libgm2/libm2pim/Makefile.in +++ b/libgm2/libm2pim/Makefile.in @@ -504,7 +504,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_PIMLIB_TRUE@ LegacyReal.def libc.def \ @BUILD_PIMLIB_TRUE@ libm.def LMathLib0.def \ @BUILD_PIMLIB_TRUE@ M2Dependent.def \ -@BUILD_PIMLIB_TRUE@ M2EXCEPTION.def M2LINK.def \ +@BUILD_PIMLIB_TRUE@ M2EXCEPTION.def \ @BUILD_PIMLIB_TRUE@ M2RTS.def \ @BUILD_PIMLIB_TRUE@ MathLib0.def MemUtils.def \ @BUILD_PIMLIB_TRUE@ NumberIO.def PushBackInput.def \ |