Squash merge from upstream-snapshot

This commit is contained in:
Tom Stellard 2024-02-05 20:49:55 +00:00
parent bec3936967
commit 152d45a205
9 changed files with 184 additions and 171 deletions

View File

@ -1,4 +1,4 @@
From d68a5a7817dc0d43853d8b84c9185dc24338664f Mon Sep 17 00:00:00 2001
From 03a4a6131a18c47a32a02a0c48f6d32358561920 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Wed, 6 Oct 2021 05:32:44 +0000
Subject: [PATCH] Driver: Add a gcc equivalent triple to the list of triples to
@ -15,10 +15,10 @@ Differential Revision: https://reviews.llvm.org/D111207
1 file changed, 22 insertions(+)
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index fe5bda5c6605..fd4a7f72be14 100644
index 16cf57072272..49084bd2ce25 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1884,6 +1884,18 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args,
@@ -2078,6 +2078,18 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args,
return GCC_INSTALL_PREFIX;
}
@ -37,7 +37,7 @@ index fe5bda5c6605..fd4a7f72be14 100644
/// Initialize a GCCInstallationDetector from the driver.
///
/// This performs all of the autodetection and sets up the various paths.
@@ -1904,6 +1916,16 @@ void Generic_GCC::GCCInstallationDetector::init(
@@ -2097,6 +2109,16 @@ void Generic_GCC::GCCInstallationDetector::init(
// The compatible GCC triples for this particular architecture.
SmallVector<StringRef, 16> CandidateTripleAliases;
SmallVector<StringRef, 16> CandidateBiarchTripleAliases;
@ -51,9 +51,9 @@ index fe5bda5c6605..fd4a7f72be14 100644
+ CandidateBiarchTripleAliases.push_back(ConvertedTriple);
+ }
+
CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs,
CandidateTripleAliases, CandidateBiarchLibDirs,
CandidateBiarchTripleAliases);
// Add some triples that we want to check first.
CandidateTripleAliases.push_back(TargetTriple.str());
std::string TripleNoVendor = TargetTriple.getArchName().str() + "-" +
--
2.26.2
2.42.0

View File

