Re: [PATCH] modula-2, driver, Front end: Revise handling of I and L paths [PR108182].

2023-01-23 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64-linux-gnu (with a 32b multilib), powerpc, i686 and
> x86_64-darwin.  OK for trunk?
> thanks,
> Iain
>
> --- 8< ---
>
> The adds the includes in the FE as done in other GCC languages.
> It also revises the library handling to avoid additional -L options
> from hiding LIBDIR.
>
> For the include/import paths as presented to the front end initialisation,
> we capture them and then arrange to emit the 'standard library' paths in
> the same order as specified for C.
>
> The specs are tidied up.

yes LGTM - apologies for the delay

thank you!
Gaius


Re: [PATCH] modula-2, driver, Front end: Revise handling of I and L paths [PR108182].

2023-01-22 Thread Richard Biener via Gcc-patches
On Tue, Jan 17, 2023 at 6:05 PM Iain Sandoe via Gcc-patches
 wrote:
>
> Tested on x86_64-linux-gnu (with a 32b multilib), powerpc, i686 and
> x86_64-darwin.  OK for trunk?

Reading through the patch I fear there's more issues lurking
(-sysroot?) but this seems to be
a step in the right direction, so OK for trunk unless Gaius has more
comments or objections.

Can you mention PR108480 in the commit log?

Thanks,
Richard.

> thanks,
> Iain
>
> --- 8< ---
>
> The adds the includes in the FE as done in other GCC languages.
> It also revises the library handling to avoid additional -L options
> from hiding LIBDIR.
>
> For the include/import paths as presented to the front end initialisation,
> we capture them and then arrange to emit the 'standard library' paths in
> the same order as specified for C.
>
> The specs are tidied up.
>
> Signed-off-by: Iain Sandoe 
>
> PR modula2/108182
>
> gcc/m2/ChangeLog:
>
> * Make-lang.in: Pass libsubdir to the language init
> build.
> * gm2-lang.cc (INCLUDE_VECTOR): Define.
> (add_one_import_path): New.
> (add_m2_import_paths): New.
> (gm2_langhook_post_options): Arrange to add the include
> paths (and add the system ones) in the same order as C
> uses.
> * gm2spec.cc (build_archive_path): Remove.
> (add_default_combination): Remove.
> (add_default_archives): Remove.
> (add_default_libs): We no longer need a '-L' option, just
> emit the -l and each library in use.
> (build_include_path): Remove.
> (add_include): Remove.
> (add_default_includes): Remove.
> (library_installed): Remove.
> (check_valid_library): Remove.
> (check_valid_list): Remove.
> (convert_abbreviation): Diagnose unhandled cases.
> (lang_specific_driver): Skip options where we will add back
> a validated version.
> * lang-specs.h (M2CPP): Reformat, append %I when -fcpp is not
> in use.  Revise the cc1gm2 spec to omit mentioning options that
> are handled in the c pre-processor line.
> * lang.opt: Allow preprocessing and path options as input to the
> cc1gm2 invocation, so that they can be passed to the preprocessor
> invocation.
> ---
>  gcc/m2/Make-lang.in |   1 +
>  gcc/m2/gm2-lang.cc  | 168 --
>  gcc/m2/gm2spec.cc   | 344 
>  gcc/m2/lang-specs.h |  13 +-
>  gcc/m2/lang.opt |  48 +++
>  5 files changed, 304 insertions(+), 270 deletions(-)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index 367be8e8af7..00cca7de617 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -543,6 +543,7 @@ m2/gm2-gcc/m2configure.o: 
> $(srcdir)/m2/gm2-gcc/m2configure.cc \
>
>  m2/gm2-lang.o: $(srcdir)/m2/gm2-lang.cc gt-m2-gm2-lang.h 
> $(GCC_HEADER_DEPENDENCIES_FOR_M2)
> $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \
> +   -DLIBSUBDIR=\"$(libsubdir)\" \
>  $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>
>  m2/stor-layout.o: $(srcdir)/stor-layout.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
> diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
> index b8123273368..98707430ef5 100644
> --- a/gcc/m2/gm2-lang.cc
> +++ b/gcc/m2/gm2-lang.cc
> @@ -20,6 +20,7 @@ along with GNU Modula-2; see the file COPYING.  If not, 
> write to the
>  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
>  02110-1301, USA.  */
>
> +#define INCLUDE_VECTOR
>  #include "gm2-gcc/gcc-consolidation.h"
>
>  #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name.  */
> @@ -45,6 +46,18 @@ static void write_globals (void);
>
>  static int insideCppArgs = FALSE;
>
> +/* We default to pim in the absence of fiso.  */
> +static bool iso = false;
> +
> +/* The language include paths are based on the libraries in use.  */
> +static bool allow_libraries = true;
> +static const char *flibs = nullptr;
> +static const char *iprefix = nullptr;
> +static const char *imultilib = nullptr;
> +static std::vectorIpaths;
> +static std::vectorisystem;
> +static std::vectoriquote;
> +
>  #define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
>
>  /* start of new stuff.  */
> @@ -198,34 +211,41 @@ gm2_langhook_handle_option (
>return 1;
>  case OPT_I:
>if (insideCppArgs)
> -{
> -  const struct cl_option *option = _options[scode];
> -  const char *opt = (const char *)option->opt_text;
> -  M2Options_CppArg (opt, arg, TRUE);
> -}
> +   {
> + const struct cl_option *option = _options[scode];
> + const char *opt = (const char *)option->opt_text;
> + M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
> +  && !(option->flags & CL_SEPARATE));
> +   }
>else
> -M2Options_SetSearchPath (arg);
> +   Ipaths.push_back (arg);
>return 1;
>

