add command line option to gcc

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

add command line option to gcc

Tim Rice

I have a use case where I would like gcc to accept -Kthread
and act as if it was passed -pthread. So -Kthread would
be a synonym for -pthread.

I am having trouble figuring out how the option processing is handled.
Possibly in gcc/gcc.c but I am stumped here.

Any pointers would be welcome.

Thanks.

--
Tim Rice Multitalents
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: add command line option to gcc

Nicholas Krause

On 9/5/19 11:25 PM, Tim Rice wrote:

> I have a use case where I would like gcc to accept -Kthread
> and act as if it was passed -pthread. So -Kthread would
> be a synonym for -pthread.
>
> I am having trouble figuring out how the option processing is handled.
> Possibly in gcc/gcc.c but I am stumped here.
>
> Any pointers would be welcome.
>
> Thanks.
>

The first thing is why don't you just create a alias in your shell for
this. If not

you also have to understand -lpthread is a linker to link in the
library. If you

really require to do then you will need to rewrite parts of the C++/C
frontends.

Here is a link to what you will need to read:

https://gcc.gnu.org/onlinedocs/gccint/Front-End.html#Front-End

Mostly it's adding the option so the first link should help it seems for
understanding

a frontend directory,


Nick

Reply | Threaded
Open this post in threaded view
|

Re: add command line option to gcc

Jonathan Wakely-4
In reply to this post by Tim Rice
On Fri, 6 Sep 2019 at 04:26, Tim Rice wrote:
>
>
> I have a use case where I would like gcc to accept -Kthread
> and act as if it was passed -pthread. So -Kthread would
> be a synonym for -pthread.

For a specific target, or universally?

> I am having trouble figuring out how the option processing is handled.
> Possibly in gcc/gcc.c but I am stumped here.

You could use "specs" to tell the driver to use -pthread when -Kthread
is given e.g.

%{Kthread: -pthread}

This can either be hardcoded into the 'gcc' driver program (which
would be done in gcc/gcc.c or in a per-target file under gcc/config)
or provided in a specs file with the -specs option (see the manual).

The quick and dirty way to test that would be to dump the current
specs to a file with 'gcc -dumpspecs > kthread.spec' and then edit the
file so that everywhere you see %{pthread: xxx} you add %{Kthread:
xxx} to make it do the same thing. Then you can run gcc
-specs=kthread.spec -Kthread ...
Reply | Threaded
Open this post in threaded view
|

Re: add command line option to gcc

Tim Rice
On Fri, 6 Sep 2019, Jonathan Wakely wrote:

> On Fri, 6 Sep 2019 at 04:26, Tim Rice wrote:
> >
> >
> > I have a use case where I would like gcc to accept -Kthread
> > and act as if it was passed -pthread. So -Kthread would
> > be a synonym for -pthread.
>
> For a specific target, or universally?

Likely only useful for UnixWare (and OpenServer 6).

>
> > I am having trouble figuring out how the option processing is handled.
> > Possibly in gcc/gcc.c but I am stumped here.
>
> You could use "specs" to tell the driver to use -pthread when -Kthread
> is given e.g.
>
> %{Kthread: -pthread}
>
> This can either be hardcoded into the 'gcc' driver program (which
> would be done in gcc/gcc.c or in a per-target file under gcc/config)
> or provided in a specs file with the -specs option (see the manual).

Ok, I'll go down this path and see how it works out.

Thanks.
 
> The quick and dirty way to test that would be to dump the current
> specs to a file with 'gcc -dumpspecs > kthread.spec' and then edit the
> file so that everywhere you see %{pthread: xxx} you add %{Kthread:
> xxx} to make it do the same thing. Then you can run gcc
> -specs=kthread.spec -Kthread ...
>

--
Tim Rice Multitalents (707) 456-1146
[hidden email]