public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Gaius Mulley <gaius@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/modula-2] Bugfix for tiny modules importing from definition for "C". Date: Tue, 15 Nov 2022 14:11:51 +0000 (GMT) [thread overview] Message-ID: <20221115141151.0ECD1385828D@sourceware.org> (raw) https://gcc.gnu.org/g:0c1fe5e2aad3fedcd7b7543b51361fa1c85cd050 commit 0c1fe5e2aad3fedcd7b7543b51361fa1c85cd050 Author: Gaius Mulley <gaiusmod2@gmail.com> Date: Tue Nov 15 14:11:04 2022 +0000 Bugfix for tiny modules importing from definition for "C". If a tiny application module imports only from a definition for "C" the import graph will not join with the core modula-2 libraries. Thus if a range exception were to occur in the application the libraries might be uninitialized. This patch forces the application module to be initialized last. gcc/m2/ChangeLog: * gm2-libs/M2Dependent.mod (DisplayModuleInfo): Use variable count to display entry number. (CheckApplication) Check that the application is the last entry in the list and move the list head if appropriate. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com> Diff: --- gcc/m2/gm2-libs/M2Dependent.mod | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/gcc/m2/gm2-libs/M2Dependent.mod b/gcc/m2/gm2-libs/M2Dependent.mod index a37d6892406..bdfebcf51ef 100644 --- a/gcc/m2/gm2-libs/M2Dependent.mod +++ b/gcc/m2/gm2-libs/M2Dependent.mod @@ -461,14 +461,17 @@ END ResolveDependencies ; PROCEDURE DisplayModuleInfo (state: DependencyState; name: ARRAY OF CHAR) ; VAR - mptr: ModuleChain ; + mptr : ModuleChain ; + count: CARDINAL ; BEGIN IF Modules[state] # NIL THEN printf ("%s modules\n", ADR (name)) ; mptr := Modules[state] ; + count := 0 ; REPEAT - printf (" %s", mptr^.name) ; + printf (" %d %s", count, mptr^.name) ; + INC (count) ; IF mptr^.dependency.appl THEN printf (" application") @@ -574,6 +577,36 @@ BEGIN END ForceDependencies ; +(* + CheckApplication - check to see that the application is the last entry in the list. + This might happen if the application only imports FOR C modules. +*) + +PROCEDURE CheckApplication ; +VAR + mptr, + appl: ModuleChain ; +BEGIN + mptr := Modules[ordered] ; + IF mptr # NIL + THEN + appl := NIL ; + REPEAT + IF mptr^.dependency.appl + THEN + appl := mptr + ELSE + mptr := mptr^.next + END + UNTIL (appl # NIL) OR (mptr=Modules[ordered]) ; + IF appl # NIL + THEN + Modules[ordered] := appl^.next + END + END +END CheckApplication ; + + (* ConstructModules - resolve dependencies and then call each module constructor in turn. @@ -600,6 +633,9 @@ BEGIN ForceDependencies ; traceprintf (ForceTrace, "After user forcing ordering\n"); DumpModuleData (ForceTrace) ; + CheckApplication ; + traceprintf (ForceTrace, "After runtime forces application to the end\n"); + DumpModuleData (ForceTrace) ; IF Modules[ordered] = NIL THEN traceprintf2 (ModuleTrace, " module: %s has not registered itself using a global constructor\n", applicationmodule);
reply other threads:[~2022-11-15 14:11 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221115141151.0ECD1385828D@sourceware.org \ --to=gaius@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).