Title: [288916] trunk/Tools/buildstream
Revision
288916
Author
[email protected]
Date
2022-02-01 15:24:29 -0800 (Tue, 01 Feb 2022)

Log Message

[Flatpak SDK] Using thin archives with ld.bfd results in linker errors
https://bugs.webkit.org/show_bug.cgi?id=235975

Reviewed by Michael Catanzaro.

Import the two upstream that fix handling of thin archives to apply atop binutils 2.37.
The patches were found from https://sourceware.org/bugzilla/show_bug.cgi?id=28138 and
cherry-picked from the upstream binutils repository.

* elements/freedesktop-sdk.bst: List patch in the sources section.
* patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/buildstream/ChangeLog (288915 => 288916)


--- trunk/Tools/buildstream/ChangeLog	2022-02-01 23:21:06 UTC (rev 288915)
+++ trunk/Tools/buildstream/ChangeLog	2022-02-01 23:24:29 UTC (rev 288916)
@@ -1,3 +1,17 @@
+2022-02-01  Adrian Perez de Castro  <[email protected]>
+
+        [Flatpak SDK] Using thin archives with ld.bfd results in linker errors
+        https://bugs.webkit.org/show_bug.cgi?id=235975
+
+        Reviewed by Michael Catanzaro.
+
+        Import the two upstream that fix handling of thin archives to apply atop binutils 2.37.
+        The patches were found from https://sourceware.org/bugzilla/show_bug.cgi?id=28138 and
+        cherry-picked from the upstream binutils repository.
+
+        * elements/freedesktop-sdk.bst: List patch in the sources section.
+        * patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch: Added.
+
 2022-01-16  ChangSeok Oh  <[email protected]>
 
         [Flatpak SDK] local build is broken

Modified: trunk/Tools/buildstream/elements/freedesktop-sdk.bst (288915 => 288916)


--- trunk/Tools/buildstream/elements/freedesktop-sdk.bst	2022-02-01 23:21:06 UTC (rev 288915)
+++ trunk/Tools/buildstream/elements/freedesktop-sdk.bst	2022-02-01 23:24:29 UTC (rev 288916)
@@ -4,6 +4,8 @@
   url: gitlab_com:freedesktop-sdk/freedesktop-sdk.git
   track: 'release/21.08'
   ref: freedesktop-sdk-21.08.9-25-gfb49cd02a3869721e08be44e068979ce98da6da6
+- kind: patch
+  path: patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch
 config:
   options:
     target_arch: '%{arch}'

Added: trunk/Tools/buildstream/patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch (0 => 288916)