@ -1,125 +0,0 @@
From adbe188f3b1e3a0dd5ec80d9409601ba7f5b0423 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine@redhat.com>
Date: Thu, 24 Mar 2022 09:44:21 +0100
Subject: [PATCH] Produce DWARF4 by default
Have a look at the following commit to see when the move from DWARF 4 to 5 first happened upstream:
https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4?diff=unified
---
clang/lib/Driver/ToolChain.cpp | 4 +---
clang/test/CodeGen/dwarf-version.c | 4 ++--
clang/test/Driver/as-options.s | 4 ++--
clang/test/Driver/cl-options.c | 2 +-
clang/test/Driver/clang-g-opts.c | 2 +-
clang/test/Driver/ve-toolchain.c | 2 +-
clang/test/Driver/ve-toolchain.cpp | 2 +-
7 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 8dafc3d481c2..92bf26dc8ec6 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -428,9 +428,7 @@ ToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const {
}
unsigned ToolChain::GetDefaultDwarfVersion() const {
- // TODO: Remove the RISC-V special case when R_RISCV_SET_ULEB128 linker
- // support becomes more widely available.
- return getTriple().isRISCV() ? 4 : 5;
+ return 4;
}
Tool *ToolChain::getClang() const {
diff --git a/clang/test/CodeGen/dwarf-version.c b/clang/test/CodeGen/dwarf-version.c
index d307eb3f101f..e7e93bf6688c 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -2,8 +2,8 @@
// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3
// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
-// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
-// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
+// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT
// environment variable which indirecty overrides the version in the target
diff --git a/clang/test/Driver/as-options.s b/clang/test/Driver/as-options.s
index 73d002c7ef7e..71d55f7fd537 100644
--- a/clang/test/Driver/as-options.s
+++ b/clang/test/Driver/as-options.s
@@ -122,7 +122,7 @@
// RUN: FileCheck --check-prefix=DEBUG %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -g0 -g %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=DEBUG %s
-// DEBUG: "-g" "-gdwarf-5"
+// DEBUG: "-g" "-gdwarf-4"
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -g -g0 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=NODEBUG %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-5 -g0 %s -### 2>&1 | \
@@ -141,7 +141,7 @@
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-2 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=GDWARF2 %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf %s -### 2>&1 | \
-// RUN: FileCheck --check-prefix=GDWARF5 %s
+// RUN: FileCheck --check-prefix=GDWARF4 %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-5 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=GDWARF5 %s
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 6d929b19e7e2..373905c2e0fc 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -569,7 +569,7 @@
// RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
// Z7_gdwarf: "-gcodeview"
// Z7_gdwarf: "-debug-info-kind=constructor"
-// Z7_gdwarf: "-dwarf-version=
+// Z7_gdwarf: "-dwarf-version=4
// RUN: %clang_cl /ZH:MD5 /c -### -- %s 2>&1 | FileCheck -check-prefix=ZH_MD5 %s
// ZH_MD5: "-gsrc-hash=md5"
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index 5ee0fe64fe48..985158746137 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -32,7 +32,7 @@
// CHECK-WITHOUT-G-NOT: -debug-info-kind
// CHECK-WITH-G: "-debug-info-kind=constructor"
-// CHECK-WITH-G: "-dwarf-version=5"
+// CHECK-WITH-G: "-dwarf-version=4"
// CHECK-WITH-G-DWARF2: "-dwarf-version=2"
// CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone"
diff --git a/clang/test/Driver/ve-toolchain.c b/clang/test/Driver/ve-toolchain.c
index 32e25769b6da..b8a2852daba8 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -6,7 +6,7 @@
/// Checking dwarf-version
// RUN: %clang -### -g --target=ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
-// DWARF_VER: "-dwarf-version=5"
+// DWARF_VER: "-dwarf-version=4"
///-----------------------------------------------------------------------------
/// Checking include-path
diff --git a/clang/test/Driver/ve-toolchain.cpp b/clang/test/Driver/ve-toolchain.cpp
index 5a33d5eceb61..cedf895b36dc 100644
--- a/clang/test/Driver/ve-toolchain.cpp
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -7,7 +7,7 @@
// RUN: %clangxx -### -g --target=ve-unknown-linux-gnu \
// RUN: %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
-// DWARF_VER: "-dwarf-version=5"
+// DWARF_VER: "-dwarf-version=4"
///-----------------------------------------------------------------------------
/// Checking include-path
--
2.41.0

View File

@ -0,0 +1,92 @@
From ba9cfbe8e1d034d823dabf1c76d270fce8085f1b Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 9 Mar 2023 21:52:41 -0800
Subject: [PATCH] Restore -fopenmp-implicit-rpath, disabled by default
Used by redhat-rpm-config on older Fedora versions.
---
clang/include/clang/Driver/Options.td | 6 ++++++
clang/lib/Driver/ToolChains/CommonArgs.cpp | 19 +++++++++++++++++++
clang/lib/Driver/ToolChains/CommonArgs.h | 3 +++
clang/test/OpenMP/Inputs/libomp.a | 1 +
4 files changed, 29 insertions(+)
create mode 100644 clang/test/OpenMP/Inputs/libomp.a
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 31ecf98b806b..46aa49e1d0d1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5194,6 +5194,12 @@ def offload_add_rpath: Flag<["--"], "offload-add-rpath">,
def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">,
Flags<[NoArgumentUnused]>,
Alias<frtlib_add_rpath>;
+defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
+ LangOpts<"OpenMP">,
+ DefaultFalse,
+ PosFlag<SetTrue, [], [ClangOption], "Set rpath on OpenMP executables">,
+ NegFlag<SetFalse>,
+ BothFlags<[NoArgumentUnused]>>;
def r : Flag<["-"], "r">, Flags<[LinkerInput, NoArgumentUnused]>,
Group<Link_Group>;
def regcall4 : Flag<["-"], "regcall4">, Group<m_Group>,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 483ecd0ae592..55c673460a2f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -889,6 +889,22 @@ static void addOpenMPDeviceLibC(const ToolChain &TC, const ArgList &Args,
}
}
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
+ const ArgList &Args,
+ ArgStringList &CmdArgs) {
+
+ if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
+ options::OPT_fno_openmp_implicit_rpath, false)) {
+ // Default to clang lib / lib64 folder, i.e. the same location as device
+ // runtime
+ SmallString<256> DefaultLibPath =
+ llvm::sys::path::parent_path(TC.getDriver().Dir);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
+ CmdArgs.push_back("-rpath");
+ CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
+ }
+}
+
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
const ArgList &Args,
ArgStringList &CmdArgs) {
@@ -963,6 +979,9 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
addOpenMPDeviceLibC(TC, Args, CmdArgs);
addArchSpecificRPath(TC, Args, CmdArgs);
+
+ if (RTKind == Driver::OMPRT_OMP)
+ addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
addOpenMPRuntimeLibraryPath(TC, Args, CmdArgs);
return true;
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index 096152bfbdcf..7e8bf6b8830c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,6 +117,9 @@ void AddAssemblerKPIC(const ToolChain &ToolChain,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);
+void addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
+ const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs);
void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);
void addOpenMPRuntimeLibraryPath(const ToolChain &TC,
diff --git a/clang/test/OpenMP/Inputs/libomp.a b/clang/test/OpenMP/Inputs/libomp.a
new file mode 100644
index 000000000000..8b277f0dd5dc
--- /dev/null
+++ b/clang/test/OpenMP/Inputs/libomp.a
@@ -0,0 +1 @@
+!<arch>
--
2.41.0

View File

@ -4,7 +4,6 @@ Date: Tue, 24 Jan 2023 22:46:25 +0000
Subject: [PATCH] clang-tools-extra: Make test dependency on LLVMHello optional
This fixes clang + clang-tools-extra standalone build after
36892727e4f19a60778e371d78f8fb09d8122c85.
---
clang-tools-extra/test/CMakeLists.txt | 10 +++++++++-
clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp | 2 +-

View File

@ -0,0 +1,39 @@
From 3dc5722d5c7673a879f2b4680369d3ac8b6b64b6 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Wed, 4 Aug 2021 14:05:38 -0700
Subject: [PATCH] cmake: Allow shared libraries to customize the soname using
LLVM_ABI_REVISION
The LLVM_ABI_REVISION variable is intended to be used for release
candidates which introduce an ABI change to a shared library. This
variable can be specified per library, so there is not one global value
for all of LLVM.
For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library
compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for
library will be incremented by 1.
In the main branch, LLVM_ABI_REVISION should always be 0, it is only
meant to be used in the release branch.
Differential Revision: https://reviews.llvm.org/D105594
---
clang/tools/clang-shlib/CMakeLists.txt | 5 +++++
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt
index 9c1f8ea452b3..4d785924e4bb 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -1,3 +1,8 @@
+# In the main branch, LLVM_ABI_REVISION should always be 0. In the release
+# branches, this should be incremented before each release candidate every
+# time the ABI of libclang-cpp.so changes.
+set(LLVM_ABI_REVISION 0)
+
# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
if (NOT LLVM_ENABLE_PIC)
return()
--
2.27.0

View File

@ -0,0 +1,26 @@
From 988dd3f3363d8ab4ee53f61e0eb5afc6646c9d4f Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Tue, 26 Sep 2023 13:06:29 +0200
Subject: [PATCH] disable myst parser
---
clang/docs/conf.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/clang/docs/conf.py b/clang/docs/conf.py
index ca310026f53e..dfb74273b5b2 100644
--- a/clang/docs/conf.py
+++ b/clang/docs/conf.py
@@ -35,9 +35,6 @@ templates_path = ["_templates"]
import sphinx
-if sphinx.version_info >= (3, 0):
- extensions.append("myst_parser")
-
# The encoding of source files.
# source_encoding = 'utf-8-sig'
--
2.41.0

View File

@ -1,26 +0,0 @@
diff -Naur a/clang/docs/conf.py b/clang/docs/conf.py
--- a/clang/docs/conf.py 2020-09-15 09:12:24.318287611 +0000
+++ b/clang/docs/conf.py 2020-09-15 15:01:00.025893199 +0000
@@ -37,21 +37,7 @@
".rst": "restructuredtext",
}
-try:
- import recommonmark
-except ImportError:
- # manpages do not use any .md sources
- if not tags.has("builder-man"):
- raise
-else:
- import sphinx
-
- if sphinx.version_info >= (3, 0):
- # This requires 0.5 or later.
- extensions.append("recommonmark")
- else:
- source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
- source_suffix[".md"] = "markdown"
+import sphinx
# The encoding of source files.
# source_encoding = 'utf-8-sig'

