]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
modula2: Add cwd to include path. Include m2cor before m2pim.
authorGaius Mulley <gaiusmod2@gmail.com>
Wed, 22 Mar 2023 16:39:12 +0000 (16:39 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Wed, 22 Mar 2023 16:39:12 +0000 (16:39 +0000)
The driver should default to include the current working directory in the
module search path.  This patch adds . to the search path provided
-fm2-pathname has not been specified.  The patch also reorders the pim
libraries so that the m2cor directory is searched before m2pim.
Coroutine support is visible by default for both -fpim and -fiso
(from their respective SYSTEM modules).

gcc/m2/ChangeLog:

PR modula2/109248
* Make-lang.in (m2/pge-boot/%.o): Add CFLAGS and CXXFLAGS for C
and C++ compiles.
* gm2spec.cc (add_m2_I_path): Indentation.
(lang_specific_driver): New variable seen_pathname.
Detect -fm2-pathname.  If not seen then push_back_Ipath (".").
Change non iso library path to "m2cor,m2log,m2pim,m2iso".

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/Make-lang.in
gcc/m2/gm2spec.cc

index 3fc691b685e85b59309c8d756f30f08567618c9a..ad21b208f09be1d95a9ed71cd73664987f77bc02 100644 (file)
@@ -1694,11 +1694,11 @@ include m2/Make-maintainer
 else
 m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
        -test -d $(@D) || $(mkinstalldirs) $(@D)
-       $(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
+       $(CXX) $(CFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
 
 m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
        -test -d $(@D) || $(mkinstalldirs) $(@D)
-       $(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
+       $(CXX) $(CXXFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
 
 $(PGE): $(BUILD-PGE-O)
        +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) -lm
index a118a8818f61fa9daad66899e4ba736dd7b0dae9..3b2652cd92a1880b2591dbf4fb56debe387547db 100644 (file)
@@ -388,7 +388,7 @@ add_m2_I_path (void)
       if (strcmp (np.name, "") == 0)
        append_option (OPT_fm2_pathname_, safe_strdup ("-"), 1);
       else
-         append_option (OPT_fm2_pathname_, safe_strdup (np.name), 1);
+       append_option (OPT_fm2_pathname_, safe_strdup (np.name), 1);
       for (auto *s : np.path)
        append_option (OPT_fm2_pathnameI, safe_strdup (s), 1);
     }
@@ -461,6 +461,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   /* Have we seen the -v flag?  */
   bool verbose = false;
 
+  /* Have we seen the -fm2-pathname flag?  */
+  bool seen_pathname = false;
+
   /* The number of libraries added in.  */
   int added_libraries;
 
@@ -569,6 +572,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
          uselist = decoded_options[i].value;
          break;
        case OPT_fm2_pathname_:
+         seen_pathname = true;
          args[i] |= SKIPOPT; /* We will add the option if it is needed.  */
          m2_path_name = decoded_options[i].arg;
          break;
@@ -677,6 +681,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (language != NULL && (strcmp (language, "modula-2") != 0))
     return;
 
+  if (! seen_pathname)
+    /* Not seen -fm2-pathname therefore make current working directory
+       the first place to look for modules.  */
+    push_back_Ipath (".");
+
   /* Override the default when the user specifies it.  */
   if (seen_scaffold_static && scaffold_static && !seen_scaffold_dynamic)
     scaffold_dynamic = false;
@@ -772,7 +781,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
            libraries = xstrdup ("m2iso,m2cor,m2pim,m2log");
          else
            /* Default to pim libraries otherwise.  */
-           libraries = xstrdup ("m2pim,m2iso,m2cor,m2log");
+           libraries = xstrdup ("m2cor,m2log,m2pim,m2iso");
        }
       libraries = convert_abbreviations (libraries);
       append_option (OPT_flibs_, xstrdup (libraries), 1);