--- trunk/Tools/buildstream/patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch	                        (rev 0)
+++ trunk/Tools/buildstream/patches/0001-binutils-import-upstream-patches-for-thin-archive-su.patch	2022-02-01 23:24:29 UTC (rev 288916)
@@ -0,0 +1,294 @@
+From c7d1d247bbe4a21727d16bfa123181663f959534 Mon Sep 17 00:00:00 2001
+From: Adrian Perez de Castro <[email protected]>
+Date: Tue, 1 Feb 2022 17:41:35 +0200
+Subject: [PATCH] binutils: import upstream patches for thin archive support
+
+See https://sourceware.org/bugzilla/show_bug.cgi?id=28138
+---
+ .../bootstrap/include/binutils-source.yml     |   4 +
+ ...-bfd_error_malformed_archive-only-if.patch |  34 +++
+ ...le-descriptor-if-there-is-no-archive.patch | 219 ++++++++++++++++++
+ 3 files changed, 257 insertions(+)
+ create mode 100644 patches/binutils/0001-bfd-Set-error-to-bfd_error_malformed_archive-only-if.patch
+ create mode 100644 patches/binutils/0002-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch
+
+diff --git a/elements/bootstrap/include/binutils-source.yml b/elements/bootstrap/include/binutils-source.yml
+index 339746847..5c5a9e2e6 100644
+--- a/elements/bootstrap/include/binutils-source.yml
++++ b/elements/bootstrap/include/binutils-source.yml
+@@ -17,3 +17,7 @@ sources:
+   track-extra:
+   - binutils-2_37-branch
+   ref: binutils-2_37-0-g116a737f438d03a1bd6aa706b6ea0b4022f3b7e2
++- kind: patch
++  path: patches/binutils/0001-bfd-Set-error-to-bfd_error_malformed_archive-only-if.patch
++- kind: patch
++  path: patches/binutils/0002-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch
+diff --git a/patches/binutils/0001-bfd-Set-error-to-bfd_error_malformed_archive-only-if.patch b/patches/binutils/0001-bfd-Set-error-to-bfd_error_malformed_archive-only-if.patch
+new file mode 100644
+index 000000000..aa1edf914
+--- /dev/null
++++ b/patches/binutils/0001-bfd-Set-error-to-bfd_error_malformed_archive-only-if.patch
+@@ -0,0 +1,34 @@
++From 1554891774c6f7c7c131c4d855411bbe04239b10 Mon Sep 17 00:00:00 2001
++From: "H.J. Lu" <[email protected]>
++Date: Mon, 26 Jul 2021 05:37:57 -0700
++Subject: [PATCH 1/2] bfd: Set error to bfd_error_malformed_archive only if
++ unset
++
++When reading an archive member, set error to bfd_error_malformed_archive
++on open_nested_file failure only if the error is unset.
++
++	PR ld/28138
++	* archive.c (_bfd_get_elt_at_filepos): Don't set error to
++	bfd_error_malformed_archive if it has been set.
++---
++ bfd/archive.c | 3 ++-
++ 1 file changed, 2 insertions(+), 1 deletion(-)
++
++diff --git a/bfd/archive.c b/bfd/archive.c
++index 5f350b8e5ce..3868fc9f7ed 100644
++--- a/bfd/archive.c
+++++ b/bfd/archive.c
++@@ -713,8 +713,9 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
++ 
++       /* It's not an element of a nested archive;
++ 	 open the external file as a bfd.  */
+++      bfd_set_error (bfd_error_no_error);
++       n_bfd = open_nested_file (filename, archive);
++-      if (n_bfd == NULL)
+++      if (n_bfd == NULL && bfd_get_error () == bfd_error_no_error)
++ 	bfd_set_error (bfd_error_malformed_archive);
++     }
++   else
++-- 
++2.35.1
++
+diff --git a/patches/binutils/0002-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch b/patches/binutils/0002-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch
+new file mode 100644
+index 000000000..e4886151f
+--- /dev/null
++++ b/patches/binutils/0002-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch
+@@ -0,0 +1,219 @@
++From 4d70a667aa6e434840411107d6f6c0b85556f7f0 Mon Sep 17 00:00:00 2001
++From: "H.J. Lu" <[email protected]>
++Date: Mon, 26 Jul 2021 05:59:55 -0700
++Subject: [PATCH 2/2] bfd: Close the file descriptor if there is no archive fd
++
++Close the file descriptor if there is no archive plugin file descriptor
++to avoid running out of file descriptors on thin archives with many
++archive members.
++
++bfd/
++
++	PR ld/28138
++	* plugin.c (bfd_plugin_close_file_descriptor): Close the file
++	descriptor there is no archive plugin file descriptor.
++
++ld/
++
++	PR ld/28138
++	* testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
++	* testsuite/ld-plugin/pr28138.c: New file.
++	* testsuite/ld-plugin/pr28138-1.c: Likewise.
++	* testsuite/ld-plugin/pr28138-2.c: Likewise.
++	* testsuite/ld-plugin/pr28138-3.c: Likewise.
++	* testsuite/ld-plugin/pr28138-4.c: Likewise.
++	* testsuite/ld-plugin/pr28138-5.c: Likewise.
++	* testsuite/ld-plugin/pr28138-6.c: Likewise.
++	* testsuite/ld-plugin/pr28138-7.c: Likewise.
++---
++ bfd/plugin.c                       |  8 ++++++++
++ ld/testsuite/ld-plugin/lto.exp     | 30 ++++++++++++++++++++++++++++++
++ ld/testsuite/ld-plugin/pr28138-1.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-2.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-3.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-4.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-5.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-6.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138-7.c |  6 ++++++
++ ld/testsuite/ld-plugin/pr28138.c   | 20 ++++++++++++++++++++
++ 10 files changed, 100 insertions(+)
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
++ create mode 100644 ld/testsuite/ld-plugin/pr28138.c
++
++diff --git a/bfd/plugin.c b/bfd/plugin.c
++index 6cfa2b66470..3bab8febe88 100644
++--- a/bfd/plugin.c
+++++ b/bfd/plugin.c
++@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
++ 	     && !bfd_is_thin_archive (abfd->my_archive))
++ 	abfd = abfd->my_archive;
++ 
+++      /* Close the file descriptor if there is no archive plugin file
+++	 descriptor.  */
+++      if (abfd->archive_plugin_fd == -1)
+++	{
+++	  close (fd);
+++	  return;
+++	}
+++
++       abfd->archive_plugin_fd_open_count--;
++       /* Dup the archive plugin file descriptor for later use, which
++ 	 will be closed by _bfd_archive_close_and_cleanup.  */
++diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
++index def69e43ab3..63be062032b 100644
++--- a/ld/testsuite/ld-plugin/lto.exp
+++++ b/ld/testsuite/ld-plugin/lto.exp
++@@ -930,4 +930,34 @@ if { [check_lto_fat_available] } {
++     }
++ }
++ 
+++run_cc_link_tests [list \
+++    [list \
+++	"Build pr28138.a" \
+++	"-T" "" \
+++	{pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+++	 pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+++    ] \
+++    [list \
+++	"Build pr28138.o" \
+++	"" "" \
+++	{pr28138.c} {} \
+++    ] \
+++]
+++
+++set exec_output [run_host_cmd "sh" \
+++			      "-c \"ulimit -n 20; \
+++			      $CC -Btmpdir/ld -o tmpdir/pr28138 \
+++			      tmpdir/pr28138.o tmpdir/pr28138.a\""]
+++set exec_output [prune_warnings $exec_output]
+++if [string match "" $exec_output] then {
+++    set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+++    if [string match "PASS" $exec_output] then {
+++	pass "PR ld/28138"
+++    } else {
+++	fail "PR ld/28138"
+++    }
+++} else {
+++    fail "PR ld/28138"
+++}
+++
++ restore_notify
++diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
++new file mode 100644
++index 00000000000..51d119e1642
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-1.c
++@@ -0,0 +1,6 @@
+++extern int a0(void);
+++int
+++a1(void)
+++{
+++  return 1 + a0();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
++new file mode 100644
++index 00000000000..1120cd797e9
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-2.c
++@@ -0,0 +1,6 @@
+++extern int a1(void);
+++int
+++a2(void)
+++{
+++  return 1 + a1();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
++new file mode 100644
++index 00000000000..ec464947ee6
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-3.c
++@@ -0,0 +1,6 @@
+++extern int a2(void);
+++int
+++a3(void)
+++{
+++  return 1 + a2();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
++new file mode 100644
++index 00000000000..475701b2c5c
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-4.c
++@@ -0,0 +1,6 @@
+++extern int a3(void);
+++int
+++a4(void)
+++{
+++  return 1 + a3();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
++new file mode 100644
++index 00000000000..e24f86c363e
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-5.c
++@@ -0,0 +1,6 @@
+++extern int a4(void);
+++int
+++a5(void)
+++{
+++  return 1 + a4();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
++new file mode 100644
++index 00000000000..b5b938bdb21
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-6.c
++@@ -0,0 +1,6 @@
+++extern int a5(void);
+++int
+++a6(void)
+++{
+++  return 1 + a5();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
++new file mode 100644
++index 00000000000..4ef75bf0f0c
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138-7.c
++@@ -0,0 +1,6 @@
+++extern int a6(void);
+++int
+++a7(void)
+++{
+++  return 1 + a6();
+++}
++diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
++new file mode 100644
++index 00000000000..68252c9f382
++--- /dev/null
+++++ b/ld/testsuite/ld-plugin/pr28138.c
++@@ -0,0 +1,20 @@
+++#include <stdio.h>
+++
+++extern int a7(void);
+++
+++int
+++a0(void)
+++{
+++  return 0;
+++}
+++
+++int
+++main()
+++{
+++  if (a7() == 7)
+++    {
+++      printf ("PASS\n");
+++      return 0;
+++    }
+++  return 1;
+++}
++-- 
++2.35.1
++
+-- 
+2.35.1
+
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to