mirror of
https://abf.rosa.ru/djam/llvm17.git
synced 2025-02-23 14:02:52 +00:00
245 lines
7.6 KiB
RPMSpec
245 lines
7.6 KiB
RPMSpec
|
%global optflags %(echo %{optflags} | sed -e 's/-ffat-lto-objects//g' -e 's/-fvar-tracking-assignments//g' -e 's/-Wa,//g' -e 's/--compress-debug-sections//g' -e 's/-fno-devirtualize//g' )
|
||
|
|
||
|
%define oname llvm
|
||
|
|
||
|
%define _olibdir /usr/%{_lib}
|
||
|
%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 _disable_ld_no_undefined 1
|
||
|
%global optflags %{optflags} -fno-strict-aliasing
|
||
|
%global ldflags %{ldflags} -Wl,-rpath,%{_libdir}
|
||
|
|
||
|
%define compile_apidox 1
|
||
|
#{?_with_apidox: %{expand: %%global compile_apidox 1}}
|
||
|
|
||
|
%define maj_ver 17
|
||
|
%define min_ver 1
|
||
|
%define libname %mklibname llvm%{maj_ver}
|
||
|
|
||
|
%if %mdkversion == 201610
|
||
|
%bcond_without lldb
|
||
|
%else
|
||
|
%bcond_with lldb
|
||
|
%endif
|
||
|
|
||
|
%define _llvm_bs_ver 16
|
||
|
|
||
|
%define commit 434575c026c81319b393f64047025b54e69e24c2
|
||
|
%define commit_short %(echo %{commit} | head -c 6)
|
||
|
|
||
|
Summary: LLVM and Clang in %{_prefix}
|
||
|
# llvm16
|
||
|
Name: llvm%{maj_ver}
|
||
|
Version: %{maj_ver}.0.%{min_ver}
|
||
|
Release: 1
|
||
|
License: NCSA
|
||
|
Group: Development/Other
|
||
|
URL: https://llvm.org
|
||
|
#Source0: https://github.com/llvm/llvm-project/archive/%{version}/%{name}-%{version}.tar.gz
|
||
|
Source0: https://github.com/llvm/llvm-project/archive/llvmorg-%{version}/%{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: gcc
|
||
|
BuildRequires: stdc++-devel
|
||
|
# gcc is too old in rosa2016.1, llvm12 was buildable with it but llvm13 is already not
|
||
|
BuildRequires: llvm%{_llvm_bs_ver}
|
||
|
BuildRequires: binutils-devel
|
||
|
BuildRequires: bison
|
||
|
BuildRequires: chrpath
|
||
|
BuildRequires: cmake
|
||
|
BuildRequires: ninja
|
||
|
BuildRequires: flex
|
||
|
BuildRequires: graphviz
|
||
|
BuildRequires: groff
|
||
|
BuildRequires: libstdc++-devel
|
||
|
BuildRequires: stdc++-gcc10-devel
|
||
|
BuildRequires: libtool
|
||
|
BuildRequires: pkgconfig(libffi)
|
||
|
BuildRequires: pkgconfig(libtirpc)
|
||
|
# patchelf is for %%check
|
||
|
BuildRequires: patchelf
|
||
|
BuildRequires: python3-devel
|
||
|
BuildRequires: python38-devel
|
||
|
BuildRequires: sed
|
||
|
BuildRequires: tcl
|
||
|
BuildRequires: zip
|
||
|
%if %{compile_apidox}
|
||
|
BuildRequires: doxygen
|
||
|
%endif
|
||
|
BuildRequires: clang
|
||
|
|
||
|
Requires: libstdc++-devel
|
||
|
Requires: stdc++-gcc10-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}
|
||
|
|
||
|
#----------------------------------------------------------------------------
|
||
|
|
||
|
%package -n %{libname}
|
||
|
Summary: LLVM %{maj_ver} shared library
|
||
|
Group: System/Libraries
|
||
|
AutoReq: 1
|
||
|
AutoProv: 1
|
||
|
|
||
|
%description -n %{libname}
|
||
|
LLVM %{maj_ver} shared library
|
||
|
|
||
|
%files -n %{libname}
|
||
|
%{_olibdir}/libLLVM-%{maj_ver}*.so
|
||
|
|
||
|
#----------------------------------------------------------------------------
|
||
|
|
||
|
%prep
|
||
|
%setup -qn llvm-project-llvmorg-%{version}
|
||
|
|
||
|
|
||
|
%build
|
||
|
# gcc is too old in rosa2016.1
|
||
|
#export CC=gcc
|
||
|
#export CXX=g++
|
||
|
export CC=/opt/llvm%{_llvm_bs_ver}/bin/clang
|
||
|
export CXX=/opt/llvm%{_llvm_bs_ver}/bin/clang++
|
||
|
export AR=/opt/llvm%{_llvm_bs_ver}/bin/llvm-ar
|
||
|
export NM=/opt/llvm%{_llvm_bs_ver}/bin/llvm-nm
|
||
|
|
||
|
%setup_compile_flags
|
||
|
|
||
|
# 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"
|
||
|
export CFLAGS="`echo %{optflags} | sed -e 's/-gdwarf-4//' -e 's/-fvar-tracking-assignments//' -e 's/-frecord-gcc-switches//' -e 's/-flto//g'`"
|
||
|
%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
|
||
|
|
||
|
%if %{mdvver} == 201610
|
||
|
export PYTHONPATH=/usr/bin
|
||
|
export PATH=$PYTHONPATH:$PATH
|
||
|
%endif
|
||
|
|
||
|
export CXXFLAGS="$CFLAGS"
|
||
|
|
||
|
export READELF=readelf
|
||
|
|
||
|
export LDFLAGS="-lstdc++-gcc10"
|
||
|
|
||
|
#clang_gcc_wrapper
|
||
|
|
||
|
|
||
|
|
||
|
mkdir -p build
|
||
|
# We actually need only clang and lld 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 and lld only for now.
|
||
|
# -DLLVM_ENABLE_PROJECTS='clang-tools-extra;libcxx;libcxxabi;%{!?with_lldb:lldb;}compiler-rt;lld;polly'
|
||
|
cmake -S llvm -B build -G Ninja \
|
||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||
|
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
|
||
|
-DCMAKE_BUILD_TYPE=Release \
|
||
|
-DLLVM_ENABLE_PROJECTS='clang;lld' \
|
||
|
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||
|
-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
|
||
|
-DLLVM_VERSION_SUFFIX="" \
|
||
|
-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 \
|
||
|
%if %{mdvver} <= 201610
|
||
|
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN:BOOL=ON \
|
||
|
%endif
|
||
|
%if %{compile_apidox}
|
||
|
-DLLVM_INCLUDE_DOCS:BOOL=ON \
|
||
|
-DLLVM_BUILD_DOCS:BOOL=ON \
|
||
|
%endif
|
||
|
-DLLVM_OPTIMIZED_TABLEGEN=ON \
|
||
|
-DCMAKE_CXX_FLAGS="-nostdinc++ -I/usr/include/libstdc++-gcc10 -I/usr/include/libstdc++-gcc10/%{_host} -Wc++11-narrowing " \
|
||
|
-DCMAKE_C_FLAGS="-nostdinc++ -I/usr/include/libstdc++-gcc10 -I/usr/include/libstdc++-gcc10/%{_host} -Wc++11-narrowing "
|
||
|
|
||
|
cmake --build build
|
||
|
|
||
|
%install
|
||
|
DESTDIR=%{buildroot} cmake --install 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}
|
||
|
|
||
|
# Will be used in Mesa
|
||
|
mkdir -p %{buildroot}%{_olibdir}
|
||
|
install -m0755 %{buildroot}%{_libdir}/libLLVM-%{maj_ver}.so %{buildroot}%{_olibdir}
|
||
|
# RPATH to /opt/... is not needed here
|
||
|
patchelf --remove-rpath %{buildroot}%{_olibdir}/*.so*
|
||
|
|
||
|
# Versionize shebangs python
|
||
|
sed '1 s,^.*$,#!%{__python3},' -i %{buildroot}%{_bindir}/{hmaptool,scan-view}
|
||
|
|
||
|
%check
|
||
|
#atchelf --print-rpath %{buildroot}%{_bindir}/clang | grep -q %{_libdir}
|