aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaius Mulley <gaius.mulley@southwales.ac.uk>2022-05-30 21:05:35 +0100
committerGaius Mulley <gaius.mulley@southwales.ac.uk>2022-05-30 21:05:35 +0100
commit5eb238ce0b2dcbcb0737def243c9d18651270363 (patch)
tree114a32353df6728632b0a1cc6fd403fd6807711d
parent622a723be0a71fdc2602882d07e8b00e37ad00fb (diff)
Remove m2 front end linking support.
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>
-rw-r--r--gcc/m2/ChangeLog14
-rw-r--r--gcc/m2/gm2-compiler/M2Options.def16
-rw-r--r--gcc/m2/gm2-compiler/M2Options.mod21
-rw-r--r--gcc/m2/gm2-gcc/m2options.h3
-rw-r--r--gcc/m2/gm2-lang.cc4
-rw-r--r--gcc/m2/lang-specs.h17
-rw-r--r--gcc/m2/lang.opt4
-rw-r--r--gcc/m2/m2-link-support.h1
-rw-r--r--gcc/testsuite/gm2/ChangeLog5
-rw-r--r--gcc/testsuite/gm2/link/externalscaffold/pass/hello.mod7
-rw-r--r--gcc/testsuite/gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp39
-rw-r--r--gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c37
12 files changed, 152 insertions, 16 deletions
diff --git a/gcc/m2/ChangeLog b/gcc/m2/ChangeLog
index 52e951fafaa..5ebbc2a941b 100644
--- a/gcc/m2/ChangeLog
+++ b/gcc/m2/ChangeLog
@@ -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.
diff --git a/gcc/m2/gm2-compiler/M2Options.def b/gcc/m2/gm2-compiler/M2Options.def
index 5e324e414c9..f134c43a0db 100644
--- a/gcc/m2/gm2-compiler/M2Options.def
+++ b/gcc/m2/gm2-compiler/M2Options.def
@@ -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. *)
@@ -164,6 +166,20 @@ 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).
*)
diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod
index ed606cfeda1..510742c3f2a 100644
--- a/gcc/m2/gm2-compiler/M2Options.mod
+++ b/gcc/m2/gm2-compiler/M2Options.mod
@@ -382,6 +382,26 @@ 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 ;
diff --git a/gcc/m2/gm2-gcc/m2options.h b/gcc/m2/gm2-gcc/m2options.h
index b4b9961579b..5a9b1db2139 100644
--- a/gcc/m2/gm2-gcc/m2options.h
+++ b/gcc/m2/gm2-gcc/m2options.h
@@ -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);
diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
index a71b45788a0..45781eaade9 100644
--- a/gcc/m2/gm2-lang.cc
+++ b/gcc/m2/gm2-lang.cc
@@ -205,7 +205,9 @@ gm2_langhook_handle_option (
switch (code)
{
-
+ case OPT_c:
+ M2Options_Setc (value);
+ return 1;
case OPT_I:
if (insideCppArgs)
{
diff --git a/gcc/m2/lang-specs.h b/gcc/m2/lang-specs.h
index 2bea228a48a..0ef2f2456bd 100644
--- a/gcc/m2/lang-specs.h
+++ b/gcc/m2/lang-specs.h
@@ -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},
diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
index 7c9f52855af..8831af688b2 100644
--- a/gcc/m2/lang.opt
+++ b/gcc/m2/lang.opt
@@ -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
diff --git a/gcc/m2/m2-link-support.h b/gcc/m2/m2-link-support.h
index 22325968e25..a68b3c9cdc3 100644
--- a/gcc/m2/m2-link-support.h
+++ b/gcc/m2/m2-link-support.h
@@ -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
diff --git a/gcc/testsuite/gm2/ChangeLog b/gcc/testsuite/gm2/ChangeLog
index cd913d80f30..bf45faee742 100644
--- a/gcc/testsuite/gm2/ChangeLog
+++ b/gcc/testsuite/gm2/ChangeLog
@@ -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
index 00000000000..75d0f651c39
--- /dev/null
+++ b/gcc/testsuite/gm2/link/externalscaffold/pass/hello.mod
@@ -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
index 00000000000..35890cf119a
--- /dev/null
+++ b/gcc/testsuite/gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp
@@ -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
index 00000000000..176b0461409
--- /dev/null
+++ b/gcc/testsuite/gm2/link/externalscaffold/pass/scaffold.c
@@ -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);
+}