12 -> 13, snapshot of not released git master, build clang only

This commit is contained in:
Mikhail Novosyolov 2021-09-05 20:00:36 +03:00
parent dec5246fb6
commit 1851a903e9
4 changed files with 74 additions and 60 deletions

View file

@ -1,2 +1,2 @@
sources:
llvm12-12.0.1.tar.gz: b608c40c5b946ce2d78c0efa96754244febcf46b
llvm13-dfc46f02681447370a1ccbe340034e970bc7e572.tar.gz: 137946b26cf4e2b23c3f8d9a84dc5c1bcc485b9e

View file

@ -1,7 +1,8 @@
diff -urN a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
--- a/clang/include/clang/Driver/Distro.h 2021-01-21 14:47:54.887955961 +0300
+++ b/clang/include/clang/Driver/Distro.h 2021-01-21 14:49:48.564035875 +0300
@@ -41,8 +41,10 @@
diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
index d9909bc..0790ef2 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -42,8 +42,10 @@ public:
RHEL5,
RHEL6,
RHEL7,
@ -12,7 +13,7 @@ diff -urN a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Dis
OpenSUSE,
UbuntuHardy,
UbuntuIntrepid,
@@ -115,6 +117,10 @@
@@ -117,6 +119,10 @@ public:
return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7);
}
@ -23,7 +24,7 @@ diff -urN a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Dis
bool IsOpenSUSE() const { return DistroVal == OpenSUSE; }
bool IsDebian() const {
@@ -129,6 +135,9 @@
@@ -131,6 +137,9 @@ public:
bool IsGentoo() const { return DistroVal == Gentoo; }
@ -33,23 +34,23 @@ diff -urN a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Dis
/// @}
};
diff -urN a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
--- a/clang/lib/Driver/Distro.cpp 2021-01-21 14:47:54.974619591 +0300
+++ b/clang/lib/Driver/Distro.cpp 2021-01-21 14:52:04.312828583 +0300
@@ -188,6 +188,9 @@
}
// ...and others.
+ if (VFS.exists("/etc/rosa-release"))
+ return Distro::ROSA;
+
if (VFS.exists("/etc/exherbo-release"))
return Distro::Exherbo;
diff -urN a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
--- a/clang/lib/Driver/ToolChains/Gnu.cpp 2021-01-21 14:47:54.984619240 +0300
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp 2021-01-21 14:49:10.282009317 +0300
@@ -2075,7 +2075,9 @@
diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index cdb5a17..f697c8c 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -44,6 +44,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
.Case("sles", Distro::OpenSUSE)
.Case("opensuse", Distro::OpenSUSE)
.Case("exherbo", Distro::Exherbo)
+ .Case("rosa", Distro::ROSA)
.Default(Distro::UnknownDistro);
return Version;
}
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index c28fe78..8a72332 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2078,7 +2078,9 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
"aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
@ -60,7 +61,7 @@ diff -urN a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gn
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
"aarch64_be-linux-gnu"};
@@ -2085,6 +2087,8 @@
@@ -2088,6 +2090,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"arm-linux-androideabi"};
static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
"armv7hl-redhat-linux-gnueabi",
@ -69,31 +70,31 @@ diff -urN a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gn
"armv6hl-suse-linux-gnueabi",
"armv7hl-suse-linux-gnueabi"};
static const char *const ARMebLibDirs[] = {"/lib"};
@@ -2103,7 +2107,8 @@
@@ -2106,7 +2110,9 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"x86_64-redhat-linux", "x86_64-suse-linux",
"x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
"x86_64-slackware-linux", "x86_64-unknown-linux",
- "x86_64-amazon-linux", "x86_64-linux-android"};
+ "x86_64-amazon-linux", "x86_64-linux-android",
+ "x86_64-rosa-linux-gnu", "x86_64-openmandriva-linux-gnu"};
static const char *const X32LibDirs[] = {"/libx32"};
static const char *const X86LibDirs[] = {"/lib32", "/lib"};
static const char *const X86Triples[] = {
@@ -2112,7 +2117,9 @@
"i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux",
"i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu",
"i686-linux-android", "i386-gnu", "i486-gnu",
- "i586-gnu", "i686-gnu"};
+ "i586-gnu", "i686-gnu", "i586-unknown-linux-gnu",
+ "i586-rosa-linux-gnu", "i686-rosa-linux-gnu", "i586-openmandriva-linux-gnu",
+ "i686-openmandriva-linux-gnu"};
+ "x86_64-rosa-linux-gnu", "x86_64-openmandriva-linux-gnu"
+ };
static const char *const X32Triples[] = {"x86_64-linux-gnux32",
"x86_64-pc-linux-gnux32"};
static const char *const X32LibDirs[] = {"/libx32", "/lib"};
@@ -2117,6 +2123,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"i686-redhat-linux", "i386-redhat-linux",
"i586-suse-linux", "i686-montavista-linux",
"i686-linux-android", "i686-gnu",
+ "i586-rosa-linux-gnu", "i686-rosa-linux-gnu",
+ "i586-unknown-linux-gnu", "i586-openmandriva-linux-gnu"
};
static const char *const MIPSLibDirs[] = {"/lib"};
static const char *const MIPSTriples[] = {
diff -urN a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
--- a/clang/lib/Driver/ToolChains/Linux.cpp 2021-01-21 14:47:54.984619240 +0300
+++ b/clang/lib/Driver/ToolChains/Linux.cpp 2021-01-21 14:49:10.285342537 +0300
@@ -231,7 +231,7 @@
static const char *const M68kLibDirs[] = {"/lib"};
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index a80b8ad..b69ffda 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -194,7 +194,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
}
if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
@ -102,7 +103,7 @@ diff -urN a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/
ExtraOpts.push_back("-z");
ExtraOpts.push_back("relro");
}
@@ -271,6 +271,7 @@
@@ -233,6 +233,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// Hexagon linker/loader does not support .gnu.hash
if (!IsMips && !IsHexagon) {
if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
@ -110,7 +111,7 @@ diff -urN a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/
(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
(IsAndroid && !Triple.isAndroidVersionLT(23)))
ExtraOpts.push_back("--hash-style=gnu");
@@ -286,7 +287,7 @@
@@ -248,7 +249,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
ExtraOpts.push_back("--build-id");
#endif

View file

@ -15,14 +15,10 @@
%global optflags %{optflags} -fno-strict-aliasing
%global ldflags %{ldflags} -Wl,-rpath,%{_libdir}
# clang header paths are hard-coded at compile time
# and need adjustment whenever there's a new GCC version
%define gcc_version %(gcc -dumpversion)
%define compile_apidox 0
%{?_with_apidox: %{expand: %%global compile_apidox 1}}
%define maj_ver 12
%define maj_ver 13
%if %{mdvver} == 201610
%bcond_without lldb
@ -30,19 +26,26 @@
%bcond_with lldb
%endif
%define commit dfc46f02681447370a1ccbe340034e970bc7e572
%define commit_short %(echo %{commit} | head -c 6)
Summary: LLVM and Clang in %{_prefix}
# llvm11
# llvm13
Name: llvm%{maj_ver}
Version: 12.0.1
Release: 1
Version: 13
Release: 0.git%{commit_short}.1
License: NCSA
Group: Development/Other
Url: http://llvm.org
Source0: https://github.com/llvm/llvm-project/archive/llvmorg-%{version}.tar.gz?/%{name}-%{version}.tar.gz
Source0: https://github.com/llvm/llvm-project/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz
Source1000: llvm%{maj_ver}.rpmlintrc
# Adjust the search paths to match the OS, adjust the default compiler flags
# as well.
Patch1: clang-rosa.patch
BuildRequires: gcc
BuildRequires: stdc++-devel
# gcc is too old in rosa2016.1, llvm12 was buildable with it but llvm13 is already not
BuildRequires: llvm12
BuildRequires: binutils-devel
BuildRequires: bison
BuildRequires: chrpath
@ -93,12 +96,14 @@ This package contains LLVM and Clang in %{_prefix}.
#----------------------------------------------------------------------------
%prep
%autosetup -p1 -n llvm-project-llvmorg-%{version}
%autosetup -p1 -n llvm-project-%{commit}
%build
# Build with gcc/g++, not clang if it happens to be installed
export CC=gcc
export CXX=g++
# gcc is too old in rosa2016.1
#export CC=gcc
#export CXX=g++
export CC=/opt/llvm12/bin/clang
export CXX=/opt/llvm12/bin/clang++
# A couple more fixes from OMV + a workaround for a bug (?) in GCC 4.9:
# https://llvm.org/bugs/show_bug.cgi?id=20080 and
@ -134,13 +139,21 @@ export PATH=$PYTHONPATH:$PATH
%setup_compile_flags
mkdir -p build
cd build
# We actually need only clang to build chromium-browser-stable,
# other subprojects fail to build when using /opt/llvm12/bin/clang++,
# build OK when using gcc, but gcc is too old in rosa2016.1,
# so let's build clang only for now.
# -DLLVM_ENABLE_PROJECTS='clang-tools-extra;libcxx;libcxxabi;%{!?with_lldb:lldb;}compiler-rt;lld;polly'
cmake ../llvm \
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;libunwind;%{!?with_lldb:lldb;}compiler-rt;lld;polly' \
-DLLVM_ENABLE_PROJECTS='clang' \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
-DLLVM_LIBDIR_SUFFIX=$(echo %{_lib} | sed -e 's,^lib,,') \
-DCLANG_LIBDIR_SUFFIX=$(echo %{_lib} | sed -e 's,^lib,,') \
-DCLANG_DEFAULT_CXX_STDLIB="libstdc++" \
-DCLANG_DEFAULT_RTLIB="libgcc" \
-DLLVM_ENABLE_FFI:BOOL=ON \
-DLLVM_ENABLE_RTTI:BOOL=ON \
-DOCAMLFIND=NOTFOUND \