* [PATCH] Carry the gnulib getcwd backport as a patch
@ 2018-09-18 21:21 Simon Marchi
2018-09-18 21:33 ` John Baldwin
2018-09-18 21:39 ` Tom Tromey
0 siblings, 2 replies; 7+ messages in thread
From: Simon Marchi @ 2018-09-18 21:21 UTC (permalink / raw)
To: gdb-patches; +Cc: Sergio Durigan Junior, Simon Marchi
Commit
e2fc52e7457 ("Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling GDB")
backported some changes from a future gnulib version to our import.
However, this means that every time someone wants to change our gnulib
import (e.g. add a module), they must make sure not to include that
backported change. It also means that someone running the
update-gnulib.sh script without changes will get some diffs and wonder
why.
Instead, I suggest we carry that backport as a patch applied by the
update-gnulib.sh script after running the import tool. It will make it
clear what backport or local modification we have and should make
running update-gnulib.sh give a reproducible result.
There is a hunk in the configure file in this patch, this is because the
commit that backported the getcwd bits didn't include the re-generated
configure.
Note: you'll need this patch as well to get deterministic results:
Generate aclocal-m4-deps.mk more deterministically and portably.
https://sourceware.org/ml/gdb-patches/2018-09/msg00643.html
gdb/ChangeLog:
* patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch:
New file.
* update-gnulib.sh: Apply patch.
* configure: Re-generate.
---
gdb/gnulib/configure | 18 ++++-
...-Use-system-s-getcwd-when-cross-comp.patch | 69 +++++++++++++++++++
gdb/gnulib/update-gnulib.sh | 12 ++++
3 files changed, 96 insertions(+), 3 deletions(-)
create mode 100644 gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
diff --git a/gdb/gnulib/configure b/gdb/gnulib/configure
index 8c3027635f5..092db16ba28 100644
--- a/gdb/gnulib/configure
+++ b/gdb/gnulib/configure
@@ -16921,10 +16921,22 @@ else
# Arrange for deletion of the temporary directory this test creates.
ac_clean_files="$ac_clean_files confdir3"
if test "$cross_compiling" = yes; then :
- case "$host_os" in
- aix*) gl_cv_func_getcwd_path_max='no, it has the AIX bug';;
- *) gl_cv_func_getcwd_path_max=no;;
+ # Cross-compilation guesses:
+ case "$host_os" in
+ aix*) # On AIX, it has the AIX bug.
+ gl_cv_func_getcwd_path_max='no, it has the AIX bug' ;;
+ gnu*) # On Hurd, it is 'yes'.
+ gl_cv_func_getcwd_path_max=yes ;;
+ linux* | kfreebsd*)
+ # On older Linux+glibc it's 'no, but it is partly working',
+ # on newer Linux+glibc it's 'yes'.
+ # On Linux+musl libc, it's 'no, but it is partly working'.
+ # On kFreeBSD+glibc, it's 'no, but it is partly working'.
+ gl_cv_func_getcwd_path_max='no, but it is partly working' ;;
+ *) # If we don't know, assume the worst.
+ gl_cv_func_getcwd_path_max=no ;;
esac
+
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
diff --git a/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch b/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
new file mode 100644
index 00000000000..1d8cdf6b901
--- /dev/null
+++ b/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
@@ -0,0 +1,69 @@
+From a7447215cdc492a077732420a3f0db6d48b34d51 Mon Sep 17 00:00:00 2001
+From: Sergio Durigan Junior <sergiodj@redhat.com>
+Date: Mon, 10 Sep 2018 12:52:04 -0400
+Subject: [PATCH] Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling
+ GDB
+
+This is a backport of a gnulib fix for the following bug:
+
+ https://sourceware.org/bugzilla/show_bug.cgi?id=23558
+
+The problem reported there is about the replacement of 'getcwd' when
+cross-compiling GDB. With our current gnulib copy, the mechanism for
+deciding whether to use the system's 'getcwd' or gnulib's version is
+too simplistic and pessimistic, so when cross-compiling we always end
+up using gnulib's version, which has a limitation: it cannot handle
+the situation when the parent directory doesn't have read permissions.
+
+The solution is to backport the following gnulib commit:
+
+ commit a96d2e67052c879b1bcc5bc461722beac75fc372
+ Author: Bruno Haible <bruno@clisp.org>
+ Date: Thu Aug 23 21:13:19 2018 +0200
+
+ getcwd: Add cross-compilation guesses.
+
+gdb/ChangeLog:
+2018-09-10 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR gdb/23555
+ PR gdb/23558
+ * gnulib/import/m4/getcwd-path-max.m4: Add cross-compilation
+ guesses.
+---
+ gdb/gnulib/import/m4/getcwd-path-max.m4 | 20 ++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
+
+diff --git a/gdb/gnulib/import/m4/getcwd-path-max.m4 b/gdb/gnulib/import/m4/getcwd-path-max.m4
+index 2531ccff65c..90bbc77dea1 100644
+--- a/gdb/gnulib/import/m4/getcwd-path-max.m4
++++ b/gdb/gnulib/import/m4/getcwd-path-max.m4
+@@ -209,9 +209,21 @@ main ()
+ 32) gl_cv_func_getcwd_path_max='yes, but with shorter paths';;
+ *) gl_cv_func_getcwd_path_max=no;;
+ esac],
+- [case "$host_os" in
+- aix*) gl_cv_func_getcwd_path_max='no, it has the AIX bug';;
+- *) gl_cv_func_getcwd_path_max=no;;
+- esac])
++ [# Cross-compilation guesses:
++ case "$host_os" in
++ aix*) # On AIX, it has the AIX bug.
++ gl_cv_func_getcwd_path_max='no, it has the AIX bug' ;;
++ gnu*) # On Hurd, it is 'yes'.
++ gl_cv_func_getcwd_path_max=yes ;;
++ linux* | kfreebsd*)
++ # On older Linux+glibc it's 'no, but it is partly working',
++ # on newer Linux+glibc it's 'yes'.
++ # On Linux+musl libc, it's 'no, but it is partly working'.
++ # On kFreeBSD+glibc, it's 'no, but it is partly working'.
++ gl_cv_func_getcwd_path_max='no, but it is partly working' ;;
++ *) # If we don't know, assume the worst.
++ gl_cv_func_getcwd_path_max=no ;;
++ esac
++ ])
+ ])
+ ])
+--
+2.19.0
+
diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
index 3077424622b..dff1254830b 100755
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -157,6 +157,18 @@ if [ $? -ne 0 ]; then
exit 1
fi
+# Apply our local patches.
+apply_patches ()
+{
+ patch -p3 -f -i "$1"
+ if [ $? -ne 0 ]; then
+ echo "Failed to apply some patches. Aborting."
+ exit 1
+ fi
+}
+
+apply_patches "patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch"
+
# Regenerate all necessary files...
aclocal -Iimport/m4 &&
autoconf &&
--
2.19.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
2018-09-18 21:21 [PATCH] Carry the gnulib getcwd backport as a patch Simon Marchi
@ 2018-09-18 21:33 ` John Baldwin
2018-09-18 21:39 ` Tom Tromey
1 sibling, 0 replies; 7+ messages in thread
From: John Baldwin @ 2018-09-18 21:33 UTC (permalink / raw)
To: Simon Marchi, gdb-patches; +Cc: Sergio Durigan Junior
On 9/18/18 2:21 PM, Simon Marchi wrote:
> Commit
>
> e2fc52e7457 ("Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling GDB")
>
> backported some changes from a future gnulib version to our import.
> However, this means that every time someone wants to change our gnulib
> import (e.g. add a module), they must make sure not to include that
> backported change. It also means that someone running the
> update-gnulib.sh script without changes will get some diffs and wonder
> why.
>
> Instead, I suggest we carry that backport as a patch applied by the
> update-gnulib.sh script after running the import tool. It will make it
> clear what backport or local modification we have and should make
> running update-gnulib.sh give a reproducible result.
>
> There is a hunk in the configure file in this patch, this is because the
> commit that backported the getcwd bits didn't include the re-generated
> configure.
This looks good to me. I've verified it generates ok for me on a FreeBSD host
as well.
--
John Baldwin
                                                                           Â
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
2018-09-18 21:21 [PATCH] Carry the gnulib getcwd backport as a patch Simon Marchi
2018-09-18 21:33 ` John Baldwin
@ 2018-09-18 21:39 ` Tom Tromey
2018-09-18 21:49 ` Simon Marchi
1 sibling, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2018-09-18 21:39 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches, Sergio Durigan Junior
>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
Simon> Instead, I suggest we carry that backport as a patch applied by the
Simon> update-gnulib.sh script after running the import tool. It will make it
Simon> clear what backport or local modification we have and should make
Simon> running update-gnulib.sh give a reproducible result.
This seems like a good idea to me.
Simon> +# Apply our local patches.
Simon> +apply_patches ()
This should probably be "apply_patch" since it just applies a single patch.
Also there is a comment near the top of update-gnulib.sh:
# This script will also make a number of other verifications:
# . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
# . The correct versions of the auto-tools that are used to
# regenerate the various scripts and Makefiles are on the PATH.
I think an addition here about updating the patches would be good.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
2018-09-18 21:39 ` Tom Tromey
@ 2018-09-18 21:49 ` Simon Marchi
[not found] ` <87woriqxmj.fsf@tromey.com>
0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2018-09-18 21:49 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Sergio Durigan Junior
On 2018-09-18 05:38 PM, Tom Tromey wrote:
> Simon> +# Apply our local patches.
> Simon> +apply_patches ()
>
> This should probably be "apply_patch" since it just applies a single patch.
Oops yes.
> Also there is a comment near the top of update-gnulib.sh:
>
> # This script will also make a number of other verifications:
> # . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
> # . The correct versions of the auto-tools that are used to
> # regenerate the various scripts and Makefiles are on the PATH.
>
> I think an addition here about updating the patches would be good.
I don't think it belongs in that particular list, because it's not a verification,
but I've added a note in that header.
Does this look good?
From f0584664629ee49216e5b56810c9eec83f9f3a8f Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Tue, 18 Sep 2018 16:42:53 -0400
Subject: [PATCH] Carry the gnulib getcwd backport as a patch
Commit
e2fc52e7457 ("Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling GDB")
backported some changes from a future gnulib version to our import.
However, this means that every time someone wants to change our gnulib
import (e.g. add a module), they must make sure not to include that
backported change. It also means that someone running the
update-gnulib.sh script without changes will get some diffs and wonder
why.
Instead, I suggest we carry that backport as a patch applied by the
update-gnulib.sh script after running the import tool. It will make it
clear what backport or local modification we have and should make
running update-gnulib.sh give a reproducible result.
There is a hunk in the configure file in this patch, this is because the
commit that backported the getcwd bits didn't include the re-generated
configure.
gdb/ChangeLog:
* patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch:
New file.
* update-gnulib.sh: Apply patch.
* configure: Re-generate.
---
gdb/gnulib/configure | 18 ++++-
...-Use-system-s-getcwd-when-cross-comp.patch | 69 +++++++++++++++++++
gdb/gnulib/update-gnulib.sh | 14 ++++
3 files changed, 98 insertions(+), 3 deletions(-)
create mode 100644 gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
diff --git a/gdb/gnulib/configure b/gdb/gnulib/configure
index 5fd52d45ac9..dc6c5b66573 100644
--- a/gdb/gnulib/configure
+++ b/gdb/gnulib/configure
@@ -17696,10 +17696,22 @@ else
# Arrange for deletion of the temporary directory this test creates.
ac_clean_files="$ac_clean_files confdir3"
if test "$cross_compiling" = yes; then :
- case "$host_os" in
- aix*) gl_cv_func_getcwd_path_max='no, it has the AIX bug';;
- *) gl_cv_func_getcwd_path_max=no;;
+ # Cross-compilation guesses:
+ case "$host_os" in
+ aix*) # On AIX, it has the AIX bug.
+ gl_cv_func_getcwd_path_max='no, it has the AIX bug' ;;
+ gnu*) # On Hurd, it is 'yes'.
+ gl_cv_func_getcwd_path_max=yes ;;
+ linux* | kfreebsd*)
+ # On older Linux+glibc it's 'no, but it is partly working',
+ # on newer Linux+glibc it's 'yes'.
+ # On Linux+musl libc, it's 'no, but it is partly working'.
+ # On kFreeBSD+glibc, it's 'no, but it is partly working'.
+ gl_cv_func_getcwd_path_max='no, but it is partly working' ;;
+ *) # If we don't know, assume the worst.
+ gl_cv_func_getcwd_path_max=no ;;
esac
+
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
diff --git a/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch b/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
new file mode 100644
index 00000000000..1d8cdf6b901
--- /dev/null
+++ b/gdb/gnulib/patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch
@@ -0,0 +1,69 @@
+From a7447215cdc492a077732420a3f0db6d48b34d51 Mon Sep 17 00:00:00 2001
+From: Sergio Durigan Junior <sergiodj@redhat.com>
+Date: Mon, 10 Sep 2018 12:52:04 -0400
+Subject: [PATCH] Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling
+ GDB
+
+This is a backport of a gnulib fix for the following bug:
+
+ https://sourceware.org/bugzilla/show_bug.cgi?id=23558
+
+The problem reported there is about the replacement of 'getcwd' when
+cross-compiling GDB. With our current gnulib copy, the mechanism for
+deciding whether to use the system's 'getcwd' or gnulib's version is
+too simplistic and pessimistic, so when cross-compiling we always end
+up using gnulib's version, which has a limitation: it cannot handle
+the situation when the parent directory doesn't have read permissions.
+
+The solution is to backport the following gnulib commit:
+
+ commit a96d2e67052c879b1bcc5bc461722beac75fc372
+ Author: Bruno Haible <bruno@clisp.org>
+ Date: Thu Aug 23 21:13:19 2018 +0200
+
+ getcwd: Add cross-compilation guesses.
+
+gdb/ChangeLog:
+2018-09-10 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR gdb/23555
+ PR gdb/23558
+ * gnulib/import/m4/getcwd-path-max.m4: Add cross-compilation
+ guesses.
+---
+ gdb/gnulib/import/m4/getcwd-path-max.m4 | 20 ++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
+
+diff --git a/gdb/gnulib/import/m4/getcwd-path-max.m4 b/gdb/gnulib/import/m4/getcwd-path-max.m4
+index 2531ccff65c..90bbc77dea1 100644
+--- a/gdb/gnulib/import/m4/getcwd-path-max.m4
++++ b/gdb/gnulib/import/m4/getcwd-path-max.m4
+@@ -209,9 +209,21 @@ main ()
+ 32) gl_cv_func_getcwd_path_max='yes, but with shorter paths';;
+ *) gl_cv_func_getcwd_path_max=no;;
+ esac],
+- [case "$host_os" in
+- aix*) gl_cv_func_getcwd_path_max='no, it has the AIX bug';;
+- *) gl_cv_func_getcwd_path_max=no;;
+- esac])
++ [# Cross-compilation guesses:
++ case "$host_os" in
++ aix*) # On AIX, it has the AIX bug.
++ gl_cv_func_getcwd_path_max='no, it has the AIX bug' ;;
++ gnu*) # On Hurd, it is 'yes'.
++ gl_cv_func_getcwd_path_max=yes ;;
++ linux* | kfreebsd*)
++ # On older Linux+glibc it's 'no, but it is partly working',
++ # on newer Linux+glibc it's 'yes'.
++ # On Linux+musl libc, it's 'no, but it is partly working'.
++ # On kFreeBSD+glibc, it's 'no, but it is partly working'.
++ gl_cv_func_getcwd_path_max='no, but it is partly working' ;;
++ *) # If we don't know, assume the worst.
++ gl_cv_func_getcwd_path_max=no ;;
++ esac
++ ])
+ ])
+ ])
+--
+2.19.0
+
diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
index 327b37f3a3c..90b103e50a2 100755
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -27,6 +27,8 @@
# . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
# . The correct versions of the auto-tools that are used to
# regenerate the various scripts and Makefiles are on the PATH.
+#
+# It will also apply any local patches to gnulib we carry at the time.
# The list of gnulib modules we are importing in GDB.
IMPORTED_GNULIB_MODULES="\
@@ -158,6 +160,18 @@ if [ $? -ne 0 ]; then
exit 1
fi
+# Apply our local patches.
+apply_patch()
+{
+ patch -p3 -f -i "$1"
+ if [ $? -ne 0 ]; then
+ echo "Failed to apply some patches. Aborting."
+ exit 1
+ fi
+}
+
+apply_patch "patches/0001-Fix-PR-gdb-23558-Use-system-s-getcwd-when-cross-comp.patch"
+
# Regenerate all necessary files...
aclocal -Iimport/m4 &&
autoconf &&
--
2.19.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
[not found] ` <87woriqxmj.fsf@tromey.com>
@ 2018-09-18 21:59 ` Simon Marchi
2018-09-19 2:42 ` Sergio Durigan Junior
0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2018-09-18 21:59 UTC (permalink / raw)
To: Tom Tromey; +Cc: Simon Marchi, gdb-patches, Sergio Durigan Junior
On 2018-09-18 17:55, Tom Tromey wrote:
> Simon> Does this look good?
>
> Yes, thanks.
>
> Tom
Thanks, I'll wait to see if Sergio has any comment about this before
pushing.
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
2018-09-18 21:59 ` Simon Marchi
@ 2018-09-19 2:42 ` Sergio Durigan Junior
2018-09-19 3:49 ` Simon Marchi
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Durigan Junior @ 2018-09-19 2:42 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, Simon Marchi, gdb-patches
On Tuesday, September 18 2018, Simon Marchi wrote:
> On 2018-09-18 17:55, Tom Tromey wrote:
>> Simon> Does this look good?
>>
>> Yes, thanks.
>>
>> Tom
>
> Thanks, I'll wait to see if Sergio has any comment about this before
> pushing.
Thanks for taking care of this. I agree with the approach taken here
(as discussed on IRC), and am OK with the patch.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Carry the gnulib getcwd backport as a patch
2018-09-19 2:42 ` Sergio Durigan Junior
@ 2018-09-19 3:49 ` Simon Marchi
0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2018-09-19 3:49 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: Tom Tromey, Simon Marchi, gdb-patches
On 2018-09-18 22:42, Sergio Durigan Junior wrote:
> On Tuesday, September 18 2018, Simon Marchi wrote:
>
>> On 2018-09-18 17:55, Tom Tromey wrote:
>>> Simon> Does this look good?
>>>
>>> Yes, thanks.
>>>
>>> Tom
>>
>> Thanks, I'll wait to see if Sergio has any comment about this before
>> pushing.
>
> Thanks for taking care of this. I agree with the approach taken here
> (as discussed on IRC), and am OK with the patch.
Thanks, I pushed it.
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-09-19 3:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 21:21 [PATCH] Carry the gnulib getcwd backport as a patch Simon Marchi
2018-09-18 21:33 ` John Baldwin
2018-09-18 21:39 ` Tom Tromey
2018-09-18 21:49 ` Simon Marchi
[not found] ` <87woriqxmj.fsf@tromey.com>
2018-09-18 21:59 ` Simon Marchi
2018-09-19 2:42 ` Sergio Durigan Junior
2018-09-19 3:49 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox