public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How can I run xg++ from its build location?
@ 2023-08-25 20:12 Michael Welsh Duggan
  2023-08-25 20:22 ` David Edelsohn
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michael Welsh Duggan @ 2023-08-25 20:12 UTC (permalink / raw)
  To: gcc

I am attempting to debug an issue in gcc (PR 110827, if curious).  In
order to do this I have built a stage 1 compiler with debugging and
without optimization as discussed here:

https://gcc.gnu.org/wiki/DebuggingGCC#Building_a_Debuggable_Compiler

I would like run the compiler from its build location without installing
it, but I cannot determine how to have gcc look for its include files
and libraries from within its source and build trees.  My first problem
was that it looked for for cc1plus in the wrong location; my next
problems involved include paths.

Is it possible to do this without extensive command-line options, or
does this need to be installed?  If the latter, what target do I use to
install the unoptimized stage 1 compiler?

-- 
Michael Welsh Duggan
(md5i@md5i.com)


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

* Re: How can I run xg++ from its build location?
  2023-08-25 20:12 How can I run xg++ from its build location? Michael Welsh Duggan
@ 2023-08-25 20:22 ` David Edelsohn
  2023-08-27  5:28   ` Michael Welsh Duggan
  2023-08-25 20:34 ` Sam James
  2023-08-25 21:11 ` David Malcolm
  2 siblings, 1 reply; 6+ messages in thread
From: David Edelsohn @ 2023-08-25 20:22 UTC (permalink / raw)
  To: Michael Welsh Duggan, gcc

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On Fri, Aug 25, 2023 at 4:16 PM Michael Welsh Duggan via Gcc <
gcc@gcc.gnu.org> wrote:

> I am attempting to debug an issue in gcc (PR 110827, if curious).  In
> order to do this I have built a stage 1 compiler with debugging and
> without optimization as discussed here:
>
> https://gcc.gnu.org/wiki/DebuggingGCC#Building_a_Debuggable_Compiler
>
> I would like run the compiler from its build location without installing
> it, but I cannot determine how to have gcc look for its include files
> and libraries from within its source and build trees.  My first problem
> was that it looked for for cc1plus in the wrong location; my next
> problems involved include paths.
>
> Is it possible to do this without extensive command-line options, or
> does this need to be installed?  If the latter, what target do I use to
> install the unoptimized stage 1 compiler?
>

One can use

$ ./xgcc -B./

to run GCC in the build directory, or wherever the driver and compiler are
installed.

To debug the compiler, it is easier to produce a preprocessed file with the
header files included (-E command line option) and direct the compiler,
e.g, cc1 or cc1plus, to use the preprocessed file as input.

David

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

* Re: How can I run xg++ from its build location?
  2023-08-25 20:12 How can I run xg++ from its build location? Michael Welsh Duggan
  2023-08-25 20:22 ` David Edelsohn
@ 2023-08-25 20:34 ` Sam James
  2023-08-25 21:11 ` David Malcolm
  2 siblings, 0 replies; 6+ messages in thread
From: Sam James @ 2023-08-25 20:34 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: gcc


Michael Welsh Duggan via Gcc <gcc@gcc.gnu.org> writes:

> I am attempting to debug an issue in gcc (PR 110827, if curious).  In
> order to do this I have built a stage 1 compiler with debugging and
> without optimization as discussed here:
>
> https://gcc.gnu.org/wiki/DebuggingGCC#Building_a_Debuggable_Compiler
>
> I would like run the compiler from its build location without installing
> it, but I cannot determine how to have gcc look for its include files
> and libraries from within its source and build trees.  My first problem
> was that it looked for for cc1plus in the wrong location; my next
> problems involved include paths.
>

You can try something like:
./xgcc -B$(pwd) -I$(pwd) ... # (may need to add some more include
directives in)

I know someone was interested in adding a proper wrapper for this
so it Just Worked.

But for now, I'd really just...

> Is it possible to do this without extensive command-line options, or
> does this need to be installed?  If the latter, what target do I use to
> install the unoptimized stage 1 compiler?

Is there a particular reason you can't install it to a temporary prefix,
like ./configure --prefix=/opt/foo or even /tmp/foo?

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

* Re: How can I run xg++ from its build location?
  2023-08-25 20:12 How can I run xg++ from its build location? Michael Welsh Duggan
  2023-08-25 20:22 ` David Edelsohn
  2023-08-25 20:34 ` Sam James
