From b4686dd8b6242691dd8cc3cea5e5628c5fd190ec Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Feb 28 2024 19:36:38 +0000 Subject: Attempt to fix -lgcc_s issue in https://src.fedoraproject.org/tests/compiler-rt/blob/main/f/cross-compile-i686 --- diff --git a/0001-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch b/0001-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch deleted file mode 100644 index f044fc2..0000000 --- a/0001-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 03a4a6131a18c47a32a02a0c48f6d32358561920 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Wed, 6 Oct 2021 05:32:44 +0000 -Subject: [PATCH] Driver: Add a gcc equivalent triple to the list of triples to - search - -There are some gcc triples, like x86_64-redhat-linux, that provide the -same behavior as a clang triple with a similar name (e.g. -x86_64-redhat-linux-gnu). When searching for a gcc install, also search -for a gcc equivalent triple if one exists. - -Differential Revision: https://reviews.llvm.org/D111207 ---- - clang/lib/Driver/ToolChains/Gnu.cpp | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - -diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index 16cf57072272..49084bd2ce25 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.cpp -+++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -2078,6 +2078,18 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args, - return GCC_INSTALL_PREFIX; - } - -+/// This function takes a 'clang' triple and converts it to an equivalent gcc -+/// triple. -+static const char *ConvertToGccTriple(StringRef CandidateTriple) { -+ return llvm::StringSwitch(CandidateTriple) -+ .Case("aarch64-redhat-linux-gnu", "aarch64-redhat-linux") -+ .Case("i686-redhat-linux-gnu", "i686-redhat-linux") -+ .Case("ppc64le-redhat-linux-gnu", "ppc64le-redhat-linux") -+ .Case("s390x-redhat-linux-gnu", "s390x-redhat-linux") -+ .Case("x86_64-redhat-linux-gnu", "x86_64-redhat-linux") -+ .Default(NULL); -+} -+ - /// Initialize a GCCInstallationDetector from the driver. - /// - /// This performs all of the autodetection and sets up the various paths. -@@ -2097,6 +2109,16 @@ void Generic_GCC::GCCInstallationDetector::init( - // The compatible GCC triples for this particular architecture. - SmallVector CandidateTripleAliases; - SmallVector CandidateBiarchTripleAliases; -+ -+ // In some cases gcc uses a slightly different triple than clang for the -+ // same target. Convert the clang triple to the gcc equivalent and use that -+ // to search for the gcc install. -+ const char *ConvertedTriple = ConvertToGccTriple(TargetTriple.str()); -+ if (ConvertedTriple) { -+ CandidateTripleAliases.push_back(ConvertedTriple); -+ CandidateBiarchTripleAliases.push_back(ConvertedTriple); -+ } -+ - // Add some triples that we want to check first. - CandidateTripleAliases.push_back(TargetTriple.str()); - std::string TripleNoVendor = TargetTriple.getArchName().str() + "-" + --- -2.42.0 - diff --git a/build.spec.inc b/build.spec.inc index 5cb6273..ec7970b 100644 --- a/build.spec.inc +++ b/build.spec.inc @@ -74,6 +74,7 @@ cd llvm -DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \ -DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra \ + -DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{pkg_name_clang}/ \ %ifarch %{arm} -DCLANG_DEFAULT_LINKER=lld \ %endif diff --git a/install.spec.inc b/install.spec.inc index 40d0e75..7a96b0e 100644 --- a/install.spec.inc +++ b/install.spec.inc @@ -186,10 +186,10 @@ mkdir -p %{buildroot}%{install_libdir}/clang/%{maj_ver}/{include,lib,share}/ ln -s %{_datadir}/clang/clang-format-diff.py %{buildroot}%{_bindir}/clang-format-diff %endif -%if 0%{?fedora} == 38 -# Install config file -mkdir -p %{buildroot}%{_sysconfdir}/%{name}/ -mv %{SOURCE2006} %{buildroot}%{_sysconfdir}/%{name}/%{_target_platform}.cfg +# Install config file for clang +%if %{maj_ver} >=18 +mkdir -p %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/ +echo "--gcc-triple=%{_arch}-redhat-linux" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/clang.cfg %endif #endregion diff --git a/sources.spec.inc b/sources.spec.inc index b409398..1c3a962 100644 --- a/sources.spec.inc +++ b/sources.spec.inc @@ -10,8 +10,6 @@ Source1006: release-keys.asc Source2005: macros.%{pkg_name_clang} %endif -Source2006: clang.cfg - # Sources we use to split up the main spec file in sections so that we can more # easily see what specfile sections are touched by a patch. Source1000: version.spec.inc