llvm12/llvm12.spec
Mikhail Novosyolov c4fa0c8d68 Explicitly BR python3
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find Python3 (missing: Python3_EXECUTABLE Interpreter)
2021-05-06 01:59:51 +03:00

170 lines
5.1 KiB
RPMSpec

%define oname llvm
%define _prefix /opt/%{name}
%define _bindir %{_prefix}/bin
%define _datadir %{_prefix}/share
%define _includedir %{_prefix}/include
%define _libdir %{_prefix}/%{_lib}
%define _libexecdir %{_prefix}/libexec
%define _mandir %{_prefix}/share/man
%define debugcflags %{nil}
%define debug_package %{nil}
%define _disable_ld_no_undefined 1
%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
Summary: LLVM and Clang in %{_prefix}
# llvm11
Name: llvm%{maj_ver}
Version: 12.0.0
Release: 3
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
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: binutils-devel
BuildRequires: bison
BuildRequires: chrpath
BuildRequires: cmake
BuildRequires: flex
BuildRequires: graphviz
BuildRequires: groff
BuildRequires: libstdc++-devel
BuildRequires: libtool
BuildRequires: pkgconfig(libffi)
BuildRequires: pkgconfig(libtirpc)
# patchelf is for %%check
BuildRequires: patchelf
BuildRequires: python3
BuildRequires: sed
BuildRequires: tcl
BuildRequires: zip
%if %{compile_apidox}
BuildRequires: doxygen
%endif
Requires: libstdc++-devel
# Do not provide libraries rom /opt and do not try to depend from them
# ! Nothing must be linked with libllvm etc. from here!
AutoReq: 0
AutoProv: 0
# Require this manually instead of AutoReq
%if %rpm4
Requires: %(patchelf --print-soname /usr/%{_lib}/libffi.so || echo foo)%{_arch_tag_suffix}
%else
# _arch_tag_suffix in needed form does not exist in rpm5, make a more dirty hack
Requires: %{_lib}ffi%(patchelf --print-soname /usr/%{_lib}/libffi.so | rev | cut -d. -f1 | rev)
%endif
%description
LVM is a robust system, particularly well suited for developing new mid-level
language-independent analyses and optimizations of all sorts, including those
that require extensive interprocedural analysis. LLVM is also a great target
for front-end development for conventional or research programming languages,
including those which require compile-time, link-time, or run-time optimization
for effective implementation, proper tail calls or garbage collection.
This package contains LLVM and Clang in %{_prefix}.
%files
%{_prefix}
#----------------------------------------------------------------------------
%prep
%autosetup -p1 -n llvm-project-llvmorg-%{version}
%build
# Build with gcc/g++, not clang if it happens to be installed
export CC=gcc
export CXX=g++
# 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
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61659
# (-fno-devirtualize)
#
# compiler-rt assumes off_t is 64 bits -- make sure this is true even on
# 32 bit OSes
%ifarch %ix86
# compiler-rt doesn't support ix86 with x<6 either
export CFLAGS="%{optflags} -march=i686 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -g1"
export CXXFLAGS="%{optflags} -march=i686 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -fno-devirtualize -g1 -Wno-redundant-move"
%else
export CXXFLAGS="%{optflags} -fno-devirtualize -g1 -Wno-redundant-move"
%endif
%ifarch %ix86
# Fix noexecstack
for i in compiler-rt/lib/builtins/i386/*.S; do
cat >>$i <<'EOF'
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
EOF
done
%endif
%setup_compile_flags
mkdir -p build
cd build
cmake ../llvm \
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld;polly' \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_LIBDIR_SUFFIX=$(echo %{_lib} | sed -e 's,^lib,,') \
-DCLANG_LIBDIR_SUFFIX=$(echo %{_lib} | sed -e 's,^lib,,') \
-DLLVM_ENABLE_FFI:BOOL=ON \
-DLLVM_ENABLE_RTTI:BOOL=ON \
-DOCAMLFIND=NOTFOUND \
%if %{compile_apidox}
-DLLVM_INCLUDE_DOCS:BOOL=ON \
-DLLVM_BUILD_DOCS:BOOL=ON \
%endif
-DLLVM_OPTIMIZED_TABLEGEN=ON
%make -s
%install
%makeinstall_std -C build
# [From OMV]
# Polly bits as described on
# http://polly.llvm.org/example_load_Polly_into_clang.html
cat >%{buildroot}%{_bindir}/pollycc <<'EOF'
#!/bin/sh
exec %{_bindir}/clang -O3 -Xclang -load -Xclang %{_libdir}/LLVMPolly.so "$@"
EOF
cat >%{buildroot}%{_bindir}/pollyc++ <<'EOF'
#!/bin/sh
exec %{_bindir}/clang++ -O3 -Xclang -load -Xclang %{_libdir}/LLVMPolly.so "$@"
EOF
chmod 0755 %{buildroot}%{_bindir}/pollycc %{buildroot}%{_bindir}/pollyc++
# Install libraries used for testing
cp -a build/%{_lib}/BugpointPasses.so %{buildroot}%{_libdir}
cp -a build/%{_lib}/LLVMHello.so %{buildroot}%{_libdir}
# Versionize shebangs python
sed '1 s,^.*$,#!%{__python3},' -i %{buildroot}%{_bindir}/{hmaptool,scan-view}
%check
patchelf --print-rpath %{buildroot}%{_bindir}/clang | grep -q %{_libdir}