Bug 1779691 - Stop applying D116995 to clang-trunk. r=firefox-build-system-reviewers,andi

It was applied upstream.

Also rename the patch for clang-14, with its upstream-landed
description.

Differential Revision: https://phabricator.services.mozilla.com/D151900
This commit is contained in:
Mike Hommey
2022-07-20 00:29:07 +00:00
parent 9c40d280f6
commit fabb213a49
3 changed files with 56 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
"Remove-FlushViewOfFile-when-unmaping-gcda-files.patch", "Remove-FlushViewOfFile-when-unmaping-gcda-files.patch",
"fuzzing_ccov_build_clang_12.patch", "fuzzing_ccov_build_clang_12.patch",
"win64-no-symlink.patch", "win64-no-symlink.patch",
"D116995.diff", "llvmorg-15-init-16512-g4b1e3d193706.patch",
"revert-llvmorg-14-init-14141-gd6d3000a2f6d.patch", "revert-llvmorg-14-init-14141-gd6d3000a2f6d.patch",
"revert-llvmorg-14-init-11890-gf86deb18cab6.patch" "revert-llvmorg-14-init-11890-gf86deb18cab6.patch"
] ]

View File

@@ -7,7 +7,6 @@
"bug47258-extract-symbols-mbcs.patch", "bug47258-extract-symbols-mbcs.patch",
"fuzzing_ccov_build_clang_12.patch", "fuzzing_ccov_build_clang_12.patch",
"win64-no-symlink.patch", "win64-no-symlink.patch",
"D116995.diff",
"revert-llvmorg-15-init-13446-g7524fe962e47.patch", "revert-llvmorg-15-init-13446-g7524fe962e47.patch",
"revert-llvmorg-14-init-14141-gd6d3000a2f6d.patch", "revert-llvmorg-14-init-14141-gd6d3000a2f6d.patch",
"revert-llvmorg-14-init-11890-gf86deb18cab6.patch" "revert-llvmorg-14-init-11890-gf86deb18cab6.patch"

View File

