public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <iain@sandoe.co.uk>
To: Gaius Mulley <gaiusmod2@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH, modula2] PR-108182 gm2 driver mishandles target and multilib options
Date: Sat, 7 Jan 2023 10:59:56 +0000	[thread overview]
Message-ID: <01A42446-8E4E-46CE-A692-6AA45D100BA8@sandoe.co.uk> (raw)
In-Reply-To: <87wn5zs5l4.fsf@debian>



> On 6 Jan 2023, at 21:42, Gaius Mulley via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 

> here are some patches which attempt to allow target specific include
> paths and library paths in the gm2 driver.  I admit that the patch has
> flaws in that it only processes options -f, -m in the lang_specific_driver.
> [Called after driver::set_up_specs but before read_specs is called].
> 
> I suspect a better implementation might include a language callback
> (lang_post_spec) which could fixup target related paths.
> 
> Nevertheless as a stage3 bugfix (workaround) they are presented below:
> 
> I wonder if they would be suitable for master?
> 
> Tested on Darwin (prior cleanup) and X86_64 Linux

retested this on Darwin, still fixes the issue.
Iain

> 
> regards,
> Gaius
> 
> ----- o< ----- o< ----- o< ----- o< ----- o< ----- o< ----- o< ----- o<
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index d629ca5e424..362a6a96b63 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -3849,7 +3849,7 @@ alloc_switch (void)
> /* Save an option OPT with N_ARGS arguments in array ARGS, marking it
>    as validated if VALIDATED and KNOWN if it is an internal switch.  */
> 
> -static void
> +void
> save_switch (const char *opt, size_t n_args, const char *const *args,
> 	     bool validated, bool known)
> {
> @@ -9559,6 +9559,24 @@ default_arg (const char *p, int len)
>   return 0;
> }
> 
> +/* Return the value of multilib_dir.  */
> +
> +const char *
> +get_multilib_dir (void)
> +{
> +  set_multilib_dir ();
> +  return multilib_dir;
> +}
> +
> +/* Reset the mdswitches array to empty.  */
> +
> +void
> +reset_mdswitches (void)
> +{
> +  n_mdswitches = 0;
> +  mdswitches = NULL;
> +}
> +
> /* Work out the subdirectory to use based on the options. The format of
>    multilib_select is a list of elements. Each element is a subdirectory
>    name followed by a list of options followed by a semicolon. The format
> diff --git a/gcc/gcc.h b/gcc/gcc.h
> index 19a61b373ee..03646ff2d87 100644
> --- a/gcc/gcc.h
> +++ b/gcc/gcc.h
> @@ -73,6 +73,11 @@ struct spec_function
> extern int do_spec (const char *);
> extern void record_temp_file (const char *, int, int);
> extern void set_input (const char *);
> +extern const char *get_multilib_dir (void);
> +extern void reset_mdswitches (void);
> +extern void save_switch (const char *opt, size_t n_args,
> +			 const char *const *args,
> +			 bool validated, bool known);
> 
> /* Spec files linked with gcc.cc must provide definitions for these.  */
> 
> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
> index 583723da416..dbfd1cacccc 100644
> --- a/gcc/m2/gm2spec.cc
> +++ b/gcc/m2/gm2spec.cc
> @@ -797,8 +797,14 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
> 	  if ((decoded_options[i].orig_option_with_args_text != NULL)
> 	      && (strncmp (decoded_options[i].orig_option_with_args_text,
> 			   "-m", 2) == 0))
> -	    multilib_dir = xstrdup (decoded_options[i].orig_option_with_args_text
> -				    + 2);
> +	    save_switch (decoded_options[i].orig_option_with_args_text,
> +			 0, NULL, true, true);
> +	  else if ((decoded_options[i].orig_option_with_args_text != NULL)
> +		   && (strncmp (decoded_options[i].orig_option_with_args_text,
> +				"-f", 2) == 0))
> +	      save_switch (decoded_options[i].orig_option_with_args_text,
> +			   0, NULL, true, true);
> +	  break;
> 	}
>     }
>   if (language != NULL && (strcmp (language, "modula-2") != 0))
> @@ -864,10 +870,13 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>   if ((! (seen_uselist || seen_gen_module_list)) && linking)
>     append_option (OPT_fgen_module_list_, "-", 1);
> 
> +  multilib_dir = get_multilib_dir ();
> +  reset_mdswitches ();
>   if (allow_libraries)
>     {
>       /* If the libraries have not been specified by the user but the
> -	 dialect has been specified then select the appropriate libraries.  */
> +	 dialect has been specified then select the appropriate
> +	 libraries.  */
>       if (libraries == NULL)
> 	{
> 	  if (strcmp (dialect, "iso") == 0)
> --------


  reply	other threads:[~2023-01-07 11:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 21:42 Gaius Mulley
2023-01-07 10:59 ` Iain Sandoe [this message]
2023-01-06 21:58 Gaius Mulley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01A42446-8E4E-46CE-A692-6AA45D100BA8@sandoe.co.uk \
    --to=iain@sandoe.co.uk \
    --cc=gaiusmod2@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).