]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove m2 front end linking support.
authorGaius Mulley <gaius.mulley@southwales.ac.uk>
Mon, 30 May 2022 20:05:35 +0000 (21:05 +0100)
committerGaius Mulley <gaius.mulley@southwales.ac.uk>
Mon, 30 May 2022 20:05:35 +0000 (21:05 +0100)
2022-05-30  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

All m2 linking assistance by the Modula-2 front end is disabled.
cc1gm2 handles the -c option but currently does nothing with the option.
New gcc/testsuite/gm2/link/externalscaffold added to check the compiler
can link trivial application against a hand built scaffold.

gcc/testsuite/gm2/ChangeLog:

* link/externalscaffold: (New regression test).  Manual linking
test using external scaffold.

gcc/m2/ChangeLog:

* gm2-compiler/M2Options.def (cflag): New boolean.
(Setc) New procedure.  (Getc) New procedure function.
* gm2-compiler/M2Options.mod (Setc): New procedure.
(Getc) New procedure function.  Initialize cflag to
FALSE.
* gm2-gcc/m2options.h (Setc): New external function.
(Getc) New external function.
* gm2-lang.cc: Handle OPT_c and call M2Options_Setc.
* lang-specs.h: Remove all link rules for m2.
* lang.opt: Allow m2 to process the -c option.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
12 files changed:
gcc/m2/ChangeLog
gcc/m2/gm2-compiler/M2Options.def
gcc/m2/gm2-compiler/M2Options.mod
gcc/m2/gm2-gcc/m2options.h
gcc/m2/gm2-lang.cc
gcc/m2/lang-specs.h
gcc/m2/lang.opt
gcc/m2/m2-link-support.h
gcc/testsuite/gm2/ChangeLog
gcc/testsuite/gm2/link/externalscaffold/pass/hello.mod [new file with mode: 0644]
gcc/testsuite/gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp [new file with mode: 0644]
gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c [new file with mode: 0644]

index 52e951fafaa1827827037cd840d1ca7899191866..5ebbc2a941b5dc828a7c272cc1579cc830143f2e 100644 (file)
@@ -1,3 +1,17 @@
+2022-05-30   Gaius Mulley   <gaius.mulley@southwales.ac.uk>
+
+       * gm2-compiler/M2Options.def (cflag): New boolean.
+       (Setc) New procedure.  (Getc) New procedure function.
+       * gm2-compiler/M2Options.mod (Setc): New procedure.
+       (Getc) New procedure function.  Initialize cflag to
+       FALSE.
+       * gm2-gcc/m2options.h (Setc): New external function.
+       (Getc) New external function.
+       * gm2-lang.cc: Handle OPT_c and call M2Options_Setc.
+       * lang-specs.h: Remove all link rules for m2.
+       * lang.opt: Allow m2 to process the -c option.
+       * All m2 linking is disabled.
+
 2022-05-20   Gaius Mulley   <gaius.mulley@southwales.ac.uk>
 
        * m2pp.cc: (Renamed from m2pp.c).  Comments tidied up.
index 5e324e414c9bdb2630875455dd6924fcd3994b4f..f134c43a0dbf54fcd1558f79a37a3a5305fe8703 100644 (file)
@@ -52,6 +52,7 @@ EXPORT QUALIFIED SetReturnCheck, SetNilCheck, SetCaseCheck,
                 SetWholeValueCheck, GetWholeValueCheck,
                  SetLowerCaseKeywords,
                  SetIndex, SetRange, SetWholeDiv, SetStrictTypeChecking,
+                 Setc, Getc,
 
                  Iso, Pim, Pim2, Pim3, Pim4,
                  PositiveModFloorDiv,
@@ -86,6 +87,7 @@ EXPORT QUALIFIED SetReturnCheck, SetNilCheck, SetCaseCheck,
 
 
 VAR
+   cflag,                        (* -c flag present?                         *)
    Iso,                          (* -fiso use ISO SYSTEM.def                 *)
    Pim,                          (* -fpim use PIM [234] SYSTEM.def           *)
    Pim2,                         (* -fpim2 use strict rules.                 *)
@@ -163,6 +165,20 @@ VAR
 PROCEDURE DisplayVersion (mustExit: BOOLEAN) ;
 
 
+(*
+   Setc - set the cflag (compile only flag -c) to value.
+*)
+
+PROCEDURE Setc (value: BOOLEAN) ;
+
+
+(*
+   Getc - get the cflag (compile only flag -c).
+*)
+
+PROCEDURE Getc () : BOOLEAN ;
+
+
 (*
    SetWholeProgram - sets the WholeProgram flag (-fwhole-program).
 *)
index ed606cfeda149651efad390121801f7f9e47e7dc..510742c3f2a83b273d7c416ed438b26abe225f32 100644 (file)
@@ -381,6 +381,26 @@ BEGIN
 END GetCpp ;
 
 
+(*
+   Setc - set the cflag (compile only flag -c) to value.
+*)
+
+PROCEDURE Setc (value: BOOLEAN) ;
+BEGIN
+   cflag := value
+END Setc ;
+
+
+(*
+   Getc - get the cflag (compile only flag -c).
+*)
+
+PROCEDURE Getc () : BOOLEAN ;
+BEGIN
+   RETURN cflag
+END Getc ;
+
+
 (*
    SetM2g - returns TRUE if the -fm2-g flags was used.
 *)
@@ -1016,6 +1036,7 @@ END SetSaveTempsDir ;
 
 
 BEGIN
+   cflag                        := FALSE ;  (* -c.  *)
    CppArgs                      := InitString ('') ;
    CppProgram                   := InitString ('') ;
    Pim                          :=  TRUE ;
index b4b9961579b59724ba7d73ee386d79c2738bbd50..5a9b1db213933c32822d1cd761be58f75e7a4a05 100644 (file)
@@ -60,6 +60,9 @@ EXTERN int M2Options_GetPositiveModFloor (void);
 EXTERN int M2Options_GetFloatValueCheck (void);
 EXTERN int M2Options_GetWholeValueCheck (void);
 
+EXTERN void M2Options_Setc (int value);
+EXTERN int M2Options_Getc (void);
+
 EXTERN void M2Options_SetAutoInit (int value);
 EXTERN void M2Options_SetPositiveModFloor (int value);
 EXTERN void M2Options_SetNilCheck (int value);
index a71b45788a0a0fc6f14cc1a56834d1c92d94be04..45781eaade9b19e64df4df9dab2dcf52ab5c6310 100644 (file)
@@ -205,7 +205,9 @@ gm2_langhook_handle_option (
 
   switch (code)
     {
-
+    case OPT_c:
+      M2Options_Setc (value);
+      return 1;
     case OPT_I:
       if (insideCppArgs)
         {
index 2bea228a48af85304d4bec5e2fa907c7d09c3940..0ef2f2456bd60219c3c3cd6fdc240e37e34ba769 100644 (file)
@@ -23,26 +23,15 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "m2-link-support.h"
 
-#if !defined(MODULA_PROJECT_SUPPORT)
-# define MODULA_PROJECT_SUPPORT " "
-#endif
-
-#if !defined(MODULA_LINK_SUPPORT)
-# define MODULA_LINK_SUPPORT " "
-#endif
-
 #if !defined(M2CPP)
 # define M2CPP " "
 #endif
 
   {".mod", "@modula-2", 0, 0, 0},
-  // {".m2l", "@modula-2-linker", 0, 0, 0},
   {"@modula-2",
-      "%{c:" MODULA_PROJECT_SUPPORT "}"
-      "%{c|S:cc1gm2 " M2CPP
-      "      %(cc1_options) %{f*} %{+e*} %{I*} "
+      "cc1gm2 " M2CPP
+      "      %(cc1_options) %{c*} %{f*} %{+e*} %{I*} "
       "      %{MD} %{MMD} %{M} %{MM} %{MA} %{MT*} %{MF*} %V"
       "      %{save-temps*}"
-      "      %i %{!fsyntax-only:%(invoke_as)}}"
-      MODULA_LINK_SUPPORT ,
+      "      %i %{!fsyntax-only:%(invoke_as)}",
       0, 0, 0},
index 7c9f52855afb5ecde35e9cf40c270643e8586f7c..8831af688b20fc8863d5a6272a65ef2726451f7e 100644 (file)
@@ -42,6 +42,10 @@ O
 Modula-2
 ; Documented in c.opt
 
+c
+Modula-2
+; Documented in c.opt
+
 fiso
 Modula-2
 use ISO dialect of Modula-2
index 22325968e253d9458695d2d6457ce1341d0c7df6..a68b3c9cdc35740c5ae1051410681594ad9eecbe 100644 (file)
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-
 /* The subprograms used by Modula-2 to facilitate linking are:
    gm2l - parses the top level module and all other dependent
           modules.  It creates a dependency tree and emits a list
index cd913d80f3080f42eb397d6d40727b8f03b47c6c..bf45faee7422609819920e41997e2c42decc6f5f 100644 (file)
@@ -1,3 +1,8 @@
+2022-05-20   Gaius Mulley   <gaius.mulley@southwales.ac.uk>
+
+       * link/externalscaffold: (New regression test).  Manual
+       linking test using external scaffold.
+
 2021-07-07   Gaius Mulley   <gaius.mulley@southwales.ac.uk>
 
         * calling-c/datatypes/unbounded/run/pass/c.c: New file.
diff --git a/gcc/testsuite/gm2/link/externalscaffold/pass/hello.mod b/gcc/testsuite/gm2/link/externalscaffold/pass/hello.mod
new file mode 100644 (file)
index 0000000..75d0f65
--- /dev/null
@@ -0,0 +1,7 @@
+MODULE hello ;
+
+FROM libc IMPORT printf ;
+
+BEGIN
+   printf ("hello world\n")
+END hello.
diff --git a/gcc/testsuite/gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp b/gcc/testsuite/gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp
new file mode 100644 (file)
index 0000000..35890cf
--- /dev/null
@@ -0,0 +1,39 @@
+# Expect driver script for GCC Regression Tests
+# Copyright (C) 2022 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Gaius Mulley (gaius.mulley@southwales.ac.uk)
+# for GNU Modula-2.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+# load support procs
+load_lib gm2-torture.exp
+
+gm2_init_pim "${srcdir}/gm2/pim/pass"
+gm2_link_with scaffold.o
+set output [target_compile $srcdir/$subdir/scaffold.c scaffold.o object "-g"]
+
+foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
+    # If we're only testing specific files and this isn't one of them, skip it.
+    if ![runtest_file_p $runtests $testcase] then {
+       continue
+    }
+
+    gm2-torture-execute $testcase "" "pass"
+}
diff --git a/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c b/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c
new file mode 100644 (file)
index 0000000..176b046
--- /dev/null
@@ -0,0 +1,37 @@
+extern  void exit(int);
+
+extern  void _M2_SYSTEM_init (int argc, char *argv[]);
+extern  void _M2_SYSTEM_finish (void);
+extern  void _M2_M2RTS_init (int argc, char *argv[]);
+extern  void _M2_M2RTS_finish (void);
+extern  void _M2_RTExceptions_init (int argc, char *argv[]);
+extern  void _M2_RTExceptions_finish (void);
+extern  void _M2_hello_init (int argc, char *argv[]);
+extern  void _M2_hello_finish (void);
+
+extern  void M2RTS_Terminate(void);
+
+static void init (int argc, char *argv[])
+{
+    _M2_SYSTEM_init (argc, argv);
+    _M2_M2RTS_init (argc, argv);
+    _M2_RTExceptions_init (argc, argv);
+    _M2_hello_init (argc, argv);
+}
+
+static void finish (void)
+{
+   M2RTS_Terminate ();
+   _M2_hello_finish ();
+   _M2_RTExceptions_finish ();
+   _M2_M2RTS_finish ();
+   _M2_SYSTEM_finish ();
+   exit (0);
+}
+
+int main (int argc, char *argv[])
+{
+   init (argc, argv);
+   finish ();
+   return (0);
+}