public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* add command line option to gcc
@ 2019-09-06  3:25 Tim Rice
  2019-09-06  4:18 ` Nicholas Krause
  2019-09-06 10:07 ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Tim Rice @ 2019-09-06  3:25 UTC (permalink / raw)
  To: gcc


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
tim@multitalents.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add command line option to gcc
  2019-09-06  3:25 add command line option to gcc Tim Rice
@ 2019-09-06  4:18 ` Nicholas Krause
  2019-09-06 10:07 ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Nicholas Krause @ 2019-09-06  4:18 UTC (permalink / raw)
  To: Tim Rice, gcc


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add command line option to gcc
  2019-09-06  3:25 add command line option to gcc Tim Rice
  2019-09-06  4:18 ` Nicholas Krause
@ 2019-09-06 10:07 ` Jonathan Wakely
  2019-09-06 17:21   ` Tim Rice
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2019-09-06 10:07 UTC (permalink / raw)
  To: Tim Rice; +Cc: gcc

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 ...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add command line option to gcc
  2019-09-06 10:07 ` Jonathan Wakely
@ 2019-09-06 17:21   ` Tim Rice
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Rice @ 2019-09-06 17:21 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc

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
tim@multitalents.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-06 17:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  3:25 add command line option to gcc Tim Rice
2019-09-06  4:18 ` Nicholas Krause
2019-09-06 10:07 ` Jonathan Wakely
2019-09-06 17:21   ` Tim Rice

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).