diff mbox

[RFA/gdb-9-branch] Abort configure immediately if building GDB in tree

Message ID 20200117181554.GB7007@adacore.com
State New
Headers show

Commit Message

Joel Brobecker Jan. 17, 2020, 6:15 p.m. UTC
Hi Simon,

Thanks for the review.

> > +if test x"${enable_gdb}" != x"no"; then
> > +  # For this branch, we do not support building GDB in-tree.
> > +  # Try to detect whether we are in this situation or not by
> > +  # searching for a couple of known files in the source directory.
> > +  if test -f gnulib/update-gnulib.sh -a -f gdb/ChangeLog; then
> > +    AC_MSG_ERROR([GDB must be configured and built in a directory separate from its sources])
> 
> Finish the message with a period?

Of course! FWIW, I modeled this to other calls to AC_MSG_ERROR ;-)

> Some people who only know the "./configure && make && make install" recipe
> might not know how (or that it's even possible) to configure and build in a
> separate directory, so they'll be stuck there.  I think it would be helpful
> to give an example of how to do that, like:
> 
>     GDB must be configured and built in a directory separate from its sources.
> 
>     To do so, create a dedicated directory for your GDB build and invoke the configure
>     script from that directory:
> 
>       $ mkdir my-gdb-build
>       $ cd my-gdb-build
>       $ ../path/to/gdb-x.y.z/configure [configure args]
>       $ make
> 
> Otherwise, that looks good to me.

Attached is a revised patch. I chose to use the same sequence as
the one in gdb/README, just for consistency.

ChangeLog:

        * configure.ac: Abort the build with an error if trying to build
        GDB in tree.
        * configure: Regenerate.

For gdb-9-branch only... OK to push?

Comments

Simon Marchi Jan. 17, 2020, 6:24 p.m. UTC | #1
On 2020-01-17 1:15 p.m., Joel Brobecker wrote:
> Hi Simon,
> 
> Thanks for the review.
> 
>>> +if test x"${enable_gdb}" != x"no"; then
>>> +  # For this branch, we do not support building GDB in-tree.
>>> +  # Try to detect whether we are in this situation or not by
>>> +  # searching for a couple of known files in the source directory.
>>> +  if test -f gnulib/update-gnulib.sh -a -f gdb/ChangeLog; then
>>> +    AC_MSG_ERROR([GDB must be configured and built in a directory separate from its sources])
>>
>> Finish the message with a period?
> 
> Of course! FWIW, I modeled this to other calls to AC_MSG_ERROR ;-)
> 
>> Some people who only know the "./configure && make && make install" recipe
>> might not know how (or that it's even possible) to configure and build in a
>> separate directory, so they'll be stuck there.  I think it would be helpful
>> to give an example of how to do that, like:
>>
>>     GDB must be configured and built in a directory separate from its sources.
>>
>>     To do so, create a dedicated directory for your GDB build and invoke the configure
>>     script from that directory:
>>
>>       $ mkdir my-gdb-build
>>       $ cd my-gdb-build
>>       $ ../path/to/gdb-x.y.z/configure [configure args]
>>       $ make
>>
>> Otherwise, that looks good to me.
> 
> Attached is a revised patch. I chose to use the same sequence as
> the one in gdb/README, just for consistency.

LGTM, thanks!
Tom Tromey Jan. 17, 2020, 6:24 p.m. UTC | #2
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> For gdb-9-branch only... OK to push?

Looks good to me.

Tom
Joel Brobecker Jan. 17, 2020, 6:32 p.m. UTC | #3
> > Attached is a revised patch. I chose to use the same sequence as
> > the one in gdb/README, just for consistency.
> 
> LGTM, thanks!

Thanks Simon (and thanks Tom also). Now pushed!
Sergio Durigan Junior Jan. 30, 2020, 9:06 p.m. UTC | #4
On Friday, January 17 2020, Joel Brobecker wrote:

>> > Attached is a revised patch. I chose to use the same sequence as
>> > the one in gdb/README, just for consistency.
>> 
>> LGTM, thanks!
>
> Thanks Simon (and thanks Tom also). Now pushed!

Hey, Joel!

I just found out that this commit broke the snapshot generation for the
gdb-9-branch.  It's pretty easy to reproduce the problem locally:

  $ ./src-release.sh -x gdb
  ==> Cleaning sources.
  ==> Making gdb-9.0.90.20200130/
  ==> configure --target=i386-pc-linux-gnu  --disable-binutils --disable-gas --disable-gold --disable-gprof --disable-ld  --enable-gdb --enable-libctf --enable-libdecnumber --enable-readline --enable-sim
  configure: error: GDB must be configured and built in a directory separate from its sources.
  ...

I'm wondering what to do here.  I think I found a hacky and ugly
solution here, but I'm trying to see if there's a better approach.
Meanwhile, I thought I'd report this problem in case you already have a
better idea.

Cheers,
Eli Zaretskii Jan. 31, 2020, 7:34 a.m. UTC | #5
> From: Sergio Durigan Junior <sergiodj@redhat.com>
> Cc: Simon Marchi <simark@simark.ca>,  gdb-patches@sourceware.org,  Tom Tromey <tom@tromey.com>
> Date: Thu, 30 Jan 2020 16:06:18 -0500
> 
>   $ ./src-release.sh -x gdb
>   ==> Cleaning sources.
>   ==> Making gdb-9.0.90.20200130/
>   ==> configure --target=i386-pc-linux-gnu  --disable-binutils --disable-gas --disable-gold --disable-gprof --disable-ld  --enable-gdb --enable-libctf --enable-libdecnumber --enable-readline --enable-sim
>   configure: error: GDB must be configured and built in a directory separate from its sources.
>   ...
> 
> I'm wondering what to do here.  I think I found a hacky and ugly
> solution here, but I'm trying to see if there's a better approach.

A special command-line switch to 'configure', to be used by
src-release.sh?
Sergio Durigan Junior Jan. 31, 2020, 6:37 p.m. UTC | #6
On Friday, January 31 2020, Eli Zaretskii wrote:

>> From: Sergio Durigan Junior <sergiodj@redhat.com>
>> Cc: Simon Marchi <simark@simark.ca>,  gdb-patches@sourceware.org,  Tom Tromey <tom@tromey.com>
>> Date: Thu, 30 Jan 2020 16:06:18 -0500
>> 
>>   $ ./src-release.sh -x gdb
>>   ==> Cleaning sources.
>>   ==> Making gdb-9.0.90.20200130/
>>   ==> configure --target=i386-pc-linux-gnu --disable-binutils
>> --disable-gas --disable-gold --disable-gprof --disable-ld
>> --enable-gdb --enable-libctf --enable-libdecnumber --enable-readline
>> --enable-sim
>>   configure: error: GDB must be configured and built in a directory separate from its sources.
>>   ...
>> 
>> I'm wondering what to do here.  I think I found a hacky and ugly
>> solution here, but I'm trying to see if there's a better approach.
>
> A special command-line switch to 'configure', to be used by
> src-release.sh?

A quick attempt here didn't really work.  The script is able to finish
the build and create a tarball, but for some reason the gdb directory is
not configured/built.

Thanks,
diff mbox

Patch

From 8664d4b725eeb9c5845fa36331f2184d2c1f8596 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Fri, 17 Jan 2020 19:13:15 +0100
Subject: [PATCH] Abort configure immediately if building GDB in tree

The move of gnulib to the top src directory is causing the GDB build
to break if configured in tree. We hope to lift that limitation at
some point but, in the meantime, this commit allows us to abort
the initial configure right away with a clear error message should
the user attempt to build in tree.

ChangeLog:

        * configure.ac: Abort the build with an error if trying to build
        GDB in tree.
        * configure: Regenerate.
---
 configure    | 17 +++++++++++++++++
 configure.ac | 17 +++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/configure b/configure
index 6a9719f6091..7168a4e90e0 100755
--- a/configure
+++ b/configure
@@ -2279,6 +2279,23 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+if test x"${enable_gdb}" != x"no"; then
+  # For this branch, we do not support building GDB in-tree.
+  # Try to detect whether we are in this situation or not by
+  # searching for a couple of known files in the source directory.
+  if test -f gnulib/update-gnulib.sh -a -f gdb/ChangeLog; then
+    as_fn_error $? "GDB must be configured and built in a directory separate from its sources.
+
+To do so, create a dedicated directory for your GDB build and invoke
+the configure script from that directory:
+
+      $ mkdir build
+      $ cd build
+      $ <full path to your sources>/gdb-VERSION/configure [etc...]
+      $ make" "$LINENO" 5
+  fi
+fi
+
 progname=$0
 # if PWD already has a value, it is probably wrong.
 if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi
diff --git a/configure.ac b/configure.ac
index 7433badc217..e5ca1eaa57a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,23 @@  m4_include([config/isl.m4])
 AC_INIT(move-if-change)
 AC_DISABLE_OPTION_CHECKING
 
+if test x"${enable_gdb}" != x"no"; then
+  # For this branch, we do not support building GDB in-tree.
+  # Try to detect whether we are in this situation or not by
+  # searching for a couple of known files in the source directory.
+  if test -f gnulib/update-gnulib.sh -a -f gdb/ChangeLog; then
+    AC_MSG_ERROR([GDB must be configured and built in a directory separate from its sources.
+
+To do so, create a dedicated directory for your GDB build and invoke
+the configure script from that directory:
+
+      $ mkdir build
+      $ cd build
+      $ <full path to your sources>/gdb-VERSION/configure [[etc...]]
+      $ make])
+  fi
+fi
+
 progname=$0
 # if PWD already has a value, it is probably wrong.
 if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi
-- 
2.17.1