From: Gaius Mulley Date: Wed, 22 Mar 2023 16:39:12 +0000 (+0000) Subject: modula2: Add cwd to include path. Include m2cor before m2pim. X-Git-Tag: basepoints/gcc-14~404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae0d89e65c5da6ef45ec787e165dccb5ae7e2d0;p=thirdparty%2Fgcc.git modula2: Add cwd to include path. Include m2cor before m2pim. 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 --- diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index 3fc691b685e8..ad21b208f09b 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -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 diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc index a118a8818f61..3b2652cd92a1 100644 --- a/gcc/m2/gm2spec.cc +++ b/gcc/m2/gm2spec.cc @@ -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);