3
clang.cfg Normal file
View File

@ -0,0 +1,3 @@
# Drop the following option after debugedit adds support to DWARF-5:
# https://sourceware.org/bugzilla/show_bug.cgi?id=28728
-gdwarf-4

View File

@ -81,28 +81,21 @@ Source4: release-keys.asc
%if %{without compat_build}
Source5: macros.%{name}
%endif
Source6: clang.cfg
# Patches for clang
Patch1: 0001-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch
Patch2: 0003-PATCH-clang-Don-t-install-static-libraries.patch
Patch3: 0001-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch
# Drop the following patch after debugedit adds support to DWARF-5:
# https://sourceware.org/bugzilla/show_bug.cgi?id=28728
Patch4: 0001-Produce-DWARF4-by-default.patch
# Workaround a bug in ORC on ppc64le.
# More info is available here: https://reviews.llvm.org/D159115#4641826
Patch5: 0001-Workaround-a-bug-in-ORC-on-ppc64le.patch
# Patches for https://issues.redhat.com/browse/RHEL-1650
# Remove in clang 18.
Patch6: cfg.patch
Patch7: tsa.patch
Patch8: 0001-Clang-Fix-build-with-GCC-14-on-ARM.patch
Patch9: 0001-Clang-Defer-the-instantiation-of-explicit-specifier-.patch
# RHEL specific patches
# Avoid unwanted dependency on python-recommonmark
Patch101: 0009-disable-recommonmark.patch
# Avoid unwanted dependency on python-myst-parser
Patch101: 0009-disable-myst-parser.patch
# Patches for clang-tools-extra
# See https://reviews.llvm.org/D120301
@ -138,7 +131,7 @@ BuildRequires: python3-lit
BuildRequires: python3-sphinx
%if %{undefined rhel}
BuildRequires: python3-recommonmark
BuildRequires: python3-myst-parser
%endif
BuildRequires: libatomic
@ -399,6 +392,10 @@ rm test/CodeGen/profile-filter.c
-DBUILD_SHARED_LIBS=OFF \
-DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \
-DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \
-DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{name}/ \
%ifarch %{arm}
-DCLANG_DEFAULT_LINKER=lld \
%endif
-DCLANG_DEFAULT_UNWINDLIB=libgcc
%cmake_build
@ -494,6 +491,11 @@ rm -vf %{buildroot}%{install_datadir}/clang/bash-autocomplete.sh
# populated by other packages
mkdir -p %{buildroot}%{install_prefix}/lib/clang/%{maj_ver}/{bin,include,lib,share}/
%if 0%{?fedora} == 38
# Install config file
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/
mv %{SOURCE6} %{buildroot}%{_sysconfdir}/%{name}/%{_target_platform}.cfg
%endif
%check
%if %{with check}
@ -529,6 +531,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake
%files libs
%{install_prefix}/lib/clang/%{maj_ver}/include/*
%{install_libdir}/*.so.*
%if 0%{?fedora} == 38
%{_sysconfdir}/%{name}/%{_target_platform}.cfg
%endif
%files devel
%{install_libdir}/*.so