@@ -1,4 +1,7 @@
[gold] Ignore bitcode from sections inside object files From 8482662676a4b6ef79a718c8c09943cb15241664 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Tue, 21 Jun 2022 22:22:11 -0700
Subject: [PATCH] [gold] Ignore bitcode from sections inside object files
-fembed-bitcode will put bitcode into special sections within object -fembed-bitcode will put bitcode into special sections within object
files, but this is not meant to be used by LTO, so the gold plugin files, but this is not meant to be used by LTO, so the gold plugin
@@ -6,8 +9,51 @@ should ignore it.
https://github.com/llvm/llvm-project/issues/47216 https://github.com/llvm/llvm-project/issues/47216
Reviewed By: tejohnson, MaskRay
Differential Revision: https://reviews.llvm.org/D116995
---
llvm/docs/BitCodeFormat.rst | 3 ++-
llvm/docs/GoldPlugin.rst | 4 ++++
.../tools/gold/X86/Inputs/bcsection-lib.ll | 6 +++++
llvm/test/tools/gold/X86/Inputs/bcsection.s | 5 ++++
llvm/test/tools/gold/X86/bcsection.ll | 23 +++++++++++++++----
llvm/tools/gold/gold-plugin.cpp | 8 +++++++
6 files changed, 43 insertions(+), 6 deletions(-)
create mode 100644 llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll
diff --git a/llvm/docs/BitCodeFormat.rst b/llvm/docs/BitCodeFormat.rst
index 8e81a7daa459..df1f6915d7d5 100644
--- a/llvm/docs/BitCodeFormat.rst
+++ b/llvm/docs/BitCodeFormat.rst
@@ -475,7 +475,8 @@ formats. This wrapper format is useful for accommodating LTO in compilation
pipelines where intermediate objects must be native object files which contain
metadata in other sections.
-Not all tools support this format.
+Not all tools support this format. For example, lld and the gold plugin will
+ignore these sections when linking object files.
.. _encoding of LLVM IR:
diff --git a/llvm/docs/GoldPlugin.rst b/llvm/docs/GoldPlugin.rst
index ce310bc2cf3c..07d2fc203eba 100644
--- a/llvm/docs/GoldPlugin.rst
+++ b/llvm/docs/GoldPlugin.rst
@@ -17,6 +17,10 @@ and above also supports LTO via plugins. However, usage of the LLVM
gold plugin with ld.bfd is not tested and therefore not officially
supported or recommended.
+As of LLVM 15, the gold plugin will ignore bitcode from the ``.llvmbc``
+section inside of ELF object files. However, LTO with bitcode files
+is still supported.
+
.. _`gold linker`: http://sourceware.org/binutils
.. _`GCC LTO`: http://gcc.gnu.org/wiki/LinkTimeOptimization
.. _`gold plugin interface`: http://gcc.gnu.org/wiki/whopr/driver
diff --git a/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll b/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll diff --git a/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll b/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll
new file mode 100644 new file mode 100644
index 000000000000..ef3557c19cdc
--- /dev/null --- /dev/null
+++ b/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll +++ b/llvm/test/tools/gold/X86/Inputs/bcsection-lib.ll
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
@@ -18,6 +64,7 @@ new file mode 100644
+ ret i32 0 + ret i32 0
+} +}
diff --git a/llvm/test/tools/gold/X86/Inputs/bcsection.s b/llvm/test/tools/gold/X86/Inputs/bcsection.s diff --git a/llvm/test/tools/gold/X86/Inputs/bcsection.s b/llvm/test/tools/gold/X86/Inputs/bcsection.s
index ede1e5c532dd..c523612563b4 100644
--- a/llvm/test/tools/gold/X86/Inputs/bcsection.s --- a/llvm/test/tools/gold/X86/Inputs/bcsection.s
+++ b/llvm/test/tools/gold/X86/Inputs/bcsection.s +++ b/llvm/test/tools/gold/X86/Inputs/bcsection.s
@@ -1,2 +1,7 @@ @@ -1,2 +1,7 @@
@@ -29,6 +76,7 @@ diff --git a/llvm/test/tools/gold/X86/Inputs/bcsection.s b/llvm/test/tools/gold/
.section .llvmbc .section .llvmbc
.incbin "bcsection.bc" .incbin "bcsection.bc"
diff --git a/llvm/test/tools/gold/X86/bcsection.ll b/llvm/test/tools/gold/X86/bcsection.ll diff --git a/llvm/test/tools/gold/X86/bcsection.ll b/llvm/test/tools/gold/X86/bcsection.ll
index 6d3481f8f966..09882d83fe91 100644
--- a/llvm/test/tools/gold/X86/bcsection.ll --- a/llvm/test/tools/gold/X86/bcsection.ll
+++ b/llvm/test/tools/gold/X86/bcsection.ll +++ b/llvm/test/tools/gold/X86/bcsection.ll
@@ -2,16 +2,29 @@ @@ -2,16 +2,29 @@
@@ -67,15 +115,16 @@ diff --git a/llvm/test/tools/gold/X86/bcsection.ll b/llvm/test/tools/gold/X86/bc
ret i32 0 ret i32 0
} }
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 180c181368e3..294c7a3d6178 100644
--- a/llvm/tools/gold/gold-plugin.cpp --- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp
@@ -540,6 +540,14 @@ @@ -540,6 +540,14 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
BufferRef = Buffer->getMemBufferRef(); BufferRef = Buffer->getMemBufferRef();
} }
+ // Only use bitcode files for LTO. InputFile::create() will load bitcode + // Only use bitcode files for LTO. InputFile::create() will load bitcode
+ // from special sections within a binary object, this bitcode is typically + // from the .llvmbc section within a binary object, this bitcode is typically
+ // generated by -fembed-bitcode and is not meant for LTO use. + // generated by -fembed-bitcode and is not to be used by LLVMgold.so for LTO.
+ if (identify_magic(BufferRef.getBuffer()) != file_magic::bitcode) { + if (identify_magic(BufferRef.getBuffer()) != file_magic::bitcode) {
+ *claimed = 0; + *claimed = 0;
+ return LDPS_OK; + return LDPS_OK;
@@ -84,4 +133,6 @@ diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
*claimed = 1; *claimed = 1;
Expected<std::unique_ptr<InputFile>> ObjOrErr = InputFile::create(BufferRef); Expected<std::unique_ptr<InputFile>> ObjOrErr = InputFile::create(BufferRef);
--
2.37.1.1.g659da70093