[PATCH] modula-2, driver, Front end: Revise handling of I and L paths [PR108182].

2023-01-17 Thread Iain Sandoe via Gcc-patches
Tested on x86_64-linux-gnu (with a 32b multilib), powerpc, i686 and
x86_64-darwin.  OK for trunk?
thanks,
Iain

--- 8< ---

The adds the includes in the FE as done in other GCC languages.
It also revises the library handling to avoid additional -L options
from hiding LIBDIR.

For the include/import paths as presented to the front end initialisation,
we capture them and then arrange to emit the 'standard library' paths in
the same order as specified for C.

The specs are tidied up.

Signed-off-by: Iain Sandoe 

PR modula2/108182

gcc/m2/ChangeLog:

* Make-lang.in: Pass libsubdir to the language init
build.
* gm2-lang.cc (INCLUDE_VECTOR): Define.
(add_one_import_path): New.
(add_m2_import_paths): New.
(gm2_langhook_post_options): Arrange to add the include
paths (and add the system ones) in the same order as C
uses.
* gm2spec.cc (build_archive_path): Remove.
(add_default_combination): Remove.
(add_default_archives): Remove.
(add_default_libs): We no longer need a '-L' option, just
emit the -l and each library in use.
(build_include_path): Remove.
(add_include): Remove.
(add_default_includes): Remove.
(library_installed): Remove.
(check_valid_library): Remove.
(check_valid_list): Remove.
(convert_abbreviation): Diagnose unhandled cases.
(lang_specific_driver): Skip options where we will add back
a validated version.
* lang-specs.h (M2CPP): Reformat, append %I when -fcpp is not
in use.  Revise the cc1gm2 spec to omit mentioning options that
are handled in the c pre-processor line.
* lang.opt: Allow preprocessing and path options as input to the
cc1gm2 invocation, so that they can be passed to the preprocessor
invocation.
---
 gcc/m2/Make-lang.in |   1 +
 gcc/m2/gm2-lang.cc  | 168 --
 gcc/m2/gm2spec.cc   | 344 
 gcc/m2/lang-specs.h |  13 +-
 gcc/m2/lang.opt |  48 +++
 5 files changed, 304 insertions(+), 270 deletions(-)

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 367be8e8af7..00cca7de617 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -543,6 +543,7 @@ m2/gm2-gcc/m2configure.o: 
$(srcdir)/m2/gm2-gcc/m2configure.cc \
 
 m2/gm2-lang.o: $(srcdir)/m2/gm2-lang.cc gt-m2-gm2-lang.h 
$(GCC_HEADER_DEPENDENCIES_FOR_M2)
$(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \
+   -DLIBSUBDIR=\"$(libsubdir)\" \
 $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
 m2/stor-layout.o: $(srcdir)/stor-layout.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
index b8123273368..98707430ef5 100644
--- a/gcc/m2/gm2-lang.cc
+++ b/gcc/m2/gm2-lang.cc
@@ -20,6 +20,7 @@ along with GNU Modula-2; see the file COPYING.  If not, write 
to the
 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 02110-1301, USA.  */
 
+#define INCLUDE_VECTOR
 #include "gm2-gcc/gcc-consolidation.h"
 
 #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name.  */
@@ -45,6 +46,18 @@ static void write_globals (void);
 
 static int insideCppArgs = FALSE;
 
+/* We default to pim in the absence of fiso.  */
+static bool iso = false;
+
+/* The language include paths are based on the libraries in use.  */
+static bool allow_libraries = true;
+static const char *flibs = nullptr;
+static const char *iprefix = nullptr;
+static const char *imultilib = nullptr;
+static std::vectorIpaths;
+static std::vectorisystem;
+static std::vectoriquote;
+
 #define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
 
 /* start of new stuff.  */
@@ -198,34 +211,41 @@ gm2_langhook_handle_option (
   return 1;
 case OPT_I:
   if (insideCppArgs)
-{
-  const struct cl_option *option = _options[scode];
-  const char *opt = (const char *)option->opt_text;
-  M2Options_CppArg (opt, arg, TRUE);
-}
+   {
+ const struct cl_option *option = _options[scode];
+ const char *opt = (const char *)option->opt_text;
+ M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
+  && !(option->flags & CL_SEPARATE));
+   }
   else
-M2Options_SetSearchPath (arg);
+   Ipaths.push_back (arg);
   return 1;
 case OPT_fiso:
   M2Options_SetISO (value);
+  iso = value;
   return 1;
 case OPT_fpim:
   M2Options_SetPIM (value);
+  iso = value ? false : iso;
   return 1;
 case OPT_fpim2:
   M2Options_SetPIM2 (value);
+  iso = value ? false : iso;
   return 1;
 case OPT_fpim3:
   M2Options_SetPIM3 (value);
+  iso = value ? false : iso;
   return 1;
 case OPT_fpim4:
   M2Options_SetPIM4 (value);
+  iso = value ? false : iso;
   return 1;
 case OPT_fpositive_mod_floor_div: