'posix_spawnp' error in build

2023-12-25 Thread Prashant via Gcc
Hello,

I'm new to the GCC community, who is willing to contribute and expand my
knowledge on compilers. I hope this is the right forum I'm asking for help.

 I'm trying to build the gcc repository. Based on the instructions given on
the SummerOfCode - GCC Wiki (gnu.org)
 and GCC for New
Contributors — GCC Contributors Guide 0.1 documentation
(gcc-newbies-guide.readthedocs.io)
, I have tried the
following commands.

1) git clone git://gcc.gnu.org/git/gcc.git
2) cd gcc & ./contrib/download_prerequisites
3) mkdir objdir & cd objdir
4) ../gcc/configure --prefix=/home/path/to/gcc --enable-languages=c,c++
5) make -j 4

Running the 5th throws the following error:
'xgcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or
directory
compilation terminated.'

I have tried to search Google and take help of ChatGPT but even the
guidance didn't resolve my issue.

Following are the solutions that I tried.

Executing the command:

1) 'sudo apt-get install --reinstall build-essential'
2) 'sudo apt-get install --reinstall g++'
3) 'unset GCC_EXEC_PREFIX'

This is based on the following pages:
php - Compile error: "g++: error trying to exec 'cc1plus': execvp: No such
file or directory" - Stack Overflow


and ChatGPT inputs.

I haven't been able to find a solution for the same. Any guidance/input
will be appreciated.


Thanks


Re: 'posix_spawnp' error in build

2023-12-25 Thread Segher Boessenkool
Hi!

On Mon, Dec 25, 2023 at 08:11:23PM +0530, Prashant via Gcc-help wrote:
>  I'm trying to build the gcc repository. Based on the instructions given on
> the SummerOfCode - GCC Wiki (gnu.org)
>  and GCC for New
> Contributors — GCC Contributors Guide 0.1 documentation
> (gcc-newbies-guide.readthedocs.io)
> , I have tried the
> following commands.
> 
> 1) git clone git://gcc.gnu.org/git/gcc.git
> 2) cd gcc & ./contrib/download_prerequisites
> 3) mkdir objdir & cd objdir
> 4) ../gcc/configure --prefix=/home/path/to/gcc --enable-languages=c,c++

That is wrong.  Build dir as a subdir of the source dir is not
supported.  It might work in many cases, but that does not mean it is
okay to do.

> Running the 5th throws the following error:
> 'xgcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or
> directory
> compilation terminated.'

I don't know if that is one of the weird problems caused by this.  Easy
enough to find out.  First "make distclean", and then "git status".

The error message says that the newly compiled compiler driver ("xgcc",
which will be insbtalled as just "gcc" eventually) cannot execute the
newly compiled actual C++ compiler ("cc1plus"), not from the place it
thinks it put it, anyway.

gl;hf, happy holidays, let us know how it went / what else you find out,


Segher


Re: 'posix_spawnp' error in build

2023-12-25 Thread Xi Ruoyao via Gcc
On Mon, 2023-12-25 at 10:28 -0600, Segher Boessenkool wrote:
> Hi!
> 
> On Mon, Dec 25, 2023 at 08:11:23PM +0530, Prashant via Gcc-help wrote:
> >  I'm trying to build the gcc repository. Based on the instructions given on
> > the SummerOfCode - GCC Wiki (gnu.org)
> >  and GCC for New
> > Contributors — GCC Contributors Guide 0.1 documentation
> > (gcc-newbies-guide.readthedocs.io)
> > , I have tried the
> > following commands.
> > 
> > 1) git clone git://gcc.gnu.org/git/gcc.git
> > 2) cd gcc & ./contrib/download_prerequisites
> > 3) mkdir objdir & cd objdir
> > 4) ../gcc/configure --prefix=/home/path/to/gcc --enable-languages=c,c++
> 
> That is wrong.  Build dir as a subdir of the source dir is not
> supported.  It might work in many cases, but that does not mean it is
> okay to do.

It *is* supported, per discussion at
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638760.html.

But then you should use "../configure", not "../gcc/configure".  Running
the configure script of a GCC component (instead of the top-level
configure) directly is completely unsupported.

-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: 'posix_spawnp' error in build

2023-12-25 Thread Prashant via Gcc
On Mon, 25 Dec 2023 at 22:00, Segher Boessenkool 
wrote:

> Hi!
>
> > That is wrong.  Build dir as a subdir of the source dir is not
> > supported.  It might work in many cases, but that does not mean it is
> > okay to do.
>
> I'm really sorry to miss out this important piece of information. Before
> the execution of step 3, I'm out of the gcc repo. So 'gcc' and 'objdir' are
> in the same level.



>

> I don't know if that is one of the weird problems caused by this.  Easy
> > enough to find out.  First "make distclean", and then "git status".
>
> I don't know if we require it to execute above, specially if it's outside
the actual gcc repo.


> >The error message says that the newly compiled compiler driver ("xgcc",
> > which will be insbtalled as just "gcc" eventually) cannot execute the
> > newly compiled actual C++ compiler ("cc1plus"), not from the place it
> > thinks it put it, anyway.
>
> Any solution for this> Problem still exists.


> > gl;hf, happy holidays, let us know how it went / what else you find out,
>
> Thank you and happy holidays to everyone!
> Segher
>


Re: 'posix_spawnp' error in build

2023-12-25 Thread Segher Boessenkool
On Tue, Dec 26, 2023 at 12:33:40AM +0800, Xi Ruoyao wrote:
> On Mon, 2023-12-25 at 10:28 -0600, Segher Boessenkool wrote:
> > > 1) git clone git://gcc.gnu.org/git/gcc.git
> > > 2) cd gcc & ./contrib/download_prerequisites
> > > 3) mkdir objdir & cd objdir
> > > 4) ../gcc/configure --prefix=/home/path/to/gcc --enable-languages=c,c++
> > 
> > That is wrong.  Build dir as a subdir of the source dir is not
> > supported.  It might work in many cases, but that does not mean it is
> > okay to do.
> 
> It *is* supported, per discussion at
> https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638760.html.

Huh, okay.  That changed "recently" then, for some elongated timescale
anyway :-)

> But then you should use "../configure", not "../gcc/configure".

Ha!  I didn't even notice that.

> Running
> the configure script of a GCC component (instead of the top-level
> configure) directly is completely unsupported.

Without all the necessary configuration arguments, yeah.  So it is still
easier to just make an actually  separate object dir -- even if only so
you can just blow it away when you want to start over :-)


Segher