diff --git a/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch b/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch index 0050b40..ed119e2 100644 --- a/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch +++ b/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch @@ -32,10 +32,10 @@ toolchain. create mode 100644 test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o create mode 100644 test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so -diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index c8a7fce0..f28792b7 100644 ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2500,6 +2500,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( (TargetArch == llvm::Triple::x86 && TargetTriple.getOS() != llvm::Triple::Solaris)}}; @@ -73,10 +73,10 @@ index c8a7fce0..f28792b7 100644 } } } -diff --git a/lib/Driver/ToolChains/Gnu.h b/lib/Driver/ToolChains/Gnu.h +diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h index 52690ab4..2a4452d9 100644 ---- a/lib/Driver/ToolChains/Gnu.h -+++ b/lib/Driver/ToolChains/Gnu.h +--- a/clang/lib/Driver/ToolChains/Gnu.h ++++ b/clang/lib/Driver/ToolChains/Gnu.h @@ -190,6 +190,7 @@ public: /// Driver, and has logic for fuzzing that where appropriate. class GCCInstallationDetector { @@ -95,19 +95,19 @@ index 52690ab4..2a4452d9 100644 void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, ArrayRef ExtraTripleAliases = None); -diff --git a/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o new file mode 100644 index 00000000..e69de29b -diff --git a/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o new file mode 100644 index 00000000..e69de29b -diff --git a/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so new file mode 100644 index 00000000..e69de29b -diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c +diff --git a/clang/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index ec539522..95725d5c 100644 ---- a/test/Driver/linux-ld.c -+++ b/test/Driver/linux-ld.c +--- a/clang/test/Driver/linux-ld.c ++++ b/clang/test/Driver/linux-ld.c @@ -784,6 +784,18 @@ // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtend.o" // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtn.o" diff --git a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch index f4f0fa3..c451039 100644 --- a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch +++ b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch @@ -11,10 +11,10 @@ provides this implementation. clang/test/Driver/netbsd.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) -diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp +diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 88a627e..cb99844 100644 ---- a/lib/Driver/ToolChain.cpp -+++ b/lib/Driver/ToolChain.cpp +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp @@ -767,6 +767,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, switch (Type) { case ToolChain::CST_Libcxx: @@ -23,10 +23,10 @@ index 88a627e..cb99844 100644 break; case ToolChain::CST_Libstdcxx: -diff --git a/test/Driver/netbsd.cpp b/test/Driver/netbsd.cpp +diff --git a/clang/test/Driver/netbsd.cpp b/clang/test/Driver/netbsd.cpp index 4af7d83..ff18c62 100644 ---- a/test/Driver/netbsd.cpp -+++ b/test/Driver/netbsd.cpp +--- a/clang/test/Driver/netbsd.cpp ++++ b/clang/test/Driver/netbsd.cpp @@ -131,7 +131,7 @@ // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" diff --git a/0002-gtest-reorg.patch b/0002-gtest-reorg.patch index 121ac46..f760c15 100644 --- a/0002-gtest-reorg.patch +++ b/0002-gtest-reorg.patch @@ -7,10 +7,10 @@ Subject: [PATCH 2/2] [PATCH] gtest reorg CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -diff --git a/CMakeLists.txt b/CMakeLists.txt +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c2016a45ca..48ea3c3bb9 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt @@ -157,12 +157,6 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") set(LLVM_UTILS_PROVIDED ON) set(CLANG_TEST_DEPS FileCheck count not) diff --git a/clang.spec b/clang.spec index f017008..ea5e0ae 100644 --- a/clang.spec +++ b/clang.spec @@ -1,10 +1,24 @@ -%global compat_build 0 +%bcond_with compat_build +%bcond_without tests + +# A "full build" which is a normal build with all the sub-packages and +# everything enabled. +%global with_full_build 1 + +%if %{with compat_build} +%undefine with_full_build +%undefine with_tests +%endif + +%if %{without full_build} && %{without compat_build} +%{error:Must enable either full_build or compat_build} +%endif %global maj_ver 11 %global min_ver 0 %global patch_ver 1 %global rc_ver 1 -%global baserelease 1 +%global baserelease 2 %global clang_tools_binaries \ %{_bindir}/clang-apply-replacements \ @@ -36,7 +50,7 @@ %{_bindir}/clang-cl \ %{_bindir}/clang-cpp \ -%if 0%{?compat_build} +%if %{with compat_build} %global pkg_name clang%{maj_ver}.%{min_ver} # Install clang to same prefix as llvm, so that apps that use llvm-config # will also be able to find clang libs. @@ -45,13 +59,21 @@ %global install_includedir %{install_prefix}/include %global install_libdir %{install_prefix}/lib -%global pkg_bindir %{install_bindir} %global pkg_includedir %{_includedir}/llvm%{maj_ver}.%{min_ver} %global pkg_libdir %{install_libdir} -%else + +%global llvm_pkg llvm%{maj_ver}.%{min_ver} +%endif + +%if %{with full_build} %global pkg_name clang -%global install_prefix /usr +%global install_prefix %{_prefix} %global pkg_libdir %{_libdir} +%global pkg_includedir %{_includedir} +%global llvm_pkg llvm +%if 0%{?__isa_bits} == 64 +%global llvm_libdir_suffix 64 +%endif %endif %if 0%{?fedora} || 0%{?rhel} > 7 @@ -60,8 +82,6 @@ %bcond_with python3 %endif -%global build_install_prefix %{buildroot}%{install_prefix} - %ifarch ppc64le # Too many threads on ppc64 systems causes OOM errors. %global _smp_mflags -j8 @@ -79,7 +99,7 @@ License: NCSA URL: http://llvm.org Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_srcdir}.tar.xz Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_srcdir}.tar.xz.sig -%if !0%{?compat_build} +%if %{with full_build} Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_tools_srcdir}.tar.xz Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_tools_srcdir}.tar.xz.sig %endif @@ -94,46 +114,50 @@ Patch15: 0001-clang-Don-t-install-static-libraries.patch Patch16: 0001-clang-Fix-spurious-test-failure.patch Patch17: 0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch +#---Packaging Dependencies-----------------------------------------------------# + +# We need python3-devel for pathfix.py. +BuildRequires: python3-devel +# Needed for %%multilib_fix_c_header +BuildRequires: multilib-rpm-config +# For origin certification +BuildRequires: gnupg2 + +#---Build Dependencies---------------------------------------------------------# + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: ninja-build -%if 0%{?compat_build} -BuildRequires: llvm%{maj_ver}.%{min_ver}-devel = %{version} -BuildRequires: llvm%{maj_ver}.%{min_ver}-static = %{version} -%else -BuildRequires: llvm-devel = %{version} -BuildRequires: llvm-test = %{version} + +#---Library Dependencies-------------------------------------------------------# + +BuildRequires: libxml2-devel +BuildRequires: ncurses-devel # llvm-static is required, because clang-tablegen needs libLLVMTableGen, which # is not included in libLLVM.so. -BuildRequires: llvm-static = %{version} -BuildRequires: llvm-googletest = %{version} -%endif +BuildRequires: %{llvm_pkg}-static = %{version} +BuildRequires: %{llvm_pkg}-devel = %{version} + +#---Misc Dependencies---------------------------------------------------------# -BuildRequires: libxml2-devel BuildRequires: perl-generators -BuildRequires: ncurses-devel # According to https://fedoraproject.org/wiki/Packaging:Emacs a package # should BuildRequires: emacs if it packages emacs integration files. BuildRequires: emacs - -# These build dependencies are required for the test suite. -%if %with python3 -# The testsuite uses /usr/bin/lit which is part of the python3-lit package. -BuildRequires: python3-lit -%endif - BuildRequires: python3-sphinx BuildRequires: libatomic -# We need python3-devel for pathfix.py. -BuildRequires: python3-devel +#---Test Dependencies----------------------------------------------------------# -# Needed for %%multilib_fix_c_header -BuildRequires: multilib-rpm-config +%if %{with tests} +BuildRequires: llvm-googletest = %{version} +BuildRequires: llvm-test = %{version} -# For origin certification -BuildRequires: gnupg2 +%if %with python3 +# The testsuite uses /usr/bin/lit which is part of the python3-lit package. +BuildRequires: python3-lit +%endif # scan-build uses these perl modules so they need to be installed in order # to run the tests. @@ -149,14 +173,19 @@ BuildRequires: perl(Term::ANSIColor) BuildRequires: perl(Text::ParseWords) BuildRequires: perl(Sys::Hostname) -Requires: %{name}-libs%{?_isa} = %{version}-%{release} +%endif + +#---Runtime Dependencies-------------------------------------------------------# +Requires: %{name}-libs%{?_isa} = %{version}-%{release} # clang requires gcc, clang++ requires libstdc++-devel # - https://bugzilla.redhat.com/show_bug.cgi?id=1021645 # - https://bugzilla.redhat.com/show_bug.cgi?id=1158594 Requires: libstdc++-devel Requires: gcc-c++ +#---Provides/Conflicts---------------------------------------------------------# + Provides: clang(major) = %{maj_ver} Conflicts: compiler-rt < %{version} @@ -190,12 +219,12 @@ Runtime library for clang. %package devel Summary: Development header files for clang -%if !0%{?compat_build} +%if %{with full_build} Requires: %{name}%{?_isa} = %{version}-%{release} # The clang CMake files reference tools from clang-tools-extra. Requires: %{name}-tools-extra%{?_isa} = %{version}-%{release} -Requires: %{name}-libs = %{version}-%{release} %endif +Requires: %{name}-libs = %{version}-%{release} %description devel Development header files for clang. @@ -207,7 +236,7 @@ Provides: %{name}-resource-filesystem(major) = %{maj_ver} %description resource-filesystem This package owns the clang resouce directory: $libdir/clang/$version/ -%if !0%{?compat_build} +%if %{with full_build} %package analyzer Summary: A source code analysis framework License: NCSA and MIT @@ -251,12 +280,11 @@ Requires: python3 %endif - %prep %{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE3}' --data='%{SOURCE0}' -%if 0%{?compat_build} -%autosetup -n %{clang_srcdir} -p1 +%if %{with compat_build} +%autosetup -n %{clang_srcdir} -p2 %else %{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE2}' --data='%{SOURCE1}' @@ -269,12 +297,12 @@ pathfix.py -i %{__python3} -pn \ %setup -q -n %{clang_srcdir} -%patch4 -p1 -b .gtest -%patch11 -p1 -b .libcxx-fix +%patch4 -p2 -b .gtest +%patch11 -p2 -b .libcxx-fix %patch13 -p2 -b .unwind-all %patch15 -p2 -b .no-install-static %patch16 -p2 -b .test-fix2 -%patch17 -p1 -b .check-gcc_s +%patch17 -p2 -b .check-gcc_s mv ../%{clang_tools_srcdir} tools/extra @@ -296,11 +324,7 @@ pathfix.py -i %{__python3} -pn \ %global _lto_cflags %(echo %{_lto_cflags} | sed 's/-ffat-lto-objects//') %endif -%if 0%{?__isa_bits} == 64 -sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' test/lit.cfg.py -%else -sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py -%endif +sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/%{llvm_libdir_suffix}/g' test/lit.cfg.py %ifarch s390 s390x %{arm} %ix86 ppc64le # Decrease debuginfo verbosity to reduce memory consumption during final library linking @@ -312,35 +336,32 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py # if CAMKE_INSTALL_RPATH is set to a value, but cmake interprets this value # as nothing, so it sets the rpath to "" when installing. %cmake -G Ninja \ - -DLLVM_PARALLEL_LINK_JOBS=1 \ - -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DPYTHON_EXECUTABLE=%{__python3} \ - -DCMAKE_INSTALL_RPATH:BOOL=";" \ +%if 0%{debug_package} + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ +%else + -DCMAKE_BUILD_TYPE=Release \ +%endif %ifarch s390 s390x %{arm} %ix86 ppc64le -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ %endif -%if 0%{?compat_build} +%if %{with compat_build} -DLLVM_CONFIG:FILEPATH=%{_bindir}/llvm-config-%{maj_ver}.%{min_ver}-%{__isa_bits} \ - -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ - -DCLANG_INCLUDE_TESTS:BOOL=OFF \ -%else + -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver}.%{min_ver} \ +%endif + \ +%if %{with tests} -DCLANG_INCLUDE_TESTS:BOOL=ON \ -DLLVM_EXTERNAL_LIT=%{_bindir}/lit \ -DLLVM_MAIN_SRC_DIR=%{_datadir}/llvm/src \ -%if 0%{?__isa_bits} == 64 - -DLLVM_LIBDIR_SUFFIX=64 \ -%else - -DLLVM_LIBDIR_SUFFIX= \ -%endif -%endif - \ -%if !0%{compat_build} - -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen \ %else - -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver}.%{min_ver} \ + -DCLANG_INCLUDE_TESTS:BOOL=OFF \ %endif + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DLLVM_PARALLEL_LINK_JOBS=1 \ + -DPYTHON_EXECUTABLE=%{__python3} \ + -DCMAKE_INSTALL_RPATH:BOOL=";" \ + -DLLVM_LIBDIR_SUFFIX="%{llvm_libdir_suffix}" \ -DCLANG_ENABLE_ARCMT:BOOL=ON \ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ -DCLANG_INCLUDE_DOCS:BOOL=ON \ @@ -363,7 +384,7 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py %cmake_install -%if 0%{?compat_build} +%if %{with compat_build} # Remove binaries/other files rm -Rf %{buildroot}%{install_bindir} @@ -375,7 +396,9 @@ mkdir -p %{buildroot}%{pkg_includedir} mv %{buildroot}/%{install_includedir}/clang %{buildroot}/%{pkg_includedir}/ mv %{buildroot}/%{install_includedir}/clang-c %{buildroot}/%{pkg_includedir}/ -%else +%endif + +%if %{with full_build} # install clang python bindings mkdir -p %{buildroot}%{python3_sitelib}/clang/ @@ -434,7 +457,7 @@ mkdir -p %{buildroot}%{_libdir}/clang/%{version}/{include,lib,share}/ rm -Rvf %{buildroot}%{_includedir}/clang-tidy/ %check -%if !0%{?compat_build} +%if %{with tests} # requires lit.py from LLVM utilities # FIXME: Fix failing ARM tests LD_LIBRARY_PATH=%{buildroot}/%{_libdir} %cmake_build --target check-all || \ @@ -447,7 +470,7 @@ false %endif -%if !0%{?compat_build} +%if %{with full_build} %files %license LICENSE.TXT %{clang_binaries} @@ -458,38 +481,30 @@ false %endif %files libs -%if !0%{?compat_build} -%{_libdir}/clang/ -%{_libdir}/*.so.* -%else %{pkg_libdir}/*.so.* -%{pkg_libdir}/clang/%{version} -%endif +%{pkg_libdir}/clang/ %files devel -%if !0%{?compat_build} -%{_libdir}/*.so -%{_includedir}/clang/ -%{_includedir}/clang-c/ -%{_libdir}/cmake/* -%dir %{_datadir}/clang/ -%else %{pkg_libdir}/*.so %{pkg_includedir}/clang/ %{pkg_includedir}/clang-c/ %{pkg_libdir}/cmake/ +%if %{with full_build} +# Why does the devel package own this directory? +%dir %{_datadir}/clang/ %endif +# %%dir means the package owns the directory and not the contents of +# the directory. %files resource-filesystem +%dir %{pkg_libdir}/clang/ %dir %{pkg_libdir}/clang/%{version}/ %dir %{pkg_libdir}/clang/%{version}/include/ %dir %{pkg_libdir}/clang/%{version}/lib/ %dir %{pkg_libdir}/clang/%{version}/share/ -%if !0%{?compat_build} %{pkg_libdir}/clang/%{maj_ver} -%endif -%if !0%{?compat_build} +%if %{with full_build} %files analyzer %{_bindir}/scan-view %{_bindir}/scan-build @@ -525,6 +540,9 @@ false %endif %changelog +* Sat Dec 12 2020 Tom Stellard - 11.0.1-2.rc1 +- Spec file cleanups and improvements + * Tue Dec 01 2020 sguelton@redhat.com - 11.0.1-1.rc1 - llvm 11.0.1-rc1