@ 2023-08-25 21:11 ` David Malcolm
  2 siblings, 0 replies; 6+ messages in thread
From: David Malcolm @ 2023-08-25 21:11 UTC (permalink / raw)
  To: Michael Welsh Duggan, gcc

On Fri, 2023-08-25 at 16:12 -0400, Michael Welsh Duggan via Gcc wrote:
> I am attempting to debug an issue in gcc (PR 110827, if curious).  In
> order to do this I have built a stage 1 compiler with debugging and
> without optimization as discussed here:
> 
> https://gcc.gnu.org/wiki/DebuggingGCC#Building_a_Debuggable_Compiler
> 
> I would like run the compiler from its build location without
> installing
> it, but I cannot determine how to have gcc look for its include files
> and libraries from within its source and build trees.  My first
> problem
> was that it looked for for cc1plus in the wrong location; my next
> problems involved include paths.
> 
> Is it possible to do this without extensive command-line options, or
> does this need to be installed?  If the latter, what target do I use
> to
> install the unoptimized stage 1 compiler?
> 

You could try:
  ./xgcc -B.   REST OF GCC OPTIONS   -wrapper gdb,--args

where "./xgcc -B." will run the locally-built "driver" binary (xgcc),
and make it look for things like "cc1" in ".".

You may find this guide on debugging gcc helpful:
  https://gcc-newbies-guide.readthedocs.io/en/latest/debugging.html

Dave


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

* Re: How can I run xg++ from its build location?
  2023-08-25 20:22 ` David Edelsohn
@ 2023-08-27  5:28   ` Michael Welsh Duggan
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Welsh Duggan @ 2023-08-27  5:28 UTC (permalink / raw)
  To: gcc

David Edelsohn via Gcc <gcc@gcc.gnu.org> writes:

> n Fri, Aug 25, 2023 at 4:16 PM Michael Welsh Duggan via Gcc <
> gcc@gcc.gnu.org> wrote:
>
>> I am attempting to debug an issue in gcc (PR 110827, if curious).  In
>> order to do this I have built a stage 1 compiler with debugging and
>> without optimization as discussed here:
>>
>> https://gcc.gnu.org/wiki/DebuggingGCC#Building_a_Debuggable_Compiler
>>
>> I would like run the compiler from its build location without installing
>> it, but I cannot determine how to have gcc look for its include files
>> and libraries from within its source and build trees.  My first problem
>> was that it looked for for cc1plus in the wrong location; my next
>> problems involved include paths.
>>
>> Is it possible to do this without extensive command-line options, or
>> does this need to be installed?  If the latter, what target do I use to
>> install the unoptimized stage 1 compiler?
>>
>
> One can use
>
> $ ./xgcc -B./
>
> to run GCC in the build directory, or wherever the driver and compiler are
> installed.
>
> To debug the compiler, it is easier to produce a preprocessed file with the
> header files included (-E command line option) and direct the compiler,
> e.g, cc1 or cc1plus, to use the preprocessed file as input.

Thanks; this worked, mostly.  I did have to include a `-L` option for:

  /usr/bin/ld: cannot find -lstdc++: No such file or directory

but that's only a single library, so that was easy to do.  The hint
about preprocessing rather than trying to get the include directories
correct was a good idea.  gcov doesn't work quite right with
preprocessed files, but I was able to hack around it.

-- 
Michael Welsh Duggan
(md5i@md5i.com)


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

* Re: How can I run xg++ from its build location?
@ 2023-08-26 13:59 Benjamin Priour
  0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Priour @ 2023-08-26 13:59 UTC (permalink / raw)
  To: mwd; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

Hi,

If you further have issues with loading required libraries,
you could try running a test intended for g++ (make check-c++ from under
BUILDDIR/gcc/)

You may find examples at
https://gcc-newbies-guide.readthedocs.io/en/latest/working-with-the-testsuite.html#running-just-one-test-or-just-a-few

Then, open up BUILDDIR/gcc/testsuite/g++.dg/g++.log and search for
"Invoking the compiler as".
You will most certainly find helpful commands, populated with the actual
options your test is ran with by the testsuite, that you may later on adapt
to your needs.

Benjamin.

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

end of thread, other threads:[~2023-08-27  5:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25 20:12 How can I run xg++ from its build location? Michael Welsh Duggan
2023-08-25 20:22 ` David Edelsohn
2023-08-27  5:28   ` Michael Welsh Duggan
2023-08-25 20:34 ` Sam James
2023-08-25 21:11 ` David Malcolm
2023-08-26 13:59 Benjamin Priour

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